#include <ctype.h>
#include <json-c/json.h>
+#if !defined(JSON_C_TO_STRING_NOSLASHESCAPE)
+#define JSON_C_TO_STRING_NOSLASHESCAPE 0
+#endif
#define AFB_BINDING_VERSION 0
#include <afb/afb-binding.h>
/* check daemon state */
if (export->state == Api_State_Pre_Init) {
- ERROR("[API %s] Bad call to 'afb_daemon_event_broadcast(%s, %s)', must not be in PreInit", export->api.apiname, name, json_object_to_json_string(object));
+ ERROR("[API %s] Bad call to 'afb_daemon_event_broadcast(%s, %s)', must not be in PreInit",
+ export->api.apiname, name, json_object_to_json_string_ext(object, JSON_C_TO_STRING_NOSLASHESCAPE));
errno = EINVAL;
return 0;
}
}
/* create the event */
- handler = malloc(strlen(pattern) + strlen(pattern));
+ handler = malloc(strlen(pattern) + sizeof * handler);
if (!handler) {
ERROR("[API %s] can't allocate event handler %s", export->api.apiname, pattern);
errno = ENOMEM;
handler->callback = callback;
handler->closure = closure;
strcpy(handler->pattern, pattern);
- export->event_handlers = handler;
+ *previous = handler;
return 0;
}
void afb_export_context_init(struct afb_export *export, struct afb_context *context)
{
afb_context_init(context, export->session, NULL);
+ context->validated = 1;
}