1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

FIX tmp fix to compile with c++ but c syntax for structs

This commit is contained in:
Manuel Pitz 2019-04-08 14:00:46 +01:00 committed by Steffen Vogel
parent 9d7e44860e
commit 36be027f08
4 changed files with 22 additions and 14 deletions

View file

@ -71,5 +71,6 @@ list(APPEND FORMAT_SRC
)
add_library(formats STATIC ${FORMAT_SRC})
target_compile_options(formats PRIVATE -x c)
target_include_directories(formats PUBLIC ${INCLUDE_DIRS})
target_link_libraries(formats INTERFACE ${LIBRARIES} PUBLIC villas-common)

View file

@ -67,8 +67,8 @@ static int json_unpack_timestamps(json_t *json_ts, struct sample *smp)
{
int ret;
json_error_t err;
json_t *json_ts_origin = nullptr;
json_t *json_ts_received = nullptr;
json_t *json_ts_origin = NULL;
json_t *json_ts_received = NULL;
json_unpack_ex(json_ts, &err, 0, "{ s?: o, s?: o }",
"origin", &json_ts_origin,
@ -173,7 +173,7 @@ static int json_unpack_sample(struct io *io, json_t *json_smp, struct sample *sm
{
int ret;
json_error_t err;
json_t *json_data, *json_value, *json_ts = nullptr;
json_t *json_data, *json_value, *json_ts = NULL;
size_t i;
int64_t sequence = -1;

View file

@ -37,8 +37,8 @@ static int json_reserve_pack_sample(struct io *io, json_t **j, struct sample *sm
{
json_error_t err;
json_t *json_data, *json_name, *json_unit, *json_value;
json_t *json_created = nullptr;
json_t *json_sequence = nullptr;
json_t *json_created = NULL;
json_t *json_sequence = NULL;
if (smp->flags & SAMPLE_HAS_TS_ORIGIN)
json_created = json_integer(time_to_double(&smp->ts.origin) * 1e3);
@ -67,7 +67,7 @@ static int json_reserve_pack_sample(struct io *io, json_t **j, struct sample *sm
if (sig->unit)
json_unit = json_string(sig->unit);
else
json_unit = nullptr;
json_unit = NULL;
json_value = json_pack_ex(&err, 0, "{ s: o, s: f }",
"name", json_name,
@ -94,7 +94,7 @@ static int json_reserve_pack_sample(struct io *io, json_t **j, struct sample *sm
*j = json_pack_ex(&err, 0, "{ s: o }",
"measurements", json_data
);
if (*j == nullptr)
if (*j == NULL)
return -1;
#if 0
#ifdef JSON_RESERVE_INTEGER_TARGET
@ -124,8 +124,8 @@ static int json_reserve_unpack_sample(struct io *io, json_t *json_smp, struct sa
int ret, idx;
double created = -1;
json_error_t err;
json_t *json_value, *json_data = nullptr;
json_t *json_origin = nullptr, *json_target = nullptr;
json_t *json_value, *json_data = NULL;
json_t *json_origin = NULL, *json_target = NULL;
size_t i;
ret = json_unpack_ex(json_smp, &err, 0, "{ s?: o, s?: o, s?: o, s?: o }",
@ -173,7 +173,7 @@ static int json_reserve_unpack_sample(struct io *io, json_t *json_smp, struct sa
smp->length = 0;
json_array_foreach(json_data, i, json_value) {
const char *name, *unit = nullptr;
const char *name, *unit = NULL;
double value;
ret = json_unpack_ex(json_value, &err, 0, "{ s: s, s?: s, s: F, s?: F }",

View file

@ -29,6 +29,10 @@
#include <villas/plugin.h>
#include <villas/formats/protobuf.h>
#ifdef __cplusplus
extern "C" {
#endif
static enum signal_type protobuf_detect_format(Villas__Node__Value *val)
{
switch (val->value_case) {
@ -128,14 +132,14 @@ int protobuf_sprint(struct io *io, char *buf, size_t len, size_t *wbytes, struct
goto out;
villas__node__message__pack(pb_msg, (uint8_t *) buf);
villas__node__message__free_unpacked(pb_msg, nullptr);
villas__node__message__free_unpacked(pb_msg, NULL);
*wbytes = psz;
return cnt;
out:
villas__node__message__free_unpacked(pb_msg, nullptr);
villas__node__message__free_unpacked(pb_msg, NULL);
return -1;
}
@ -145,7 +149,7 @@ int protobuf_sscan(struct io *io, const char *buf, size_t len, size_t *rbytes, s
unsigned i, j;
Villas__Node__Message *pb_msg;
pb_msg = villas__node__message__unpack(nullptr, len, (uint8_t *) buf);
pb_msg = villas__node__message__unpack(NULL, len, (uint8_t *) buf);
if (!pb_msg)
return -1;
@ -216,7 +220,7 @@ int protobuf_sscan(struct io *io, const char *buf, size_t len, size_t *rbytes, s
if (rbytes)
*rbytes = villas__node__message__get_packed_size(pb_msg);
villas__node__message__free_unpacked(pb_msg, nullptr);
villas__node__message__free_unpacked(pb_msg, NULL);
return i;
}
@ -233,3 +237,6 @@ static struct plugin p = {
}
};
REGISTER_PLUGIN(&p);
#ifdef __cplusplus
}
#endif