From 1168c8ab426105bcd1b65aaf1f62c7a6144b0ae8 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 14 Jul 2024 10:25:56 +0200 Subject: file_lines module, herschrijf omd ermee --- src/io/lines.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/io/lines.h (limited to 'src/io/lines.h') diff --git a/src/io/lines.h b/src/io/lines.h new file mode 100644 index 0000000..b09b756 --- /dev/null +++ b/src/io/lines.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +#include "util/string_view.h" + + +struct file_lines { + const char *progname, *fname; + + FILE *f; + size_t cap; + char *buffer; + size_t cursor; + size_t readfrom; // if -1, no newline in buffer +}; + +// Returns false on EOF. FILE remains ownership of the caller. +bool file_lines_open(const char *progname, const char *fname, FILE *f, struct file_lines *dst); + +// Returns whether successful +bool file_lines_read(struct file_lines *fl, struct string_view *dst); + +void file_lines_close(struct file_lines *fl); -- cgit v1.2.3-70-g09d2