]> git.ipfire.org Git - telemetry.git/commitdiff
file: Add function to run the parser on a single line
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 20 Oct 2025 13:23:29 +0000 (13:23 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 20 Oct 2025 13:23:29 +0000 (13:23 +0000)
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 <michael.tremer@ipfire.org>
src/daemon/file.c
src/daemon/file.h

index fb935c99d81aaf11dffc33738732f1eea581bf3b..5880dafb32b81ffbc601bf8956cf514cede74505 100644 (file)
@@ -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;
index 44a593c0599363bbe81d52651e14fa05362cd3b1..8660353b2fbc411fcc04b3f6f2769dfc59c8e671 100644 (file)
@@ -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