From 63e839afc912a57fe3f45e206e6ba76e45e718a3 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 12 May 2018 18:11:39 +0200 Subject: [PATCH] io: align header / source files --- include/villas/formats/csv.h | 5 +++-- include/villas/formats/json-reserve.h | 12 +++++------- include/villas/formats/json.h | 10 ++++------ include/villas/formats/villas_human.h | 7 ++----- lib/formats/csv.c | 4 ++-- lib/formats/json.c | 8 ++++---- lib/formats/json_reserve.c | 4 ++-- lib/formats/villas_human.c | 4 ++-- 8 files changed, 24 insertions(+), 30 deletions(-) diff --git a/include/villas/formats/csv.h b/include/villas/formats/csv.h index c7f2a1027..8b828aea9 100644 --- a/include/villas/formats/csv.h +++ b/include/villas/formats/csv.h @@ -30,6 +30,7 @@ struct sample; #define CSV_SEPARATOR '\t' -int csv_fprint(FILE *f, struct sample *smps[], unsigned cnt, int flags); +void csv_header(struct io *io); -int csv_fscan(FILE *f, struct sample *smps[], unsigned cnt, int flags); +int csv_sscan(struct io *io, char *buf, size_t len, size_t *rbytes, struct sample *smps[], unsigned cnt); +int csv_sprint(struct io *io, char *buf, size_t len, size_t *rbytes, struct sample *smps[], unsigned cnt); diff --git a/include/villas/formats/json-reserve.h b/include/villas/formats/json-reserve.h index bf23115e9..71280af59 100644 --- a/include/villas/formats/json-reserve.h +++ b/include/villas/formats/json-reserve.h @@ -26,12 +26,10 @@ /* Forward declarations */ struct sample; +struct io; -typedef int (*json_pack_cb_t)(json_t **j, struct sample *smp, int flags); -typedef int (*json_unpack_cb_t)(json_t *j, struct sample *s, int flags); +int json_reserve_sprint(struct io *io, char *buf, size_t len, size_t *wbytes, struct sample *smps[], unsigned cnt); +int json_reserve_sscan(struct io *io, char *buf, size_t len, size_t *rbytes, struct sample *smps[], unsigned cnt); -int json_reserve_pack_sample(json_t **j, struct sample *s, int flags); -int json_reserve_unpack_sample(json_t *j, struct sample *s, int flags); - -int json_reserve_fprint(FILE *f, struct sample *smps[], unsigned cnt, int flags); -int json_reserve_fscan(FILE *f, struct sample *smps[], unsigned cnt, int flags); +int json_reserve_print(struct io *io, struct sample *smps[], unsigned cnt); +int json_reserve_scan(struct io *io, struct sample *smps[], unsigned cnt); diff --git a/include/villas/formats/json.h b/include/villas/formats/json.h index 5f8778417..50fb60aee 100644 --- a/include/villas/formats/json.h +++ b/include/villas/formats/json.h @@ -27,10 +27,8 @@ /* Forward declarations */ struct sample; -int json_pack_sample(struct io *io, json_t **j, struct sample *s); +int json_sprint(struct io *io, char *buf, size_t len, size_t *wbytes, struct sample *smps[], unsigned cnt); +int json_sscan(struct io *io, char *buf, size_t len, size_t *wbytes, struct sample *smps[], unsigned cnt); -int json_unpack_sample(struct io *io, json_t *j, struct sample *s); - -int json_fprint(struct io *io, FILE *f, struct sample *smps[], unsigned cnt); - -int json_fscan(struct io *io, FILE *f, struct sample *smps[], unsigned cnt); +int json_print(struct io *io, struct sample *smps[], unsigned cnt); +int json_scan(struct io *io, struct sample *smps[], unsigned cnt); diff --git a/include/villas/formats/villas_human.h b/include/villas/formats/villas_human.h index a189514bc..01ced6032 100644 --- a/include/villas/formats/villas_human.h +++ b/include/villas/formats/villas_human.h @@ -29,10 +29,7 @@ struct io; struct sample; +void villas_human_header(struct io *io); + int villas_human_print(struct io *io, struct sample *smps[], unsigned cnt); - int villas_human_scan(struct io *io, struct sample *smps[], unsigned cnt); - -int villas_human_fprint(FILE *f, struct sample *smps[], unsigned cnt, int flags); - -int villas_human_fscan(FILE *f, struct sample *smps[], unsigned cnt, int flags); diff --git a/lib/formats/csv.c b/lib/formats/csv.c index c8f6d83c7..64a4a5b91 100644 --- a/lib/formats/csv.c +++ b/lib/formats/csv.c @@ -31,7 +31,7 @@ #include #include -size_t csv_sprint_single(struct io *io, char *buf, size_t len, struct sample *s) +static size_t csv_sprint_single(struct io *io, char *buf, size_t len, struct sample *s) { size_t off = 0; @@ -66,7 +66,7 @@ size_t csv_sprint_single(struct io *io, char *buf, size_t len, struct sample *s) return off; } -size_t csv_sscan_single(struct io *io, const char *buf, size_t len, struct sample *s) +static size_t csv_sscan_single(struct io *io, const char *buf, size_t len, struct sample *s) { const char *ptr = buf; char *end; diff --git a/lib/formats/json.c b/lib/formats/json.c index 0328c6ec4..4ce2d6927 100644 --- a/lib/formats/json.c +++ b/lib/formats/json.c @@ -69,7 +69,7 @@ static int json_unpack_timestamps(json_t *json_ts, struct sample *smp) return 0; } -int json_pack_sample(struct io *io, json_t **j, struct sample *smp) +static int json_pack_sample(struct io *io, json_t **j, struct sample *smp) { json_t *json_smp; json_error_t err; @@ -101,7 +101,7 @@ int json_pack_sample(struct io *io, json_t **j, struct sample *smp) return 0; } -int json_pack_samples(struct io *io, json_t **j, struct sample *smps[], unsigned cnt) +static int json_pack_samples(struct io *io, json_t **j, struct sample *smps[], unsigned cnt) { int ret; json_t *json_smps = json_array(); @@ -121,7 +121,7 @@ int json_pack_samples(struct io *io, json_t **j, struct sample *smps[], unsigned return cnt; } -int json_unpack_sample(struct io *io, json_t *json_smp, struct sample *smp) +static int json_unpack_sample(struct io *io, json_t *json_smp, struct sample *smp) { int ret; json_error_t err; @@ -181,7 +181,7 @@ int json_unpack_sample(struct io *io, json_t *json_smp, struct sample *smp) return 0; } -int json_unpack_samples(struct io *io, json_t *json_smps, struct sample *smps[], unsigned cnt) +static int json_unpack_samples(struct io *io, json_t *json_smps, struct sample *smps[], unsigned cnt) { int ret; json_t *json_smp; diff --git a/lib/formats/json_reserve.c b/lib/formats/json_reserve.c index c4e4f2d75..1c18270b0 100644 --- a/lib/formats/json_reserve.c +++ b/lib/formats/json_reserve.c @@ -29,7 +29,7 @@ #include #include -int json_reserve_pack_sample(struct io *io, json_t **j, struct sample *smp) +static int json_reserve_pack_sample(struct io *io, json_t **j, struct sample *smp) { json_error_t err; json_t *json_data, *json_name, *json_unit, *json_value; @@ -95,7 +95,7 @@ int json_reserve_pack_sample(struct io *io, json_t **j, struct sample *smp) return 0; } -int json_reserve_unpack_sample(struct io *io, json_t *json_smp, struct sample *smp) +static int json_reserve_unpack_sample(struct io *io, json_t *json_smp, struct sample *smp) { int ret, idx; double created = -1; diff --git a/lib/formats/villas_human.c b/lib/formats/villas_human.c index aa4d22917..e4d79c602 100644 --- a/lib/formats/villas_human.c +++ b/lib/formats/villas_human.c @@ -32,7 +32,7 @@ #include #include -size_t villas_human_sprint_single(struct io *io, char *buf, size_t len, struct sample *s) +static size_t villas_human_sprint_single(struct io *io, char *buf, size_t len, struct sample *s) { size_t off = 0; @@ -65,7 +65,7 @@ size_t villas_human_sprint_single(struct io *io, char *buf, size_t len, struct s return off; } -size_t villas_human_sscan_single(struct io *io, const char *buf, size_t len, struct sample *s) +static size_t villas_human_sscan_single(struct io *io, const char *buf, size_t len, struct sample *s) { char *end; const char *ptr = buf;