Allow renaming of API
[src/app-framework-binder.git] / src / afb-hook.c
index 664ef12..a1ecea6 100644 (file)
@@ -177,24 +177,24 @@ static void _hook_(const char *fmt1, const char *fmt2, va_list arg2, ...)
 #else /* new behaviour: emits directly to stderr */
 static void _hook_(const char *fmt1, const char *fmt2, va_list arg2, ...)
 {
-       static const char chars[] = "[HOOK ] \n";
+       static const char chars[] = "HOOK: [] \n";
        char *mem1, *mem2, buf1[256], buf2[2000];
        struct iovec iov[5];
        va_list arg1;
 
        iov[0].iov_base = (void*)&chars[0];
-       iov[0].iov_len = 6;
+       iov[0].iov_len = 7;
 
        va_start(arg1, arg2);
        iov[1].iov_base = _pbuf_(fmt1, arg1, &mem1, buf1, sizeof buf1, &iov[1].iov_len);
        va_end(arg1);
 
-       iov[2].iov_base = (void*)&chars[6];
+       iov[2].iov_base = (void*)&chars[7];
        iov[2].iov_len = 2;
 
        iov[3].iov_base = _pbuf_(fmt2, arg2, &mem2, buf2, sizeof buf2, &iov[3].iov_len);
 
-       iov[4].iov_base = (void*)&chars[8];
+       iov[4].iov_base = (void*)&chars[9];
        iov[4].iov_len = 1;
 
        writev(2, iov, 5);
@@ -752,6 +752,11 @@ static void hook_ditf_require_api_result_cb(void *closure, const struct afb_hook
        _hook_ditf_(ditf, "...require_api(%s, %d) -> %d", name, initialized, result);
 }
 
+static void hook_ditf_rename_api_cb(void *closure, const struct afb_hookid *hookid, const struct afb_ditf *ditf, const char *oldname, const char *newname, int result)
+{
+       _hook_ditf_(ditf, "rename_api(%s -> %s) -> %d", oldname, newname, result);
+}
+
 static struct afb_hook_ditf_itf hook_ditf_default_itf = {
        .hook_ditf_event_broadcast_before = hook_ditf_event_broadcast_before_cb,
        .hook_ditf_event_broadcast_after = hook_ditf_event_broadcast_after_cb,
@@ -765,7 +770,8 @@ static struct afb_hook_ditf_itf hook_ditf_default_itf = {
        .hook_ditf_queue_job = hook_ditf_queue_job_cb,
        .hook_ditf_unstore_req = hook_ditf_unstore_req_cb,
        .hook_ditf_require_api = hook_ditf_require_api_cb,
-       .hook_ditf_require_api_result = hook_ditf_require_api_result_cb
+       .hook_ditf_require_api_result = hook_ditf_require_api_result_cb,
+       .hook_ditf_rename_api = hook_ditf_rename_api_cb
 };
 
 /******************************************************************************
@@ -862,6 +868,12 @@ int afb_hook_ditf_require_api_result(const struct afb_ditf *ditf, const char *na
        return result;
 }
 
+int afb_hook_ditf_rename_api(const struct afb_ditf *ditf, const char *oldname, const char *newname, int result)
+{
+       _HOOK_DITF_(rename_api, ditf, oldname, newname, result);
+       return result;
+}
+
 /******************************************************************************
  * section: hooking ditf
  *****************************************************************************/
@@ -1415,7 +1427,7 @@ static struct afb_hook_global_itf hook_global_default_itf = {
 
 static void afb_hook_global_vverbose(int level, const char *file, int line, const char *func, const char *fmt, va_list args)
 {
-       _HOOK_GLOBAL_(vverbose, level, file ?: "?", line, func ?: "?", fmt, args);
+       _HOOK_GLOBAL_(vverbose, level, file ?: "?", line, func ?: "?", fmt ?: "", args);
 }
 
 /******************************************************************************