Mercurial > pidgin.yaz
annotate src/value.h @ 10467:cbbf5af9e520
[gaim-migrate @ 11747]
Stupid mistake. Hopefully this will enable SecurID for real.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 03 Jan 2005 05:08:03 +0000 |
parents | af06746954de |
children | 5cb55bcad11b |
rev | line source |
---|---|
6562 | 1 /** |
2 * @file value.h 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 #ifndef _GAIM_VALUE_H_ | |
26 #define _GAIM_VALUE_H_ | |
27 | |
6565
cb00e9647033
[gaim-migrate @ 7087]
Christian Hammond <chipx86@chipx86.com>
parents:
6563
diff
changeset
|
28 #include <glib.h> |
cb00e9647033
[gaim-migrate @ 7087]
Christian Hammond <chipx86@chipx86.com>
parents:
6563
diff
changeset
|
29 |
6562 | 30 /** |
31 * Specific value types. | |
32 */ | |
33 typedef enum | |
34 { | |
35 GAIM_TYPE_UNKNOWN = 0, /**< Unknown type. */ | |
36 GAIM_TYPE_SUBTYPE, /**< Subtype. */ | |
37 GAIM_TYPE_CHAR, /**< Character. */ | |
38 GAIM_TYPE_UCHAR, /**< Unsigned character. */ | |
39 GAIM_TYPE_BOOLEAN, /**< Boolean. */ | |
40 GAIM_TYPE_SHORT, /**< Short integer. */ | |
41 GAIM_TYPE_USHORT, /**< Unsigned short integer. */ | |
42 GAIM_TYPE_INT, /**< Integer. */ | |
43 GAIM_TYPE_UINT, /**< Unsigned integer. */ | |
44 GAIM_TYPE_LONG, /**< Long integer. */ | |
45 GAIM_TYPE_ULONG, /**< Unsigned long integer. */ | |
46 GAIM_TYPE_INT64, /**< 64-bit integer. */ | |
47 GAIM_TYPE_UINT64, /**< 64-bit unsigned integer. */ | |
48 GAIM_TYPE_STRING, /**< String. */ | |
49 GAIM_TYPE_OBJECT, /**< Object pointer. */ | |
50 GAIM_TYPE_POINTER, /**< Generic pointer. */ | |
51 GAIM_TYPE_ENUM, /**< Enum. */ | |
52 GAIM_TYPE_BOXED /**< Boxed pointer with specific type. */ | |
53 | |
54 } GaimType; | |
55 | |
56 /** | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
57 * Gaim-specific subtype values. |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
58 */ |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
59 typedef enum |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
60 { |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
61 GAIM_SUBTYPE_UNKNOWN = 0, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
62 GAIM_SUBTYPE_ACCOUNT, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
63 GAIM_SUBTYPE_BLIST, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
64 GAIM_SUBTYPE_BLIST_BUDDY, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
65 GAIM_SUBTYPE_BLIST_GROUP, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
66 GAIM_SUBTYPE_BLIST_CHAT, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
67 GAIM_SUBTYPE_CONNECTION, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
68 GAIM_SUBTYPE_CONVERSATION, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
69 GAIM_SUBTYPE_CONV_WINDOW, |
8817 | 70 GAIM_SUBTYPE_PLUGIN, |
71 GAIM_SUBTYPE_BLIST_NODE | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
72 |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
73 } GaimSubType; |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
74 |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
75 /** |
6562 | 76 * A wrapper for a type, subtype, and specific type of value. |
77 */ | |
78 typedef struct | |
79 { | |
80 GaimType type; | |
81 unsigned short flags; | |
82 | |
83 union | |
84 { | |
85 char char_data; | |
86 unsigned char uchar_data; | |
87 gboolean boolean_data; | |
88 short short_data; | |
89 unsigned short ushort_data; | |
90 int int_data; | |
91 unsigned int uint_data; | |
92 long long_data; | |
93 unsigned long ulong_data; | |
94 gint64 int64_data; | |
95 guint64 uint64_data; | |
96 char *string_data; | |
97 void *object_data; | |
98 void *pointer_data; | |
99 int enum_data; | |
100 void *boxed_data; | |
101 | |
102 } data; | |
103 | |
104 union | |
105 { | |
106 unsigned int subtype; | |
107 char *specific_type; | |
108 | |
109 } u; | |
110 | |
111 } GaimValue; | |
112 | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
113 #ifdef __cplusplus |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
114 extern "C" { |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
115 #endif |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
116 |
6562 | 117 /** |
118 * Creates a new GaimValue. | |
119 * | |
120 * This function takes a type and, depending on that type, a sub-type | |
121 * or specific type. | |
122 * | |
123 * If @a type is GAIM_TYPE_POINTER, the next parameter must be a | |
124 * string representing the specific type. | |
125 * | |
126 * If @a type is GAIM_TYPE_SUBTYPE, the next parameter must be a | |
127 * integer or enum representing the sub-type. | |
128 * | |
129 * If the subtype or specific type is not set when required, random | |
130 * errors may occur. You have been warned. | |
131 * | |
132 * @param type The type. | |
133 * | |
134 * @return The new value. | |
135 */ | |
136 GaimValue *gaim_value_new(GaimType type, ...); | |
137 | |
138 /** | |
139 * Creates a new outgoing GaimValue. | |
140 * | |
141 * This function takes a type and, depending on that type, a sub-type | |
142 * or specific type. | |
143 * | |
144 * If @a type is GAIM_TYPE_POINTER, the next parameter must be a | |
145 * string representing the specific type. | |
146 * | |
147 * If @a type is GAIM_TYPE_SUBTYPE, the next parameter must be a | |
148 * integer or enum representing the sub-type. | |
149 * | |
150 * If the sub-type or specific type is not set when required, random | |
151 * errors may occur. You have been warned. | |
152 * | |
153 * @param type The type. | |
154 * | |
155 * @return The new value. | |
156 */ | |
157 GaimValue *gaim_value_new_outgoing(GaimType type, ...); | |
158 | |
159 /** | |
160 * Destroys a GaimValue. | |
161 * | |
162 * @param value The value to destroy. | |
163 */ | |
164 void gaim_value_destroy(GaimValue *value); | |
165 | |
166 /** | |
8809
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
167 * Duplicated a GaimValue. |
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 * @param value The value to duplicate. |
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 * @return The duplicate value. |
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 GaimValue *gaim_value_dup(const GaimValue *value); |
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 /** |
6562 | 176 * Returns a value's type. |
177 * | |
10071 | 178 * @param value The value whose type you want. |
179 * | |
6562 | 180 * @return The value's type. |
181 */ | |
182 GaimType gaim_value_get_type(const GaimValue *value); | |
183 | |
184 /** | |
185 * Returns a value's subtype. | |
186 * | |
187 * If the value's type is not GAIM_TYPE_SUBTYPE, this will return 0. | |
188 * Subtypes should never have a subtype of 0. | |
189 * | |
10071 | 190 * @param value The value whose subtype you want. |
191 * | |
6562 | 192 * @return The value's subtype, or 0 if @a type is not GAIM_TYPE_SUBTYPE. |
193 */ | |
194 unsigned int gaim_value_get_subtype(const GaimValue *value); | |
195 | |
196 /** | |
197 * Returns a value's specific type. | |
198 * | |
199 * If the value's type is not GAIM_TYPE_BOXED, this will return @c NULL. | |
200 * | |
10071 | 201 * @param value The value whose specific type you want. |
202 * | |
6562 | 203 * @return The value's specific type, or @a NULL if not GAIM_TYPE_BOXED. |
204 */ | |
205 const char *gaim_value_get_specific_type(const GaimValue *value); | |
206 | |
207 /** | |
208 * Returns whether or not the value is an outgoing value. | |
209 * | |
210 * @param value The value. | |
211 * | |
212 * @return TRUE if the value is outgoing, or FALSE otherwise. | |
213 */ | |
214 gboolean gaim_value_is_outgoing(const GaimValue *value); | |
215 | |
216 /** | |
217 * Sets the value's character data. | |
218 * | |
219 * @param value The value. | |
220 * @param data The character data. | |
221 */ | |
222 void gaim_value_set_char(GaimValue *value, char data); | |
223 | |
224 /** | |
225 * Sets the value's unsigned character data. | |
226 * | |
227 * @param value The value. | |
228 * @param data The unsigned character data. | |
229 */ | |
230 void gaim_value_set_uchar(GaimValue *value, unsigned char data); | |
231 | |
232 /** | |
233 * Sets the value's boolean data. | |
234 * | |
235 * @param value The value. | |
236 * @param data The boolean data. | |
237 */ | |
238 void gaim_value_set_boolean(GaimValue *value, gboolean data); | |
239 | |
240 /** | |
241 * Sets the value's short integer data. | |
242 * | |
243 * @param value The value. | |
244 * @param data The short integer data. | |
245 */ | |
246 void gaim_value_set_short(GaimValue *value, short data); | |
247 | |
248 /** | |
249 * Sets the value's unsigned short integer data. | |
250 * | |
251 * @param value The value. | |
252 * @param data The unsigned short integer data. | |
253 */ | |
254 void gaim_value_set_ushort(GaimValue *value, unsigned short data); | |
255 | |
256 /** | |
257 * Sets the value's integer data. | |
258 * | |
259 * @param value The value. | |
260 * @param data The integer data. | |
261 */ | |
262 void gaim_value_set_int(GaimValue *value, int data); | |
263 | |
264 /** | |
265 * Sets the value's unsigned integer data. | |
266 * | |
267 * @param value The value. | |
268 * @param data The unsigned integer data. | |
269 */ | |
270 void gaim_value_set_uint(GaimValue *value, unsigned int data); | |
271 | |
272 /** | |
273 * Sets the value's long integer data. | |
274 * | |
275 * @param value The value. | |
276 * @param data The long integer data. | |
277 */ | |
278 void gaim_value_set_long(GaimValue *value, long data); | |
279 | |
280 /** | |
281 * Sets the value's unsigned long integer data. | |
282 * | |
283 * @param value The value. | |
284 * @param data The unsigned long integer data. | |
285 */ | |
286 void gaim_value_set_ulong(GaimValue *value, unsigned long data); | |
287 | |
288 /** | |
289 * Sets the value's 64-bit integer data. | |
290 * | |
291 * @param value The value. | |
292 * @param data The 64-bit integer data. | |
293 */ | |
294 void gaim_value_set_int64(GaimValue *value, gint64 data); | |
295 | |
296 /** | |
297 * Sets the value's unsigned 64-bit integer data. | |
298 * | |
299 * @param value The value. | |
300 * @param data The unsigned 64-bit integer data. | |
301 */ | |
302 void gaim_value_set_uint64(GaimValue *value, guint64 data); | |
303 | |
304 /** | |
305 * Sets the value's string data. | |
306 * | |
307 * @param value The value. | |
308 * @param data The string data. | |
309 */ | |
310 void gaim_value_set_string(GaimValue *value, const char *data); | |
311 | |
312 /** | |
313 * Sets the value's object data. | |
314 * | |
315 * @param value The value. | |
316 * @param data The object data. | |
317 */ | |
318 void gaim_value_set_object(GaimValue *value, void *data); | |
319 | |
320 /** | |
321 * Sets the value's pointer data. | |
322 * | |
323 * @param value The value. | |
324 * @param data The pointer data. | |
325 */ | |
326 void gaim_value_set_pointer(GaimValue *value, void *data); | |
327 | |
328 /** | |
329 * Sets the value's enum data. | |
330 * | |
331 * @param value The value. | |
332 * @param data The enum data. | |
333 */ | |
334 void gaim_value_set_enum(GaimValue *value, int data); | |
335 | |
336 /** | |
337 * Sets the value's boxed data. | |
338 * | |
339 * @param value The value. | |
340 * @param data The boxed data. | |
341 */ | |
342 void gaim_value_set_boxed(GaimValue *value, void *data); | |
343 | |
344 /** | |
345 * Returns the value's character data. | |
346 * | |
347 * @param value The value. | |
348 * | |
349 * @return The character data. | |
350 */ | |
351 char gaim_value_get_char(const GaimValue *value); | |
352 | |
353 /** | |
354 * Returns the value's unsigned character data. | |
355 * | |
356 * @param value The value. | |
357 * | |
358 * @return The unsigned character data. | |
359 */ | |
360 unsigned char gaim_value_get_uchar(const GaimValue *value); | |
361 | |
362 /** | |
363 * Returns the value's boolean data. | |
364 * | |
365 * @param value The value. | |
366 * | |
367 * @return The boolean data. | |
368 */ | |
369 gboolean gaim_value_get_boolean(const GaimValue *value); | |
370 | |
371 /** | |
372 * Returns the value's short integer data. | |
373 * | |
374 * @param value The value. | |
375 * | |
376 * @return The short integer data. | |
377 */ | |
378 short gaim_value_get_short(const GaimValue *value); | |
379 | |
380 /** | |
381 * Returns the value's unsigned short integer data. | |
382 * | |
383 * @param value The value. | |
384 * | |
385 * @return The unsigned short integer data. | |
386 */ | |
387 unsigned short gaim_value_get_ushort(const GaimValue *value); | |
388 | |
389 /** | |
390 * Returns the value's integer data. | |
391 * | |
392 * @param value The value. | |
393 * | |
394 * @return The integer data. | |
395 */ | |
396 int gaim_value_get_int(const GaimValue *value); | |
397 | |
398 /** | |
399 * Returns the value's unsigned integer data. | |
400 * | |
401 * @param value The value. | |
402 * | |
403 * @return The unsigned integer data. | |
404 */ | |
405 unsigned int gaim_value_get_uint(const GaimValue *value); | |
406 | |
407 /** | |
408 * Returns the value's long integer data. | |
409 * | |
410 * @param value The value. | |
411 * | |
412 * @return The long integer data. | |
413 */ | |
414 long gaim_value_get_long(const GaimValue *value); | |
415 | |
416 /** | |
417 * Returns the value's unsigned long integer data. | |
418 * | |
419 * @param value The value. | |
420 * | |
421 * @return The unsigned long integer data. | |
422 */ | |
423 unsigned long gaim_value_get_ulong(const GaimValue *value); | |
424 | |
425 /** | |
426 * Returns the value's 64-bit integer data. | |
427 * | |
428 * @param value The value. | |
429 * | |
430 * @return The 64-bit integer data. | |
431 */ | |
432 gint64 gaim_value_get_int64(const GaimValue *value); | |
433 | |
434 /** | |
435 * Returns the value's unsigned 64-bit integer data. | |
436 * | |
437 * @param value The value. | |
438 * | |
439 * @return The unsigned 64-bit integer data. | |
440 */ | |
441 guint64 gaim_value_get_uint64(const GaimValue *value); | |
442 | |
443 /** | |
444 * Returns the value's string data. | |
445 * | |
446 * @param value The value. | |
447 * | |
448 * @return The string data. | |
449 */ | |
450 const char *gaim_value_get_string(const GaimValue *value); | |
451 | |
452 /** | |
453 * Returns the value's object data. | |
454 * | |
455 * @param value The value. | |
456 * | |
457 * @return The object data. | |
458 */ | |
459 void *gaim_value_get_object(const GaimValue *value); | |
460 | |
461 /** | |
462 * Returns the value's pointer data. | |
463 * | |
464 * @param value The value. | |
465 * | |
466 * @return The pointer data. | |
467 */ | |
468 void *gaim_value_get_pointer(const GaimValue *value); | |
469 | |
470 /** | |
471 * Returns the value's enum data. | |
472 * | |
473 * @param value The value. | |
474 * | |
475 * @return The enum data. | |
476 */ | |
477 int gaim_value_get_enum(const GaimValue *value); | |
478 | |
479 /** | |
480 * Returns the value's boxed data. | |
481 * | |
482 * @param value The value. | |
483 * | |
484 * @return The boxed data. | |
485 */ | |
486 void *gaim_value_get_boxed(const GaimValue *value); | |
487 | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
488 #ifdef __cplusplus |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
489 } |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
490 #endif |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
491 |
6562 | 492 #endif /* _GAIM_VALUE_H_ */ |