const char *api; /* api name for the binding */
const char *specification; /* textual specification of the binding */
const struct afb_verb_v2 *verbs; /* array of descriptions of verbs terminated by a NULL name */
- int (*init)(struct afb_daemon daemon);
- int (*start)(struct afb_service service);
+ int (*preinit)(struct afb_daemon daemon);
+ int (*init)(struct afb_service service);
void (*onevent)(struct afb_service service, const char *event, struct json_object *object);
unsigned concurrent: 1; /* allows concurrent requests to verbs */
};
}
/* get the initialisation */
- start = desc->binding->start;
+ start = desc->binding->init;
if (start == NULL) {
/* not an error when onneed */
if (onneed != 0)
afb_ditf_init_v2(&desc->ditf, binding->api);
/* init the binding */
- if (binding->init) {
- INFO("binding %s calling init function", binding->api);
- rc = binding->init(desc->ditf.daemon);
+ if (binding->preinit) {
+ INFO("binding %s calling preinit function", binding->api);
+ rc = binding->preinit(desc->ditf.daemon);
if (rc < 0) {
- ERROR("binding %s initialisation function failed...", binding->api);
+ ERROR("binding %s preinit function failed...", binding->api);
goto error2;
}
}
struct json_object *root = NULL;
struct json_object *d_perms = NULL;
struct json_object *a_perms = NULL;
+const char *preinit = NULL;
const char *init = NULL;
-const char *start = NULL;
const char *onevent = NULL;
const char *api = NULL;
const char *scope = NULL;
const char *prefix = NULL;
const char *postfix = NULL;
int priv = -1;
+int conc = -1;
/**
* Search for a reference of type "#/a/b/c" int the
/* get some names */
getvar(&api, "#/info/x-binding-c-generator/api", NULL);
+ getvar(&preinit, "#/info/x-binding-c-generator/preinit", NULL);
getvar(&init, "#/info/x-binding-c-generator/init", NULL);
- getvar(&start, "#/info/x-binding-c-generator/start", NULL);
getvar(&onevent, "#/info/x-binding-c-generator/onevent", NULL);
getvar(&scope, "#/info/x-binding-c-generator/scope", "static");
getvar(&prefix, "#/info/x-binding-c-generator/prefix", "afb_verb_");
getvar(&postfix, "#/info/x-binding-c-generator/postfix", "_cb");
getvarbool(&priv, "#/info/x-binding-c-generator/private", 0);
+ getvarbool(&conc, "#/info/x-binding-c-generator/concurrent", 0);
getvar(&api, "#/info/title", "?");
/* get the API name */
" .api = \"%s\",\n"
" .specification = _afb_description_v2_%s,\n"
" .verbs = _afb_verbs_v2_%s,\n"
+ " .preinit = %s,\n"
" .init = %s,\n"
- " .start = %s,\n"
" .onevent = %s,\n"
+ " .concurrent = %d\n"
"};\n"
"\n"
, priv ? "static " : ""
, api
, api
, api
+ , preinit ?: "NULL"
, init ?: "NULL"
- , start ?: "NULL"
, onevent ?: "NULL"
+ , !!conc
);
/* clean up */