aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-05-19 12:05:29 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-05-19 23:04:44 +0200
commit66451a0d658eabab18f37995659d81d429e0138e (patch)
treefecd83413ee9cf673cecc21c794e8dcd8272a69b
parentbd4f365ba69281941c14b2c02d58f4b37a22b42d (diff)
Bindings V2: rename init functions
The new naming is closer to the functionnal design and closer to V1 names. Change-Id: I8970338056a30564b84eaa1a7da6df3a9e6aa579 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--include/afb/afb-binding-v2.h4
-rw-r--r--src/afb-api-so-v2.c10
-rw-r--r--src/genskel/genskel.c12
-rw-r--r--src/genskel/monitor-api.json6
-rw-r--r--src/monitor-api.inc2
5 files changed, 19 insertions, 15 deletions
diff --git a/include/afb/afb-binding-v2.h b/include/afb/afb-binding-v2.h
index b949a2d7..91d64693 100644
--- a/include/afb/afb-binding-v2.h
+++ b/include/afb/afb-binding-v2.h
@@ -57,8 +57,8 @@ struct afb_binding_v2
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 */
};
diff --git a/src/afb-api-so-v2.c b/src/afb-api-so-v2.c
index e0769213..6aa10cf5 100644
--- a/src/afb-api-so-v2.c
+++ b/src/afb-api-so-v2.c
@@ -119,7 +119,7 @@ static int service_start_cb(void *closure, int share_session, int onneed, struct
}
/* get the initialisation */
- start = desc->binding->start;
+ start = desc->binding->init;
if (start == NULL) {
/* not an error when onneed */
if (onneed != 0)
@@ -211,11 +211,11 @@ int afb_api_so_v2_add_binding(const struct afb_binding_v2 *binding, void *handle
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;
}
}
diff --git a/src/genskel/genskel.c b/src/genskel/genskel.c
index 60f0e3b6..58f7a2c4 100644
--- a/src/genskel/genskel.c
+++ b/src/genskel/genskel.c
@@ -64,14 +64,15 @@ struct path
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
@@ -586,13 +587,14 @@ void process(char *filename)
/* 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 */
@@ -623,9 +625,10 @@ void process(char *filename)
" .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 " : ""
@@ -634,9 +637,10 @@ void process(char *filename)
, api
, api
, api
+ , preinit ?: "NULL"
, init ?: "NULL"
- , start ?: "NULL"
, onevent ?: "NULL"
+ , !!conc
);
/* clean up */
diff --git a/src/genskel/monitor-api.json b/src/genskel/monitor-api.json
index 34161cba..9b998432 100644
--- a/src/genskel/monitor-api.json
+++ b/src/genskel/monitor-api.json
@@ -9,11 +9,11 @@
"version": 2,
"prefix": "f_",
"postfix": "",
- "start": null,
- "onevent": null,
+ "preinit": null,
"init": null,
+ "onevent": null,
"scope": "static",
- "private": true
+ "private": true
}
},
"servers": [
diff --git a/src/monitor-api.inc b/src/monitor-api.inc
index 71c2a029..30d1ede6 100644
--- a/src/monitor-api.inc
+++ b/src/monitor-api.inc
@@ -65,8 +65,8 @@ static const struct afb_binding_v2 _afb_binding_v2_monitor = {
.api = "monitor",
.specification = _afb_description_v2_monitor,
.verbs = _afb_verbs_v2_monitor,
+ .preinit = NULL,
.init = NULL,
- .start = NULL,
.onevent = NULL,
};