From: Michael Tremer Date: Mon, 20 Oct 2025 13:23:29 +0000 (+0000) Subject: file: Add function to run the parser on a single line X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c066d8c99eed1848bba38185f42147289bc3a37d;p=telemetry.git file: Add function to run the parser on a single line This is useful if we want to use the parser when we cannot walk through the file line by line. Signed-off-by: Michael Tremer --- diff --git a/src/daemon/file.c b/src/daemon/file.c index fb935c9..5880daf 100644 --- a/src/daemon/file.c +++ b/src/daemon/file.c @@ -281,6 +281,10 @@ int td_file_parse(td_file* self, td_file_parser* parser) { return td_file_walk(self, __td_file_parse, parser); } +int td_file_parse_line(td_file* self, td_file_parser* parser, char* line, size_t length) { + return __td_file_parse(self->ctx, self, 0, line, length, parser); +} + int td_read_uint64(td_ctx* ctx, const char* path, uint64_t* number) { td_file* file = NULL; int r; diff --git a/src/daemon/file.h b/src/daemon/file.h index 44a593c..8660353 100644 --- a/src/daemon/file.h +++ b/src/daemon/file.h @@ -68,6 +68,7 @@ typedef struct td_file_parser { { .s = _s, .n = 4, .v1 = _v1, .v2 = _v2, .v3 = _v3, .v4 = _v4 } int td_file_parse(td_file* self, td_file_parser* parser); +int td_file_parse_line(td_file* self, td_file_parser* parser, char* line, size_t length); // Shorthands