X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-xreq.c;h=0b828277ac26f40e10f87ccc831f4e4ee494cdab;hb=791e07d6476f6758598a68749185a807da253316;hp=527692c674a0842655d1f76987f8ff47f675cb70;hpb=6f1126ae2c585afc34d0bb06f3763e3a82ee3d37;p=src%2Fapp-framework-binder.git diff --git a/src/afb-xreq.c b/src/afb-xreq.c index 527692c6..0b828277 100644 --- a/src/afb-xreq.c +++ b/src/afb-xreq.c @@ -19,6 +19,7 @@ #define AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO #include +#include #include #include @@ -39,6 +40,17 @@ /******************************************************************************/ +static void vinfo(void *first, void *second, const char *fmt, va_list args, void (*fun)(void*,void*,const char*)) +{ + char *info; + if (fmt == NULL || vasprintf(&info, fmt, args) < 0) + info = NULL; + fun(first, second, info); + free(info); +} + +/******************************************************************************/ + static struct json_object *xreq_json_cb(void *closure) { struct afb_xreq *xreq = closure; @@ -85,6 +97,16 @@ static void xreq_fail_cb(void *closure, const char *status, const char *info) } } +static void xreq_vsuccess_cb(void *closure, struct json_object *obj, const char *fmt, va_list args) +{ + vinfo(closure, obj, fmt, args, (void*)xreq_success_cb); +} + +static void xreq_vfail_cb(void *closure, const char *status, const char *fmt, va_list args) +{ + vinfo(closure, (void*)status, fmt, args, (void*)xreq_fail_cb); +} + static void *xreq_context_get_cb(void *closure) { struct afb_xreq *xreq = closure; @@ -265,6 +287,16 @@ static void xreq_hooked_fail_cb(void *closure, const char *status, const char *i xreq_fail_cb(closure, status, info); } +static void xreq_hooked_vsuccess_cb(void *closure, struct json_object *obj, const char *fmt, va_list args) +{ + vinfo(closure, obj, fmt, args, (void*)xreq_hooked_success_cb); +} + +static void xreq_hooked_vfail_cb(void *closure, const char *status, const char *fmt, va_list args) +{ + vinfo(closure, (void*)status, fmt, args, (void*)xreq_hooked_fail_cb); +} + static void *xreq_hooked_context_get_cb(void *closure) { void *r = xreq_context_get_cb(closure); @@ -372,6 +404,8 @@ const struct afb_req_itf xreq_itf = { .get = xreq_get_cb, .success = xreq_success_cb, .fail = xreq_fail_cb, + .vsuccess = xreq_vsuccess_cb, + .vfail = xreq_vfail_cb, .context_get = xreq_context_get_cb, .context_set = xreq_context_set_cb, .addref = xreq_addref_cb, @@ -389,6 +423,8 @@ const struct afb_req_itf xreq_hooked_itf = { .get = xreq_hooked_get_cb, .success = xreq_hooked_success_cb, .fail = xreq_hooked_fail_cb, + .vsuccess = xreq_hooked_vsuccess_cb, + .vfail = xreq_hooked_vfail_cb, .context_get = xreq_hooked_context_get_cb, .context_set = xreq_hooked_context_set_cb, .addref = xreq_hooked_addref_cb,