aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-apiset.c
diff options
context:
space:
mode:
authorJose Bollo <jose.bollo@iot.bzh>2019-11-04 17:57:23 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2019-11-29 12:48:17 +0100
commitb55f3cd48507105e85894be89557787eccfbe22f (patch)
tree337b771a460688087c622e3b27c43c0b5a77a233 /src/afb-apiset.c
parenteaf5670e9d10b5d7c066043e7563706cf1e01bd5 (diff)
afb-stub-ws: Enforce asynchronous describe
Because remote apis describe themselves asynchronousely, it is better to have asynchronous describe api. Bug-AGL: SPEC-2968 Change-Id: I52b4dab697f229ad01ea2b73d6b8dee22d507912 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-apiset.c')
-rw-r--r--src/afb-apiset.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/afb-apiset.c b/src/afb-apiset.c
index 0a8b3390..9fddd46c 100644
--- a/src/afb-apiset.c
+++ b/src/afb-apiset.c
@@ -28,6 +28,7 @@
#include "afb-apiset.h"
#include "afb-context.h"
#include "afb-xreq.h"
+#include "jobs.h"
#define INCR 8 /* CAUTION: must be a power of 2 */
@@ -941,20 +942,25 @@ int afb_apiset_get_logmask(struct afb_apiset *set, const char *name)
return i->api.itf->get_logmask(i->api.closure);
}
-/**
- * Get the description of the API of 'name'
- * @param set the api set
- * @param name the api whose description is required
- * @return the description or NULL
- */
-struct json_object *afb_apiset_describe(struct afb_apiset *set, const char *name)
+void afb_apiset_describe(struct afb_apiset *set, const char *name, void (*describecb)(void *, struct json_object *), void *closure)
{
const struct api_desc *i;
-
- i = name ? searchrec(set, name) : NULL;
- return i && i->api.itf->describe ? i->api.itf->describe(i->api.closure) : NULL;
+ struct json_object *r;
+
+ r = NULL;
+ if (name) {
+ i = searchrec(set, name);
+ if (i) {
+ if (i->api.itf->describe) {
+ i->api.itf->describe(i->api.closure, describecb, closure);
+ return;
+ }
+ }
+ }
+ describecb(closure, r);
}
+
struct get_names {
union {
struct {