+/*************************************************************************************************************
+ *************************************************************************************************************
+ *************************************************************************************************************
+ *************************************************************************************************************
+ F R O M D Y N A P I
+ *************************************************************************************************************
+ *************************************************************************************************************
+ *************************************************************************************************************
+ *************************************************************************************************************/
+
+static int api_set_verbs_v2_cb(
+ struct afb_dynapi *dynapi,
+ const struct afb_verb_v2 *verbs)
+{
+ struct afb_export *export = from_dynapi(dynapi);
+
+ if (export->apidyn) {
+ afb_api_dyn_set_verbs_v2(export->apidyn, verbs);
+ return 0;
+ }
+
+ errno = EPERM;
+ return -1;
+}
+
+static int api_add_verb_cb(
+ struct afb_dynapi *dynapi,
+ const char *verb,
+ const char *info,
+ void (*callback)(struct afb_request *request),
+ void *vcbdata,
+ const struct afb_auth *auth,
+ uint32_t session)
+{
+ struct afb_export *export = from_dynapi(dynapi);
+
+ if (export->apidyn)
+ return afb_api_dyn_add_verb(export->apidyn, verb, info, callback, vcbdata, auth, session);
+
+ errno = EPERM;
+ return -1;
+}
+
+static int api_sub_verb_cb(
+ struct afb_dynapi *dynapi,
+ const char *verb)
+{
+ struct afb_export *export = from_dynapi(dynapi);
+
+ if (export->apidyn)
+ return afb_api_dyn_sub_verb(export->apidyn, verb);
+
+ errno = EPERM;
+ return -1;
+}
+
+static int api_set_on_event_cb(
+ struct afb_dynapi *dynapi,
+ void (*onevent)(struct afb_dynapi *dynapi, const char *event, struct json_object *object))
+{
+ struct afb_export *export = from_dynapi(dynapi);
+ return afb_export_handle_events_vdyn(export, onevent);
+}
+
+static int api_set_on_init_cb(
+ struct afb_dynapi *dynapi,
+ int (*oninit)(struct afb_dynapi *dynapi))
+{
+ struct afb_export *export = from_dynapi(dynapi);
+
+ return afb_export_handle_init_vdyn(export, oninit);
+}
+
+static void api_seal_cb(
+ struct afb_dynapi *dynapi)
+{
+ struct afb_export *export = from_dynapi(dynapi);
+
+ export->apidyn = NULL;
+}
+
+static int hooked_api_set_verbs_v2_cb(
+ struct afb_dynapi *dynapi,
+ const struct afb_verb_v2 *verbs)
+{
+ /* TODO */
+ return api_set_verbs_v2_cb(dynapi, verbs);
+}
+
+static int hooked_api_add_verb_cb(
+ struct afb_dynapi *dynapi,
+ const char *verb,
+ const char *info,
+ void (*callback)(struct afb_request *request),
+ void *vcbdata,
+ const struct afb_auth *auth,
+ uint32_t session)
+{
+ /* TODO */
+ return api_add_verb_cb(dynapi, verb, info, callback, vcbdata, auth, session);
+}
+
+static int hooked_api_sub_verb_cb(
+ struct afb_dynapi *dynapi,
+ const char *verb)
+{
+ /* TODO */
+ return api_sub_verb_cb(dynapi, verb);
+}
+
+static int hooked_api_set_on_event_cb(
+ struct afb_dynapi *dynapi,
+ void (*onevent)(struct afb_dynapi *dynapi, const char *event, struct json_object *object))
+{
+ /* TODO */
+ return api_set_on_event_cb(dynapi, onevent);
+}
+
+static int hooked_api_set_on_init_cb(
+ struct afb_dynapi *dynapi,
+ int (*oninit)(struct afb_dynapi *dynapi))
+{
+ /* TODO */
+ return api_set_on_init_cb(dynapi, oninit);
+}
+
+static void hooked_api_seal_cb(
+ struct afb_dynapi *dynapi)
+{
+ /* TODO */
+ api_seal_cb(dynapi);
+}
+
+static const struct afb_dynapi_itf dynapi_itf = {
+
+ .vverbose = (void*)vverbose_cb,
+
+ .get_event_loop = afb_common_get_event_loop,
+ .get_user_bus = afb_common_get_user_bus,
+ .get_system_bus = afb_common_get_system_bus,
+ .rootdir_get_fd = afb_common_rootdir_get_fd,
+ .rootdir_open_locale = rootdir_open_locale_cb,
+ .queue_job = queue_job_cb,
+
+ .require_api = require_api_cb,
+ .rename_api = rename_api_cb,
+
+ .event_broadcast = event_broadcast_cb,
+ .eventid_make = eventid_make_cb,
+
+ .call = svc_call_dynapi,
+ .call_sync = svc_call_sync,
+
+ .api_new_api = api_new_api_cb,
+ .api_set_verbs_v2 = api_set_verbs_v2_cb,
+ .api_add_verb = api_add_verb_cb,
+ .api_sub_verb = api_sub_verb_cb,
+ .api_set_on_event = api_set_on_event_cb,
+ .api_set_on_init = api_set_on_init_cb,
+ .api_seal = api_seal_cb,
+};
+
+static const struct afb_dynapi_itf hooked_dynapi_itf = {
+
+ .vverbose = hooked_vverbose_cb,
+
+ .get_event_loop = hooked_get_event_loop,
+ .get_user_bus = hooked_get_user_bus,
+ .get_system_bus = hooked_get_system_bus,
+ .rootdir_get_fd = hooked_rootdir_get_fd,
+ .rootdir_open_locale = hooked_rootdir_open_locale_cb,
+ .queue_job = hooked_queue_job_cb,
+
+ .require_api = hooked_require_api_cb,
+ .rename_api = hooked_rename_api_cb,
+
+ .event_broadcast = hooked_event_broadcast_cb,
+ .eventid_make = hooked_eventid_make_cb,
+
+ .call = svc_hooked_call_dynapi,
+ .call_sync = svc_hooked_call_sync,
+
+ .api_new_api = hooked_api_new_api_cb,
+ .api_set_verbs_v2 = hooked_api_set_verbs_v2_cb,
+ .api_add_verb = hooked_api_add_verb_cb,
+ .api_sub_verb = hooked_api_sub_verb_cb,
+ .api_set_on_event = hooked_api_set_on_event_cb,
+ .api_set_on_init = hooked_api_set_on_init_cb,
+ .api_seal = hooked_api_seal_cb,
+};
+