summaryrefslogtreecommitdiffstats
path: root/src/mapis.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-07-03 19:07:17 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-07-10 17:12:14 +0200
commit47d9a2667ee860c3dc3199a4e0c4f23a03f47fbc (patch)
tree250c1e462e4fd239473826712d87657876e6da8c /src/mapis.c
parent1843e4ece852755cec7778db60629d2aea8536a0 (diff)
Continue Mapis works WIP
Beginning work to handle events from a Mapi. Also rename old fapis file to mapis and some format Change-Id: I30bedcbe13cac9568e21cd3a0947516e74dde271 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/mapis.c')
-rw-r--r--src/mapis.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mapis.c b/src/mapis.c
index d196ed0..b6976e3 100644
--- a/src/mapis.c
+++ b/src/mapis.c
@@ -24,9 +24,10 @@ struct mapisHandleT {
CtlSectionT *section;
json_object *mapiJ;
json_object *verbsJ;
+ json_object *eventsJ;
};
-static int LoadOnemapi(void *data, AFB_ApiT apiHandle)
+static int LoadOneMapi(void *data, AFB_ApiT apiHandle)
{
struct mapisHandleT *mapisHandle = (struct mapisHandleT*)data;
@@ -46,7 +47,7 @@ static int LoadOnemapi(void *data, AFB_ApiT apiHandle)
return 0;
}
-static void OnemapiConfig(void *data, json_object *mapiJ) {
+static void OneMapiConfig(void *data, json_object *mapiJ) {
const char *uid = NULL, *info = NULL;
struct mapisHandleT *mapisHandle = (struct mapisHandleT*)data;
@@ -58,30 +59,33 @@ static void OnemapiConfig(void *data, json_object *mapiJ) {
"spath", NULL,
"libs", NULL,
"lua", NULL,
- "verbs", &mapisHandle->verbsJ)) {
+ "verbs", &mapisHandle->verbsJ,
+ "eventsJ", &mapisHandle->eventsJ)) {
AFB_ApiError(mapisHandle->mainApiHandle, "Wrong mapis specification, missing uid|[info]|[spath]|libs|[lua]|verbs");
return;
}
json_object_get(mapisHandle->verbsJ);
+ json_object_get(mapisHandle->eventsJ);
json_object_object_del(mapiJ, "verbs");
+ json_object_object_del(mapiJ, "events");
mapisHandle->mapiJ = mapiJ;
- if (afb_dynapi_new_api(mapisHandle->mainApiHandle, uid, info, 1, LoadOnemapi, (void*)mapisHandle)) {
+ if (afb_dynapi_new_api(mapisHandle->mainApiHandle, uid, info, 1, LoadOneMapi, (void*)mapisHandle)) {
AFB_ApiError(mapisHandle->mainApiHandle, "Error creating new api: %s", uid);
return;
}
}
}
-int mapisConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *mapisJ) {
+int MapiConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *mapisJ) {
struct mapisHandleT mapisHandle = {
.mainApiHandle = apiHandle,
.section = section,
.mapiJ = NULL,
.verbsJ = NULL
};
- wrap_json_optarray_for_all(mapisJ, OnemapiConfig, (void*)&mapisHandle);
+ wrap_json_optarray_for_all(mapisJ, OneMapiConfig, (void*)&mapisHandle);
return 0;
}