diff options
| author | pml68 <contact@pml68.dev> | 2025-09-16 21:48:56 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-09-16 22:15:01 +0200 |
| commit | fd3a7cc487ad5dc36d99ccf46f9e3c6461687f99 (patch) | |
| tree | e1627f8ea07510d06a99ea55f275ae3b6e1919a7 /slstatus/util.c | |
| parent | chore: bump dwm and dmenu versions (diff) | |
| download | suckless-setup-fd3a7cc487ad5dc36d99ccf46f9e3c6461687f99.tar.gz | |
chore: sync slstatus with upstream
Diffstat (limited to 'slstatus/util.c')
| -rw-r--r-- | slstatus/util.c | 17 |
1 files changed, 17 insertions, 0 deletions
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; +} |
