diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-09-07 10:10:38 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-09-07 10:10:38 +0200 |
commit | bba4befcc57ff4eb106a01b416119da01accfcd1 (patch) | |
tree | a398a743e1542dc34208bf1a38b5fd81b1528e0e /src | |
parent | a826da17cdfa4586f66b9d3350e10d6799609a88 (diff) |
Use controller new behavior that add objectsflounder_5.99.6flounder/5.99.65.99.6
Adding objects to events section using the controller function
to create a mock-api.
Change-Id: Ic538c02f08b2f4f3376ffa6e9b9ffcbef1592599
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r-- | src/mapis.c | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/src/mapis.c b/src/mapis.c index ba72857..e40f3aa 100644 --- a/src/mapis.c +++ b/src/mapis.c @@ -29,8 +29,7 @@ struct mapisHandleT { }; static int LoadOneMapi(void *data, AFB_ApiT apiHandle) { - int savedCount = 0, count = 0, idx = 0; - CtlActionT *savedActions = NULL, *newActions = NULL; + int idx = 0; struct mapisHandleT *mapisHandle = (struct mapisHandleT*)data; CtlConfigT *ctrlConfig = AFB_ApiGetUserData(mapisHandle->mainApiHandle); @@ -48,40 +47,14 @@ static int LoadOneMapi(void *data, AFB_ApiT apiHandle) { if(mapisHandle->eventsJ) { // Add actions to the section to be able to respond to defined events. for(idx = 0; ctrlConfig->sections[idx].key != NULL; ++idx) { - if(! strcasecmp(ctrlConfig->sections[idx].key, "events")) { - savedActions = ctrlConfig->sections[idx].actions; + if(! strcasecmp(ctrlConfig->sections[idx].key, "events")) break; - } } - newActions = ActionConfig(apiHandle, mapisHandle->eventsJ, 0); - if(savedActions) { - while(savedActions[savedCount].uid != NULL) - savedCount++; + if( AddActionsToSection(apiHandle, &ctrlConfig->sections[idx], mapisHandle->eventsJ, 0) ) { + AFB_ApiError(apiHandle, "Wasn't able to add new events to %s", ctrlConfig->sections[idx].uid); + return -1; } - - while(newActions[count].uid != NULL) - count++; - - int total = savedCount + count; - count = 0; - savedCount = 0; - CtlActionT * mergedActions = calloc(total + 1, sizeof(CtlActionT)); - - if(savedActions) { - while(savedActions[count].uid != NULL) { - mergedActions[count] = savedActions[count]; - count++; - } - } - - while(newActions[savedCount].uid != NULL && count <= total) { - mergedActions[count] = newActions[savedCount]; - count++; - savedCount++; - } - - ctrlConfig->sections[idx].actions = mergedActions; } // declare an event event manager for this API; |