diff options
author | Li, Xiaoming <lixm.fnst@cn.fujitsu.com> | 2020-06-22 11:07:30 +0800 |
---|---|---|
committer | Li Xiaoming <lixm.fnst@cn.fujitsu.com> | 2020-07-21 12:31:15 +0000 |
commit | abb024ffcbf800a51dc7a7c513611141d82b2a3b (patch) | |
tree | d527d9ffb743460058ef3f275cd063efcb65a9d8 /binding/binding-api.c | |
parent | 0c6f41e5965d0013cd871659c52c9abb1057550c (diff) |
Fix test folder structureneedlefish_13.93.0needlefish/13.93.0marlin_12.93.0marlin_12.92.0marlin_12.91.0marlin_12.90.1marlin_12.90.0marlin/12.93.0marlin/12.92.0marlin/12.91.0marlin/12.90.1marlin/12.90.0lamprey_11.92.0lamprey_11.91.0lamprey/11.92.0lamprey/11.91.0koi_10.93.0koi_10.92.0koi_10.91.0koi/10.93.0koi/10.92.0koi/10.91.0jellyfish_9.99.4jellyfish_9.99.3jellyfish_9.99.2jellyfish/9.99.4jellyfish/9.99.3jellyfish/9.99.29.99.49.99.39.99.213.93.012.93.012.92.012.91.012.90.112.90.011.92.011.91.010.93.010.92.010.91.0
The test folder should rest in the root of a package.
Bug-AGL: SPEC-2807
Change-Id: I6e44e68f40aaf58d2c59973e6a2413947dcb4eaf
Signed-off-by: Li, Xiaoming <lixm.fnst@cn.fujitsu.com>
Diffstat (limited to 'binding/binding-api.c')
-rw-r--r-- | binding/binding-api.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/binding/binding-api.c b/binding/binding-api.c new file mode 100644 index 0000000..5221cda --- /dev/null +++ b/binding/binding-api.c @@ -0,0 +1,65 @@ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include "binding-api.h" + +#include <stdlib.h> +#include <stdio.h> + +const afb_verb_t verbs[] = { + { .verb = POIAPI_BINDING_VERB_SEND_REQUEST, .callback = send_request }, + { .verb = POIAPI_BINDING_VERB_REQUEST_PROCESSED, .callback = request_processed }, + { .verb = POIAPI_BINDING_VERB_SUBSCRIBE_REQUESTS, .callback = subscribe_requests }, + { .verb = POIAPI_BINDING_VERB_UNSUBSCRIBE_REQUESTS, .callback = unsubscribe_requests }, + { .verb = POIAPI_BINDING_VERB_SUBSCRIBE_RESPONSES, .callback = subscribe_responses }, + { .verb = POIAPI_BINDING_VERB_UNSUBSCRIBE_RESPONSES, .callback = unsubscribe_responses }, + { .verb = NULL } +}; + +afb_event_t gEventRequestReceived; +afb_event_t gEventResponseReceived; + +int init(afb_api_t api) +{ + gEventRequestReceived = afb_api_make_event(api, POIAPI_BINDING_EVENT_REQUEST_RECEIVED); + gEventResponseReceived = afb_api_make_event(api, POIAPI_BINDING_EVENT_RESPONSE_RECEIVED); + if (afb_event_is_valid(gEventRequestReceived) && afb_event_is_valid(gEventResponseReceived)) { + + json_object *args = json_object_new_object(); + // TODO Set Version + json_object *appid = json_object_new_string("poi-service@0.1"); + json_object_object_add(args, "id", appid); + + char *err; + char *info; + json_object *response; + + // Launch poiservice + afb_api_call_sync(api, "afm-main", "start", args, &response, &err, &info); + + if (err) { + AFB_API_ERROR(api, "ERROR %s", err); + free(err); + } + if (info) { + AFB_API_INFO(api, "INFO %s", info); + free(info); + } + + json_object_put(response); + + return 0; + } + else { + AFB_API_ERROR(api, "Can't create events"); + return -1; + } +} + +const afb_binding_t afbBindingExport = { + .api = POIAPI_BINDING_API_NAME, + .verbs = verbs, + .init = init, + .noconcurrency = 0 +}; |