* fix conffiles
[navit-package] / navit / callback.c
index dbbd45e..fa2087b 100644 (file)
@@ -60,11 +60,37 @@ callback_new_attr(void (*func)(void), enum attr_type type, int pcount, void **p)
 }
 
 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)
 {
@@ -121,8 +147,10 @@ callback_call(struct callback *cb, int pcount, void **p)
                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++)
@@ -162,11 +190,28 @@ callback_call(struct callback *cb, int pcount, void **p)
 }
 
 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;
@@ -178,11 +223,36 @@ callback_list_call_attr(struct callback_list *l, enum attr_type type, int pcount
 }
 
 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)