+int afb_hook_api_require_api_result(const struct afb_export *export, const char *name, int initialized, int result)
+{
+ _HOOK_API_2_(require_api, require_api_result, export, name, initialized, result);
+ return result;
+}
+
+int afb_hook_api_add_alias(const struct afb_export *export, const char *api, const char *alias, int result)
+{
+ _HOOK_API_(add_alias, export, api, alias, result);
+ return result;
+}
+
+void afb_hook_api_start_before(const struct afb_export *export)
+{
+ _HOOK_API_2_(start, start_before, export);
+}
+
+int afb_hook_api_start_after(const struct afb_export *export, int status)
+{
+ _HOOK_API_2_(start, start_after, export, status);
+ return status;
+}
+
+void afb_hook_api_on_event_before(const struct afb_export *export, const char *event, int event_x2, struct json_object *object)
+{
+ _HOOK_API_2_(on_event, on_event_before, export, event, event_x2, object);
+}
+
+void afb_hook_api_on_event_after(const struct afb_export *export, const char *event, int event_x2, struct json_object *object)
+{
+ _HOOK_API_2_(on_event, on_event_after, export, event, event_x2, object);
+}
+
+void afb_hook_api_call(const struct afb_export *export, const char *api, const char *verb, struct json_object *args)
+{
+ _HOOK_API_(call, export, api, verb, args);
+}
+
+void afb_hook_api_call_result(const struct afb_export *export, struct json_object *object, const char*error, const char *info)
+{
+ _HOOK_API_2_(call, call_result, export, object, error, info);
+
+}
+
+void afb_hook_api_callsync(const struct afb_export *export, const char *api, const char *verb, struct json_object *args)
+{
+ _HOOK_API_(callsync, export, api, verb, args);
+}
+
+int afb_hook_api_callsync_result(const struct afb_export *export, int status, struct json_object *object, const char *error, const char *info)
+{
+ _HOOK_API_2_(callsync, callsync_result, export, status, object, error, info);
+ return status;
+}
+
+void afb_hook_api_new_api_before(const struct afb_export *export, const char *api, const char *info, int noconcurrency)
+{
+ _HOOK_API_2_(new_api, new_api_before, export, api, info, noconcurrency);
+}
+
+int afb_hook_api_new_api_after(const struct afb_export *export, int result, const char *api)
+{
+ _HOOK_API_2_(new_api, new_api_after, export, result, api);
+ return result;
+}
+
+int afb_hook_api_api_set_verbs_v2(const struct afb_export *export, int result, const struct afb_verb_v2 *verbs)
+{
+ _HOOK_API_2_(api_set_verbs, api_set_verbs_v2, export, result, verbs);
+ return result;
+}
+
+int afb_hook_api_api_set_verbs_v3(const struct afb_export *export, int result, const struct afb_verb_v3 *verbs)
+{
+ _HOOK_API_2_(api_set_verbs, api_set_verbs_v3, export, result, verbs);
+ return result;
+}
+
+int afb_hook_api_api_add_verb(const struct afb_export *export, int result, const char *verb, const char *info, int glob)
+{
+ _HOOK_API_(api_add_verb, export, result, verb, info, glob);
+ return result;
+}
+
+int afb_hook_api_api_del_verb(const struct afb_export *export, int result, const char *verb)
+{
+ _HOOK_API_(api_del_verb, export, result, verb);
+ return result;
+}
+
+int afb_hook_api_api_set_on_event(const struct afb_export *export, int result)
+{
+ _HOOK_API_(api_set_on_event, export, result);
+ return result;
+}
+
+int afb_hook_api_api_set_on_init(const struct afb_export *export, int result)
+{
+ _HOOK_API_(api_set_on_init, export, result);
+ return result;
+}
+
+void afb_hook_api_api_seal(const struct afb_export *export)
+{
+ _HOOK_API_(api_seal, export);
+}
+
+int afb_hook_api_event_handler_add(const struct afb_export *export, int result, const char *pattern)
+{
+ _HOOK_API_(event_handler_add, export, result, pattern);
+ return result;
+}
+int afb_hook_api_event_handler_del(const struct afb_export *export, int result, const char *pattern)
+{
+ _HOOK_API_(event_handler_del, export, result, pattern);
+ return result;
+}
+int afb_hook_api_class_provide(const struct afb_export *export, int result, const char *name)
+{
+ _HOOK_API_(class_provide, export, result, name);
+ return result;
+}
+int afb_hook_api_class_require(const struct afb_export *export, int result, const char *name)
+{
+ _HOOK_API_(class_require, export, result, name);
+ return result;
+}
+
+int afb_hook_api_delete_api(const struct afb_export *export, int result)
+{
+ _HOOK_API_(delete_api, export, result);
+ return result;
+}
+
+void afb_hook_api_on_event_handler_before(const struct afb_export *export, const char *event, int event_x2, struct json_object *object, const char *pattern)
+{
+ _HOOK_API_2_(on_event_handler, on_event_handler_before, export, event, event_x2, object, pattern);
+}
+
+void afb_hook_api_on_event_handler_after(const struct afb_export *export, const char *event, int event_x2, struct json_object *object, const char *pattern)
+{
+ _HOOK_API_2_(on_event_handler, on_event_handler_after, export, event, event_x2, object, pattern);
+}
+
+struct json_object *afb_hook_api_settings(const struct afb_export *export, struct json_object *object)
+{
+ _HOOK_API_(settings, export, object);
+ return object;
+}
+
+/******************************************************************************
+ * section: hooking export
+ *****************************************************************************/
+
+int afb_hook_flags_api(const char *api)
+{
+ int flags;
+ struct afb_hook_api *hook;
+
+ flags = 0;
+ pthread_rwlock_rdlock(&rwlock);
+ hook = list_of_api_hooks;
+ while (hook) {
+ if (!api || MATCH_API(hook->api, api))
+ flags |= hook->flags;
+ hook = hook->next;
+ }
+ pthread_rwlock_unlock(&rwlock);
+ return flags;
+}
+
+struct afb_hook_api *afb_hook_create_api(const char *api, int flags, struct afb_hook_api_itf *itf, void *closure)
+{
+ struct afb_hook_api *hook;
+
+ /* alloc the result */
+ hook = calloc(1, sizeof *hook);
+ if (hook == NULL)
+ return NULL;