}
struct callback *
+callback_new_attr_args(void (*func)(void), enum attr_type type, int count, ...)
+{
+ int i;
+ void *p[count];
+ va_list ap;
+ va_start(ap, count);
+ for (i = 0 ; i < count ; i++)
+ p[i]=va_arg(ap, void *);
+ va_end(ap);
+ return callback_new_attr(func, type, count, p);
+}
+
+struct callback *
callback_new(void (*func)(void), int pcount, void **p)
{
return callback_new_attr(func, attr_none, pcount, p);
}
+struct callback *
+callback_new_args(void (*func)(void), int count, ...)
+{
+ int i;
+ void *p[count];
+ va_list ap;
+ va_start(ap, count);
+ for (i = 0 ; i < count ; i++)
+ p[i]=va_arg(ap, void *);
+ va_end(ap);
+ return callback_new(func, count, p);
+}
+
void
callback_destroy(struct callback *cb)
{
if (cb->pcount && cb->p)
dbg(1,"cb->p[0]=%p\n", cb->p[0]);
dbg(1,"pcount=%d\n", pcount);
- if (pcount && p)
+ if (pcount) {
+ dbg_assert(p!=NULL);
dbg(1,"p[0]=%p\n", p[0]);
+ }
for (i = 0 ; i < cb->pcount ; i++)
pf[i]=cb->p[i];
for (i = 0 ; i < pcount ; i++)
break;
}
} else {
- g_warning("too many parameters for callback (%d+%d)\n", cb->pcount, pcount);
+ dbg(0,"too many parameters for callback (%d+%d)\n", cb->pcount, pcount);
}
}
void
+callback_call_args(struct callback *cb, int count, ...)
+{
+ int i;
+ void *p[count];
+ va_list ap;
+ va_start(ap, count);
+ for (i = 0 ; i < count ; i++)
+ p[i]=va_arg(ap, void *);
+ va_end(ap);
+ callback_call(cb, count, p);
+}
+
+void
callback_list_call_attr(struct callback_list *l, enum attr_type type, int pcount, void **p)
{
GList *cbi;
struct callback *cb;
+ if (!l) {
+ return;
+ }
+
cbi=l->list;
while (cbi) {
cb=cbi->data;
}
void
+callback_list_call_attr_args(struct callback_list *cbl, enum attr_type type, int count, ...)
+{
+ int i;
+ void *p[count];
+ va_list ap;
+ va_start(ap, count);
+ for (i = 0 ; i < count ; i++)
+ p[i]=va_arg(ap, void *);
+ va_end(ap);
+ callback_list_call_attr(cbl, type, count, p);
+}
+
+void
callback_list_call(struct callback_list *l, int pcount, void **p)
{
callback_list_call_attr(l, attr_any, pcount, p);
}
+void
+callback_list_call_args(struct callback_list *cbl, int count, ...)
+{
+ int i;
+ void *p[count];
+ va_list ap;
+ va_start(ap, count);
+ for (i = 0 ; i < count ; i++)
+ p[i]=va_arg(ap, void *);
+ va_end(ap);
+ callback_list_call(cbl, count, p);
+}
void
callback_list_destroy(struct callback_list *l)