1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-16 00:00:02 +01:00
VILLASnode/lib/compat.c

30 lines
No EOL
667 B
C

/** Compatability for different library versions.
*
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
*********************************************************************************/
#include <string.h>
#include <jansson.h>
#include "compat.h"
#if JANSSON_VERSION_HEX < 0x020A00
size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags)
{
char *str;
size_t len;
str = json_dumps(json, flags);
if (!str)
return 0;
len = strlen(str); // not \0 terminated
if (buffer && len <= size)
memcpy(buffer, str, len);
free(str);
return len;
}
#endif