2020-06-16 21:39:45 +00:00
|
|
|
#include "webfuse_provider/impl/message.h"
|
2019-03-26 22:04:53 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <libwebsockets.h>
|
|
|
|
|
|
|
|
extern struct wf_message * wf_message_create(json_t const * value)
|
|
|
|
{
|
|
|
|
struct wf_message * message = NULL;
|
|
|
|
size_t const length = json_dumpb(value, NULL, 0, JSON_COMPACT);
|
|
|
|
|
|
|
|
if (0 < length)
|
|
|
|
{
|
|
|
|
char * data = malloc(sizeof(struct wf_message) + LWS_PRE + length);
|
|
|
|
message = (struct wf_message *) data;
|
2020-03-21 20:22:22 +00:00
|
|
|
message->data = &data[sizeof(struct wf_message) + LWS_PRE];
|
|
|
|
message->length = length;
|
2019-03-26 22:04:53 +00:00
|
|
|
|
2020-03-21 20:22:22 +00:00
|
|
|
json_dumpb(value, message->data, length, JSON_COMPACT);
|
2019-03-26 22:04:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wf_message_dispose(
|
|
|
|
struct wf_message * message)
|
|
|
|
{
|
|
|
|
free(message);
|
|
|
|
}
|