+struct afb_hook_xreq_itf {
+ void (*hook_xreq_begin)(void * closure, const struct afb_xreq *xreq);
+ void (*hook_xreq_end)(void * closure, const struct afb_xreq *xreq);
+ void (*hook_xreq_json)(void * closure, const struct afb_xreq *xreq, struct json_object *obj);
+ void (*hook_xreq_get)(void * closure, const struct afb_xreq *xreq, const char *name, struct afb_arg arg);
+ void (*hook_xreq_success)(void * closure, const struct afb_xreq *xreq, struct json_object *obj, const char *info);
+ void (*hook_xreq_fail)(void * closure, const struct afb_xreq *xreq, const char *status, const char *info);
+ void (*hook_xreq_raw)(void * closure, const struct afb_xreq *xreq, const char *buffer, size_t size);
+ void (*hook_xreq_send)(void * closure, const struct afb_xreq *xreq, const char *buffer, size_t size);
+ void (*hook_xreq_context_get)(void * closure, const struct afb_xreq *xreq, void *value);
+ void (*hook_xreq_context_set)(void * closure, const struct afb_xreq *xreq, void *value, void (*free_value)(void*));
+ void (*hook_xreq_addref)(void * closure, const struct afb_xreq *xreq);
+ void (*hook_xreq_unref)(void * closure, const struct afb_xreq *xreq);
+ void (*hook_xreq_session_close)(void * closure, const struct afb_xreq *xreq);
+ void (*hook_xreq_session_set_LOA)(void * closure, const struct afb_xreq *xreq, unsigned level, int result);
+ void (*hook_xreq_subscribe)(void * closure, const struct afb_xreq *xreq, struct afb_event event, int result);
+ void (*hook_xreq_unsubscribe)(void * closure, const struct afb_xreq *xreq, struct afb_event event, int result);
+ void (*hook_xreq_subcall)(void * closure, const struct afb_xreq *xreq, const char *api, const char *verb, struct json_object *args);
+ void (*hook_xreq_subcall_result)(void * closure, const struct afb_xreq *xreq, int status, struct json_object *result);
+ void (*hook_xreq_subcallsync)(void * closure, const struct afb_xreq *xreq, const char *api, const char *verb, struct json_object *args);
+ void (*hook_xreq_subcallsync_result)(void * closure, const struct afb_xreq *xreq, int status, struct json_object *result);
+};
+
+extern void afb_hook_init_xreq(struct afb_xreq *xreq);
+
+extern struct afb_hook_xreq *afb_hook_create_xreq(const char *api, const char *verb, struct afb_session *session, int flags, struct afb_hook_xreq_itf *itf, void *closure);
+extern struct afb_hook_xreq *afb_hook_addref_xreq(struct afb_hook_xreq *spec);
+extern void afb_hook_unref_xreq(struct afb_hook_xreq *spec);
+
+/* hooks for xreq */
+extern void afb_hook_xreq_begin(const struct afb_xreq *xreq);
+extern void afb_hook_xreq_end(const struct afb_xreq *xreq);
+extern struct json_object *afb_hook_xreq_json(const struct afb_xreq *xreq, struct json_object *obj);
+extern struct afb_arg afb_hook_xreq_get(const struct afb_xreq *xreq, const char *name, struct afb_arg arg);
+extern void afb_hook_xreq_success(const struct afb_xreq *xreq, struct json_object *obj, const char *info);
+extern void afb_hook_xreq_fail(const struct afb_xreq *xreq, const char *status, const char *info);
+extern const char *afb_hook_xreq_raw(const struct afb_xreq *xreq, const char *buffer, size_t size);
+extern void afb_hook_xreq_send(const struct afb_xreq *xreq, const char *buffer, size_t size);
+extern void *afb_hook_xreq_context_get(const struct afb_xreq *xreq, void *value);
+extern void afb_hook_xreq_context_set(const struct afb_xreq *xreq, void *value, void (*free_value)(void*));
+extern void afb_hook_xreq_addref(const struct afb_xreq *xreq);
+extern void afb_hook_xreq_unref(const struct afb_xreq *xreq);
+extern void afb_hook_xreq_session_close(const struct afb_xreq *xreq);
+extern int afb_hook_xreq_session_set_LOA(const struct afb_xreq *xreq, unsigned level, int result);
+extern int afb_hook_xreq_subscribe(const struct afb_xreq *xreq, struct afb_event event, int result);
+extern int afb_hook_xreq_unsubscribe(const struct afb_xreq *xreq, struct afb_event event, int result);
+extern void afb_hook_xreq_subcall(const struct afb_xreq *xreq, const char *api, const char *verb, struct json_object *args);
+extern void afb_hook_xreq_subcall_result(const struct afb_xreq *xreq, int status, struct json_object *result);
+extern void afb_hook_xreq_subcallsync(const struct afb_xreq *xreq, const char *api, const char *verb, struct json_object *args);
+extern int afb_hook_xreq_subcallsync_result(const struct afb_xreq *xreq, int status, struct json_object *result);
+
+/*********************************************************
+* section hooking ditf
+*********************************************************/
+
+#define afb_hook_flag_ditf_vverbose 0x000001
+#define afb_hook_flag_ditf_event_make 0x000002
+#define afb_hook_flag_ditf_event_broadcast_before 0x000004
+#define afb_hook_flag_ditf_event_broadcast_after 0x000008
+#define afb_hook_flag_ditf_get_event_loop 0x000010
+#define afb_hook_flag_ditf_get_user_bus 0x000020
+#define afb_hook_flag_ditf_get_system_bus 0x000040
+#define afb_hook_flag_ditf_rootdir_get_fd 0x000080
+#define afb_hook_flag_ditf_rootdir_open_locale 0x000100
+#define afb_hook_flag_ditf_queue_job 0x000200
+
+#define afb_hook_flags_ditf_common (afb_hook_flag_ditf_vverbose\
+ |afb_hook_flag_ditf_event_make\
+ |afb_hook_flag_ditf_event_broadcast_before\
+ |afb_hook_flag_ditf_event_broadcast_after)
+#define afb_hook_flags_ditf_extra (afb_hook_flag_ditf_get_event_loop\
+ |afb_hook_flag_ditf_get_user_bus\
+ |afb_hook_flag_ditf_get_system_bus\
+ |afb_hook_flag_ditf_rootdir_get_fd\
+ |afb_hook_flag_ditf_rootdir_open_locale\
+ |afb_hook_flag_ditf_queue_job)
+
+#define afb_hook_flags_ditf_all (afb_hook_flags_ditf_common|afb_hook_flags_ditf_extra)