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>
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
extern struct wfp_message * wfp_message_create(json_t const * value)
|
2019-03-26 22:04:53 +00:00
|
|
|
{
|
|
|
|
size_t const length = json_dumpb(value, NULL, 0, JSON_COMPACT);
|
|
|
|
|
2020-06-25 20:08:48 +00:00
|
|
|
char * data = malloc(sizeof(struct wfp_message) + LWS_PRE + length);
|
|
|
|
struct wfp_message * message = (struct wfp_message *) data;
|
|
|
|
message->data = &data[sizeof(struct wfp_message) + LWS_PRE];
|
|
|
|
message->length = length;
|
2019-03-26 22:04:53 +00:00
|
|
|
|
2020-06-25 20:08:48 +00:00
|
|
|
json_dumpb(value, message->data, length, JSON_COMPACT);
|
2019-03-26 22:04:53 +00:00
|
|
|
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
void wfp_message_dispose(
|
|
|
|
struct wfp_message * message)
|
2019-03-26 22:04:53 +00:00
|
|
|
{
|
|
|
|
free(message);
|
|
|
|
}
|