#include #include #include "c_wayland_client.h" log_hook_t ada_handler; char buf[256]; void actual_log_handler(const char *c, va_list va) { char *str = buf; char *extra = NULL; int len; if (c == NULL) { (*ada_handler)(c,0); return; } len = vsnprintf(str, 256, c, va); if (len >= 256) { extra = malloc((len + 1) * sizeof(char)); if (extra == NULL) { (*ada_handler)(extra,1); return; } str = extra; vsnprintf(str, len + 1, c, va); } (*ada_handler)(str,0); if (extra != NULL) { free(extra); } } void wayland_client_set_log_hook(log_hook_t func) { ada_handler = func; wl_log_set_handler_client(&actual_log_handler); }