rename accountopt.[ch] to purpleaccountoption.[ch]
[pidgin-git.git] / libpurple / signals.c
blobc9ab7b90d916a051836bfc9a601fc0f9fca807f8
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
21 #include "internal.h"
23 #include "debug.h"
24 #include "signals.h"
26 /* must include this to use G_VA_COPY */
27 #include <string.h>
29 typedef struct
31 void *instance;
33 GHashTable *signals;
34 size_t signal_count;
36 gulong next_signal_id;
38 } PurpleInstanceData;
40 typedef struct
42 gulong id;
44 PurpleSignalMarshalFunc marshal;
46 int num_values;
47 GType *value_types;
48 GType ret_type;
50 GList *handlers;
51 size_t handler_count;
53 gulong next_handler_id;
54 } PurpleSignalData;
56 typedef struct
58 gulong id;
59 PurpleCallback cb;
60 void *handle;
61 void *data;
62 gboolean use_vargs;
63 int priority;
65 } PurpleSignalHandlerData;
67 static GHashTable *instance_table = NULL;
69 static void
70 destroy_instance_data(PurpleInstanceData *instance_data)
72 g_hash_table_destroy(instance_data->signals);
74 g_free(instance_data);
77 static void
78 destroy_signal_data(PurpleSignalData *signal_data)
80 g_list_free_full(signal_data->handlers, g_free);
81 g_free(signal_data->value_types);
82 g_free(signal_data);
85 gulong
86 purple_signal_register(void *instance, const char *signal,
87 PurpleSignalMarshalFunc marshal,
88 GType ret_type, int num_values, ...)
90 PurpleInstanceData *instance_data;
91 PurpleSignalData *signal_data;
92 va_list args;
94 g_return_val_if_fail(instance != NULL, 0);
95 g_return_val_if_fail(signal != NULL, 0);
96 g_return_val_if_fail(marshal != NULL, 0);
98 instance_data =
99 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
101 if (instance_data == NULL)
103 instance_data = g_new0(PurpleInstanceData, 1);
105 instance_data->instance = instance;
106 instance_data->next_signal_id = 1;
108 instance_data->signals =
109 g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
110 (GDestroyNotify)destroy_signal_data);
112 g_hash_table_insert(instance_table, instance, instance_data);
115 signal_data = g_new0(PurpleSignalData, 1);
116 signal_data->id = instance_data->next_signal_id;
117 signal_data->marshal = marshal;
118 signal_data->next_handler_id = 1;
119 signal_data->ret_type = ret_type;
120 signal_data->num_values = num_values;
122 if (num_values > 0)
124 int i;
126 signal_data->value_types = g_new0(GType, num_values);
128 va_start(args, num_values);
130 for (i = 0; i < num_values; i++)
131 signal_data->value_types[i] = va_arg(args, GType);
133 va_end(args);
136 g_hash_table_insert(instance_data->signals,
137 g_strdup(signal), signal_data);
139 instance_data->next_signal_id++;
140 instance_data->signal_count++;
142 return signal_data->id;
145 void
146 purple_signal_unregister(void *instance, const char *signal)
148 PurpleInstanceData *instance_data;
150 g_return_if_fail(instance != NULL);
151 g_return_if_fail(signal != NULL);
153 instance_data =
154 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
156 g_return_if_fail(instance_data != NULL);
158 g_hash_table_remove(instance_data->signals, signal);
160 instance_data->signal_count--;
162 if (instance_data->signal_count == 0)
164 /* Unregister the instance. */
165 g_hash_table_remove(instance_table, instance);
169 void
170 purple_signals_unregister_by_instance(void *instance)
172 g_return_if_fail(instance != NULL);
174 g_hash_table_remove(instance_table, instance);
177 * Makes things easier (more annoying?) for developers who don't have
178 * things registering and unregistering in the right order :)
180 /* g_return_if_fail(found); */
183 void
184 purple_signal_get_types(void *instance, const char *signal,
185 GType *ret_type,
186 int *num_values, GType **value_types)
188 PurpleInstanceData *instance_data;
189 PurpleSignalData *signal_data;
191 g_return_if_fail(instance != NULL);
192 g_return_if_fail(signal != NULL);
193 g_return_if_fail(num_values != NULL);
194 g_return_if_fail(value_types != NULL);
196 /* Get the instance data */
197 instance_data =
198 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
200 g_return_if_fail(instance_data != NULL);
202 /* Get the signal data */
203 signal_data =
204 (PurpleSignalData *)g_hash_table_lookup(instance_data->signals, signal);
206 g_return_if_fail(signal_data != NULL);
208 *num_values = signal_data->num_values;
209 *value_types = signal_data->value_types;
211 if (ret_type != NULL)
212 *ret_type = signal_data->ret_type;
215 static gint handler_priority(void * a, void * b) {
216 PurpleSignalHandlerData *ah = (PurpleSignalHandlerData*)a;
217 PurpleSignalHandlerData *bh = (PurpleSignalHandlerData*)b;
218 if (ah->priority > bh->priority) return 1;
219 if (ah->priority < bh->priority) return -1;
220 return 0;
223 static gulong
224 signal_connect_common(void *instance, const char *signal, void *handle,
225 PurpleCallback func, void *data, int priority, gboolean use_vargs)
227 PurpleInstanceData *instance_data;
228 PurpleSignalData *signal_data;
229 PurpleSignalHandlerData *handler_data;
231 g_return_val_if_fail(instance != NULL, 0);
232 g_return_val_if_fail(signal != NULL, 0);
233 g_return_val_if_fail(handle != NULL, 0);
234 g_return_val_if_fail(func != NULL, 0);
236 /* Get the instance data */
237 instance_data =
238 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
240 if (instance_data == NULL)
242 purple_debug_warning("signals", "Something tried to register a callback "
243 "for the '%s' signal, but we do not have any signals "
244 "registered with the given handle\n", signal);
245 g_return_val_if_reached(0);
248 /* Get the signal data */
249 signal_data =
250 (PurpleSignalData *)g_hash_table_lookup(instance_data->signals, signal);
252 if (signal_data == NULL)
254 purple_debug(PURPLE_DEBUG_ERROR, "signals",
255 "Signal data for %s not found!\n", signal);
256 return 0;
259 /* Create the signal handler data */
260 handler_data = g_new0(PurpleSignalHandlerData, 1);
261 handler_data->id = signal_data->next_handler_id;
262 handler_data->cb = func;
263 handler_data->handle = handle;
264 handler_data->data = data;
265 handler_data->use_vargs = use_vargs;
266 handler_data->priority = priority;
268 signal_data->handlers = g_list_insert_sorted(signal_data->handlers, handler_data, (GCompareFunc)handler_priority);
269 signal_data->handler_count++;
270 signal_data->next_handler_id++;
272 return handler_data->id;
275 gulong
276 purple_signal_connect_priority(void *instance, const char *signal, void *handle,
277 PurpleCallback func, void *data, int priority)
279 return signal_connect_common(instance, signal, handle, func, data, priority, FALSE);
282 gulong
283 purple_signal_connect(void *instance, const char *signal, void *handle,
284 PurpleCallback func, void *data)
286 return signal_connect_common(instance, signal, handle, func, data, PURPLE_SIGNAL_PRIORITY_DEFAULT, FALSE);
289 gulong
290 purple_signal_connect_priority_vargs(void *instance, const char *signal, void *handle,
291 PurpleCallback func, void *data, int priority)
293 return signal_connect_common(instance, signal, handle, func, data, priority, TRUE);
296 gulong
297 purple_signal_connect_vargs(void *instance, const char *signal, void *handle,
298 PurpleCallback func, void *data)
300 return signal_connect_common(instance, signal, handle, func, data, PURPLE_SIGNAL_PRIORITY_DEFAULT, TRUE);
303 void
304 purple_signal_disconnect(void *instance, const char *signal,
305 void *handle, PurpleCallback func)
307 PurpleInstanceData *instance_data;
308 PurpleSignalData *signal_data;
309 PurpleSignalHandlerData *handler_data;
310 GList *l;
311 gboolean found = FALSE;
313 g_return_if_fail(instance != NULL);
314 g_return_if_fail(signal != NULL);
315 g_return_if_fail(handle != NULL);
316 g_return_if_fail(func != NULL);
318 /* Get the instance data */
319 instance_data =
320 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
322 g_return_if_fail(instance_data != NULL);
324 /* Get the signal data */
325 signal_data =
326 (PurpleSignalData *)g_hash_table_lookup(instance_data->signals, signal);
328 if (signal_data == NULL)
330 purple_debug(PURPLE_DEBUG_ERROR, "signals",
331 "Signal data for %s not found!\n", signal);
332 return;
335 /* Find the handler data. */
336 for (l = signal_data->handlers; l != NULL; l = l->next)
338 handler_data = (PurpleSignalHandlerData *)l->data;
340 if (handler_data->handle == handle && handler_data->cb == func)
342 g_free(handler_data);
344 signal_data->handlers = g_list_delete_link(signal_data->handlers,
346 signal_data->handler_count--;
348 found = TRUE;
350 break;
354 /* See note somewhere about this actually helping developers.. */
355 g_return_if_fail(found);
359 * TODO: Make this all more efficient by storing a list of handlers, keyed
360 * to a handle.
362 static void
363 disconnect_handle_from_signals(const char *signal,
364 PurpleSignalData *signal_data, void *handle)
366 GList *l, *l_next;
367 PurpleSignalHandlerData *handler_data;
369 for (l = signal_data->handlers; l != NULL; l = l_next)
371 handler_data = (PurpleSignalHandlerData *)l->data;
372 l_next = l->next;
374 if (handler_data->handle == handle)
376 g_free(handler_data);
378 signal_data->handler_count--;
379 signal_data->handlers = g_list_delete_link(signal_data->handlers,
385 static void
386 disconnect_handle_from_instance(void *instance,
387 PurpleInstanceData *instance_data,
388 void *handle)
390 g_hash_table_foreach(instance_data->signals,
391 (GHFunc)disconnect_handle_from_signals, handle);
394 void
395 purple_signals_disconnect_by_handle(void *handle)
397 g_return_if_fail(handle != NULL);
399 g_hash_table_foreach(instance_table,
400 (GHFunc)disconnect_handle_from_instance, handle);
403 void
404 purple_signal_emit(void *instance, const char *signal, ...)
406 va_list args;
408 g_return_if_fail(instance != NULL);
409 g_return_if_fail(signal != NULL);
411 va_start(args, signal);
412 purple_signal_emit_vargs(instance, signal, args);
413 va_end(args);
416 void
417 purple_signal_emit_vargs(void *instance, const char *signal, va_list args)
419 PurpleInstanceData *instance_data;
420 PurpleSignalData *signal_data;
421 PurpleSignalHandlerData *handler_data;
422 GList *l, *l_next;
423 va_list tmp;
425 g_return_if_fail(instance != NULL);
426 g_return_if_fail(signal != NULL);
428 instance_data =
429 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
431 g_return_if_fail(instance_data != NULL);
433 signal_data =
434 (PurpleSignalData *)g_hash_table_lookup(instance_data->signals, signal);
436 if (signal_data == NULL)
438 purple_debug(PURPLE_DEBUG_ERROR, "signals",
439 "Signal data for %s not found!\n", signal);
440 return;
443 for (l = signal_data->handlers; l != NULL; l = l_next)
445 l_next = l->next;
447 handler_data = (PurpleSignalHandlerData *)l->data;
449 /* This is necessary because a va_list may only be
450 * evaluated once */
451 G_VA_COPY(tmp, args);
453 if (handler_data->use_vargs)
455 ((void (*)(va_list, void *))handler_data->cb)(tmp,
456 handler_data->data);
458 else
460 signal_data->marshal(handler_data->cb, tmp,
461 handler_data->data, NULL);
464 va_end(tmp);
468 void *
469 purple_signal_emit_return_1(void *instance, const char *signal, ...)
471 void *ret_val;
472 va_list args;
474 g_return_val_if_fail(instance != NULL, NULL);
475 g_return_val_if_fail(signal != NULL, NULL);
477 va_start(args, signal);
478 ret_val = purple_signal_emit_vargs_return_1(instance, signal, args);
479 va_end(args);
481 return ret_val;
484 void *
485 purple_signal_emit_vargs_return_1(void *instance, const char *signal,
486 va_list args)
488 PurpleInstanceData *instance_data;
489 PurpleSignalData *signal_data;
490 PurpleSignalHandlerData *handler_data;
491 GList *l, *l_next;
492 va_list tmp;
494 g_return_val_if_fail(instance != NULL, NULL);
495 g_return_val_if_fail(signal != NULL, NULL);
497 instance_data =
498 (PurpleInstanceData *)g_hash_table_lookup(instance_table, instance);
500 g_return_val_if_fail(instance_data != NULL, NULL);
502 signal_data =
503 (PurpleSignalData *)g_hash_table_lookup(instance_data->signals, signal);
505 if (signal_data == NULL)
507 purple_debug(PURPLE_DEBUG_ERROR, "signals",
508 "Signal data for %s not found!\n", signal);
509 return 0;
512 for (l = signal_data->handlers; l != NULL; l = l_next)
514 void *ret_val = NULL;
516 l_next = l->next;
518 handler_data = (PurpleSignalHandlerData *)l->data;
520 G_VA_COPY(tmp, args);
521 if (handler_data->use_vargs)
523 ret_val = ((void *(*)(va_list, void *))handler_data->cb)(
524 tmp, handler_data->data);
526 else
528 signal_data->marshal(handler_data->cb, tmp,
529 handler_data->data, &ret_val);
531 va_end(tmp);
533 if (ret_val != NULL)
534 return ret_val;
537 return NULL;
540 void
541 purple_signals_init()
543 g_return_if_fail(instance_table == NULL);
545 instance_table =
546 g_hash_table_new_full(g_direct_hash, g_direct_equal,
547 NULL, (GDestroyNotify)destroy_instance_data);
550 void
551 purple_signals_uninit()
553 g_return_if_fail(instance_table != NULL);
555 g_hash_table_destroy(instance_table);
556 instance_table = NULL;
559 /**************************************************************************
560 * Marshallers
561 **************************************************************************/
562 void
563 purple_marshal_VOID(PurpleCallback cb, va_list args, void *data,
564 void **return_val)
566 ((void (*)(void *))cb)(data);
569 void
570 purple_marshal_VOID__INT(PurpleCallback cb, va_list args, void *data,
571 void **return_val)
573 gint arg1 = va_arg(args, gint);
575 ((void (*)(gint, void *))cb)(arg1, data);
578 void
579 purple_marshal_VOID__INT_INT(PurpleCallback cb, va_list args, void *data,
580 void **return_val)
582 gint arg1 = va_arg(args, gint);
583 gint arg2 = va_arg(args, gint);
585 ((void (*)(gint, gint, void *))cb)(arg1, arg2, data);
588 void
589 purple_marshal_VOID__POINTER(PurpleCallback cb, va_list args, void *data,
590 void **return_val)
592 void *arg1 = va_arg(args, void *);
594 ((void (*)(void *, void *))cb)(arg1, data);
597 void
598 purple_marshal_VOID__POINTER_UINT(PurpleCallback cb, va_list args,
599 void *data, void **return_val)
601 void *arg1 = va_arg(args, void *);
602 guint arg2 = va_arg(args, guint);
604 ((void (*)(void *, guint, void *))cb)(arg1, arg2, data);
607 void purple_marshal_VOID__POINTER_INT_INT(PurpleCallback cb, va_list args,
608 void *data, void **return_val)
610 void *arg1 = va_arg(args, void *);
611 gint arg2 = va_arg(args, gint);
612 gint arg3 = va_arg(args, gint);
614 ((void (*)(void *, gint, gint, void *))cb)(arg1, arg2, arg3, data);
617 void purple_marshal_VOID__POINTER_INT_POINTER(PurpleCallback cb, va_list args,
618 void *data, void **return_val)
620 void *arg1 = va_arg(args, void *);
621 gint arg2 = va_arg(args, gint);
622 void *arg3 = va_arg(args, void *);
624 ((void (*)(void *, gint, void *, void *))cb)(arg1, arg2, arg3, data);
627 void
628 purple_marshal_VOID__POINTER_POINTER(PurpleCallback cb, va_list args,
629 void *data, void **return_val)
631 void *arg1 = va_arg(args, void *);
632 void *arg2 = va_arg(args, void *);
634 ((void (*)(void *, void *, void *))cb)(arg1, arg2, data);
637 void
638 purple_marshal_VOID__POINTER_POINTER_UINT(PurpleCallback cb, va_list args,
639 void *data, void **return_val)
641 void *arg1 = va_arg(args, void *);
642 void *arg2 = va_arg(args, void *);
643 guint arg3 = va_arg(args, guint);
645 ((void (*)(void *, void *, guint, void *))cb)(arg1, arg2, arg3, data);
648 void
649 purple_marshal_VOID__POINTER_POINTER_UINT_UINT(PurpleCallback cb, va_list args,
650 void *data, void **return_val)
652 void *arg1 = va_arg(args, void *);
653 void *arg2 = va_arg(args, void *);
654 guint arg3 = va_arg(args, guint);
655 guint arg4 = va_arg(args, guint);
657 ((void (*)(void *, void *, guint, guint, void *))cb)(arg1, arg2, arg3, arg4, data);
660 void
661 purple_marshal_VOID__POINTER_UINT_UINT(PurpleCallback cb, va_list args,
662 void *data, void **return_val)
664 void *arg1 = va_arg(args, void *);
665 guint arg2 = va_arg(args, guint);
666 guint arg3 = va_arg(args, guint);
668 ((void (*)(void *, guint, guint, void *))cb)(arg1, arg2, arg3, data);
671 void
672 purple_marshal_VOID__POINTER_POINTER_POINTER(PurpleCallback cb, va_list args,
673 void *data, void **return_val)
675 void *arg1 = va_arg(args, void *);
676 void *arg2 = va_arg(args, void *);
677 void *arg3 = va_arg(args, void *);
679 ((void (*)(void *, void *, void *, void *))cb)(arg1, arg2, arg3, data);
682 void
683 purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER(PurpleCallback cb,
684 va_list args,
685 void *data,
686 void **return_val)
688 void *arg1 = va_arg(args, void *);
689 void *arg2 = va_arg(args, void *);
690 void *arg3 = va_arg(args, void *);
691 void *arg4 = va_arg(args, void *);
693 ((void (*)(void *, void *, void *, void *, void *))cb)(arg1, arg2, arg3, arg4, data);
696 void
697 purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_POINTER(PurpleCallback cb,
698 va_list args,
699 void *data,
700 void **return_val)
702 void *arg1 = va_arg(args, void *);
703 void *arg2 = va_arg(args, void *);
704 void *arg3 = va_arg(args, void *);
705 void *arg4 = va_arg(args, void *);
706 void *arg5 = va_arg(args, void *);
708 ((void (*)(void *, void *, void *, void *, void *, void *))cb)(arg1, arg2, arg3, arg4, arg5, data);
711 void
712 purple_marshal_VOID__POINTER_POINTER_POINTER_UINT(PurpleCallback cb,
713 va_list args,
714 void *data,
715 void **return_val)
717 void *arg1 = va_arg(args, void *);
718 void *arg2 = va_arg(args, void *);
719 void *arg3 = va_arg(args, void *);
720 guint arg4 = va_arg(args, guint);
722 ((void (*)(void *, void *, void *, guint, void *))cb)(arg1, arg2, arg3, arg4, data);
725 void
726 purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT(PurpleCallback cb,
727 va_list args,
728 void *data,
729 void **return_val)
731 void *arg1 = va_arg(args, void *);
732 void *arg2 = va_arg(args, void *);
733 void *arg3 = va_arg(args, void *);
734 void *arg4 = va_arg(args, void *);
735 guint arg5 = va_arg(args, guint);
737 ((void (*)(void *, void *, void *, void *, guint, void *))cb)(arg1, arg2, arg3, arg4, arg5, data);
740 void
741 purple_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT(PurpleCallback cb,
742 va_list args,
743 void *data,
744 void **return_val)
746 void *arg1 = va_arg(args, void *);
747 void *arg2 = va_arg(args, void *);
748 void *arg3 = va_arg(args, void *);
749 guint arg4 = va_arg(args, guint);
750 guint arg5 = va_arg(args, guint);
752 ((void (*)(void *, void *, void *, guint, guint, void *))cb)(
753 arg1, arg2, arg3, arg4, arg5, data);
756 void
757 purple_marshal_INT__INT(PurpleCallback cb, va_list args, void *data,
758 void **return_val)
760 gint ret_val;
761 gint arg1 = va_arg(args, gint);
763 ret_val = ((gint (*)(gint, void *))cb)(arg1, data);
765 if (return_val != NULL)
766 *return_val = GINT_TO_POINTER(ret_val);
769 void
770 purple_marshal_INT__INT_INT(PurpleCallback cb, va_list args, void *data,
771 void **return_val)
773 gint ret_val;
774 gint arg1 = va_arg(args, gint);
775 gint arg2 = va_arg(args, gint);
777 ret_val = ((gint (*)(gint, gint, void *))cb)(arg1, arg2, data);
779 if (return_val != NULL)
780 *return_val = GINT_TO_POINTER(ret_val);
783 void
784 purple_marshal_INT__POINTER_POINTER(PurpleCallback cb, va_list args, void *data,
785 void **return_val)
787 gint ret_val;
788 void *arg1 = va_arg(args, void *);
789 void *arg2 = va_arg(args, void *);
791 ret_val = ((gint (*)(void *, void *, void *))cb)(arg1, arg2, data);
793 if (return_val != NULL)
794 *return_val = GINT_TO_POINTER(ret_val);
797 void
798 purple_marshal_INT__POINTER_POINTER_POINTER(
799 PurpleCallback cb, va_list args, void *data, void **return_val)
801 gint ret_val;
802 void *arg1 = va_arg(args, void *);
803 void *arg2 = va_arg(args, void *);
804 void *arg3 = va_arg(args, void *);
806 ret_val = ((gint (*)(void *, void *, void *, void *))cb)(arg1, arg2, arg3, data);
808 if (return_val != NULL)
809 *return_val = GINT_TO_POINTER(ret_val);
812 void
813 purple_marshal_INT__POINTER_POINTER_POINTER_POINTER_POINTER(
814 PurpleCallback cb, va_list args, void *data, void **return_val)
816 gint ret_val;
817 void *arg1 = va_arg(args, void *);
818 void *arg2 = va_arg(args, void *);
819 void *arg3 = va_arg(args, void *);
820 void *arg4 = va_arg(args, void *);
821 void *arg5 = va_arg(args, void *);
823 ret_val =
824 ((gint (*)(void *, void *, void *, void *, void *, void *))cb)(
825 arg1, arg2, arg3, arg4, arg5, data);
827 if (return_val != NULL)
828 *return_val = GINT_TO_POINTER(ret_val);
831 void
832 purple_marshal_BOOLEAN__POINTER(PurpleCallback cb, va_list args, void *data,
833 void **return_val)
835 gboolean ret_val;
836 void *arg1 = va_arg(args, void *);
838 ret_val = ((gboolean (*)(void *, void *))cb)(arg1, data);
840 if (return_val != NULL)
841 *return_val = GINT_TO_POINTER(ret_val);
844 void
845 purple_marshal_BOOLEAN__POINTER_POINTER(PurpleCallback cb, va_list args,
846 void *data, void **return_val)
848 gboolean ret_val;
849 void *arg1 = va_arg(args, void *);
850 void *arg2 = va_arg(args, void *);
852 ret_val = ((gboolean (*)(void *, void *, void *))cb)(arg1, arg2, data);
854 if (return_val != NULL)
855 *return_val = GINT_TO_POINTER(ret_val);
858 void
859 purple_marshal_BOOLEAN__POINTER_BOOLEAN(PurpleCallback cb, va_list args,
860 void *data, void **return_val)
862 gboolean ret_val;
863 void *arg1 = va_arg(args, void *);
864 gboolean arg2 = va_arg(args, gboolean);
866 ret_val = ((gboolean (*)(void *, gboolean, void *))cb)(arg1, arg2, data);
868 if (return_val != NULL)
869 *return_val = GINT_TO_POINTER(ret_val);
872 void
873 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER(PurpleCallback cb, va_list args,
874 void *data, void **return_val)
876 gboolean ret_val;
877 void *arg1 = va_arg(args, void *);
878 void *arg2 = va_arg(args, void *);
879 void *arg3 = va_arg(args, void *);
881 ret_val = ((gboolean (*)(void *, void *, void *, void *))cb)(arg1, arg2,
882 arg3, data);
884 if (return_val != NULL)
885 *return_val = GINT_TO_POINTER(ret_val);
888 void
889 purple_marshal_BOOLEAN__POINTER_POINTER_UINT(PurpleCallback cb,
890 va_list args,
891 void *data,
892 void **return_val)
894 gboolean ret_val;
895 void *arg1 = va_arg(args, void *);
896 void *arg2 = va_arg(args, void *);
897 guint arg3 = va_arg(args, guint);
899 ret_val = ((gboolean (*)(void *, void *, guint, void *))cb)(
900 arg1, arg2, arg3, data);
902 if (return_val != NULL)
903 *return_val = GINT_TO_POINTER(ret_val);
906 void
907 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT(PurpleCallback cb,
908 va_list args,
909 void *data,
910 void **return_val)
912 gboolean ret_val;
913 void *arg1 = va_arg(args, void *);
914 void *arg2 = va_arg(args, void *);
915 void *arg3 = va_arg(args, void *);
916 guint arg4 = va_arg(args, guint);
918 ret_val = ((gboolean (*)(void *, void *, void *, guint, void *))cb)(
919 arg1, arg2, arg3, arg4, data);
921 if (return_val != NULL)
922 *return_val = GINT_TO_POINTER(ret_val);
925 void
926 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER(PurpleCallback cb,
927 va_list args,
928 void *data,
929 void **return_val)
931 gboolean ret_val;
932 void *arg1 = va_arg(args, void *);
933 void *arg2 = va_arg(args, void *);
934 void *arg3 = va_arg(args, void *);
935 void *arg4 = va_arg(args, void *);
937 ret_val = ((gboolean (*)(void *, void *, void *, void *, void *))cb)(
938 arg1, arg2, arg3, arg4, data);
940 if (return_val != NULL)
941 *return_val = GINT_TO_POINTER(ret_val);
944 void
945 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER(
946 PurpleCallback cb, va_list args, void *data, void **return_val)
948 gboolean ret_val;
949 void *arg1 = va_arg(args, void *);
950 void *arg2 = va_arg(args, void *);
951 void *arg3 = va_arg(args, void *);
952 void *arg4 = va_arg(args, void *);
953 void *arg5 = va_arg(args, void *);
955 ret_val =
956 ((gboolean (*)(void *, void *, void *, void *, void *, void *))cb)(
957 arg1, arg2, arg3, arg4, arg5, data);
959 if (return_val != NULL)
960 *return_val = GINT_TO_POINTER(ret_val);
963 void
964 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_UINT(
965 PurpleCallback cb, va_list args, void *data, void **return_val)
967 gboolean ret_val;
968 void *arg1 = va_arg(args, void *);
969 void *arg2 = va_arg(args, void *);
970 void *arg3 = va_arg(args, void *);
971 void *arg4 = va_arg(args, void *);
972 guint arg5 = va_arg(args, guint);
974 ret_val =
975 ((gboolean (*)(void *, void *, void *, void *, guint, void *))cb)(
976 arg1, arg2, arg3, arg4, arg5, data);
978 if (return_val != NULL)
979 *return_val = GINT_TO_POINTER(ret_val);
982 void
983 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER_POINTER(
984 PurpleCallback cb, va_list args, void *data, void **return_val)
986 gboolean ret_val;
987 void *arg1 = va_arg(args, void *);
988 void *arg2 = va_arg(args, void *);
989 void *arg3 = va_arg(args, void *);
990 void *arg4 = va_arg(args, void *);
991 void *arg5 = va_arg(args, void *);
992 void *arg6 = va_arg(args, void *);
994 ret_val =
995 ((gboolean (*)(void *, void *, void *, void *, void *, void *, void *))cb)(
996 arg1, arg2, arg3, arg4, arg5, arg6, data);
998 if (return_val != NULL)
999 *return_val = GINT_TO_POINTER(ret_val);
1002 void
1003 purple_marshal_BOOLEAN__INT_POINTER(PurpleCallback cb, va_list args, void *data,
1004 void **return_val)
1006 gboolean ret_val;
1007 gint arg1 = va_arg(args, gint);
1008 void *arg2 = va_arg(args, void *);
1010 ret_val = ((gboolean (*)(gint, void *, void *))cb)(arg1, arg2, data);
1012 if (return_val != NULL)
1013 *return_val = GINT_TO_POINTER(ret_val);
1016 void
1017 purple_marshal_POINTER__POINTER(
1018 PurpleCallback cb, va_list args, void *data,
1019 void **return_val)
1021 gpointer ret_val;
1022 void *arg1 = va_arg(args, void *);
1024 ret_val = ((gpointer(*)(void *, void *))cb)(arg1, data);
1026 if (return_val != NULL)
1027 *return_val = ret_val;
1031 void
1032 purple_marshal_POINTER__POINTER_INT(
1033 PurpleCallback cb, va_list args, void *data,
1034 void **return_val)
1036 gpointer ret_val;
1037 void *arg1 = va_arg(args, void *);
1038 gint arg2 = va_arg(args, gint);
1040 ret_val = ((gpointer(*)(void *, gint, void *))cb)(arg1, arg2, data);
1042 if (return_val != NULL)
1043 *return_val = ret_val;
1046 void
1047 purple_marshal_POINTER__POINTER_INT64(
1048 PurpleCallback cb, va_list args, void *data,
1049 void **return_val)
1051 gpointer ret_val;
1052 void *arg1 = va_arg(args, void *);
1053 gint64 arg2 = va_arg(args, gint64);
1055 ret_val = ((gpointer(*)(void *, gint64, void *))cb)(arg1, arg2, data);
1057 if (return_val != NULL)
1058 *return_val = ret_val;
1061 void
1062 purple_marshal_POINTER__POINTER_INT_BOOLEAN(
1063 PurpleCallback cb, va_list args, void *data,
1064 void **return_val)
1066 gpointer ret_val;
1067 void *arg1 = va_arg(args, void *);
1068 gint arg2 = va_arg(args, gint);
1069 gboolean arg3 = va_arg(args, gboolean);
1071 ret_val = ((gpointer(*)(void *, gint, gboolean, void *))cb)(arg1, arg2, arg3, data);
1073 if (return_val != NULL)
1074 *return_val = ret_val;
1077 void
1078 purple_marshal_POINTER__POINTER_INT64_BOOLEAN(
1079 PurpleCallback cb, va_list args, void *data,
1080 void **return_val)
1082 gpointer ret_val;
1083 void *arg1 = va_arg(args, void *);
1084 gint64 arg2 = va_arg(args, gint64);
1085 gboolean arg3 = va_arg(args, gboolean);
1087 ret_val = ((gpointer(*)(void *, gint64, gboolean, void *))cb)(arg1, arg2, arg3, data);
1089 if (return_val != NULL)
1090 *return_val = ret_val;
1093 void
1094 purple_marshal_POINTER__POINTER_POINTER_BOOLEAN(
1095 PurpleCallback cb, va_list args, void *data,
1096 void **return_val)
1098 gpointer ret_val;
1099 void *arg1 = va_arg(args, void *);
1100 void *arg2 = va_arg(args, void *);
1101 gboolean arg3 = va_arg(args, gboolean);
1103 ret_val = ((gpointer(*)(void *, void *, gboolean, void *))cb)(arg1, arg2, arg3, data);
1105 if (return_val != NULL)
1106 *return_val = ret_val;
1109 void
1110 purple_marshal_POINTER__POINTER_POINTER(PurpleCallback cb, va_list args, void *data,
1111 void **return_val)
1113 gpointer ret_val;
1114 void *arg1 = va_arg(args, void *);
1115 void *arg2 = va_arg(args, void *);
1117 ret_val = ((gpointer (*)(void *, void *, void *))cb)(arg1, arg2, data);
1119 if (return_val != NULL)
1120 *return_val = ret_val;