From fd3a7cc487ad5dc36d99ccf46f9e3c6461687f99 Mon Sep 17 00:00:00 2001 From: pml68 Date: Tue, 16 Sep 2025 21:48:56 +0200 Subject: chore: sync slstatus with upstream --- slstatus/util.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'slstatus/util.c') diff --git a/slstatus/util.c b/slstatus/util.c index bca9b2e..d33cf9d 100644 --- a/slstatus/util.c +++ b/slstatus/util.c @@ -139,3 +139,20 @@ pscanf(const char *path, const char *fmt, ...) return (n == EOF) ? -1 : n; } + +int +lscanf(FILE *fp, const char *key, const char *fmt, void *res) +{ + int n; + char line[256]; + + n = -1; + while (fgets(line, sizeof(line), fp)) + if (strncmp(line, key, strlen(key)) == 0) { + n = sscanf(line + strlen(key), fmt, res); + break; + } + + rewind(fp); + return (n == 1) ? 1 : -1; +} -- cgit v1.2.3