From 1a45153e46297451d7a79c4708d823ff64c8c514 Mon Sep 17 00:00:00 2001 From: Thomas Weißschuh Date: Mon, 13 May 2024 21:01:16 +0200 Subject: lib/path: introduce ul_path_vreadf_buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Weißschuh --- lib/path.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/path.c') diff --git a/lib/path.c b/lib/path.c index 6381cc5d8f..6a70ad45f7 100644 --- a/lib/path.c +++ b/lib/path.c @@ -701,16 +701,25 @@ int ul_path_read_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char return rc; } -int ul_path_readf_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...) +int ul_path_vreadf_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, va_list ap) { const char *p; + + p = ul_path_mkpath(pc, path, ap); + + return !p ? -errno : ul_path_read_buffer(pc, buf, bufsz, p); +} + +int ul_path_readf_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...) +{ va_list ap; + int rc; va_start(ap, path); - p = ul_path_mkpath(pc, path, ap); + rc = ul_path_vreadf_buffer(pc, buf, bufsz, path, ap); va_end(ap); - return !p ? -errno : ul_path_read_buffer(pc, buf, bufsz, p); + return rc; } int ul_path_scanf(struct path_cxt *pc, const char *path, const char *fmt, ...) -- cgit 1.2.3-korg