mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
27 lines
695 B
C
27 lines
695 B
C
#include "webfuse_provider/impl/message.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <libwebsockets.h>
|
|
|
|
extern struct wfp_message * wfp_message_create(json_t const * value)
|
|
{
|
|
size_t const length = json_dumpb(value, NULL, 0, JSON_COMPACT);
|
|
|
|
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;
|
|
message->raw_data = NULL;
|
|
|
|
json_dumpb(value, message->data, length, JSON_COMPACT);
|
|
|
|
return message;
|
|
}
|
|
|
|
void wfp_message_dispose(
|
|
struct wfp_message * message)
|
|
{
|
|
free(message->raw_data);
|
|
free(message);
|
|
}
|