]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: introduce fopenf helper function
authorMasatake YAMATO <yamato@redhat.com>
Sun, 9 May 2021 17:29:31 +0000 (02:29 +0900)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Oct 2021 09:01:53 +0000 (11:01 +0200)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd.c
misc-utils/lsfd.h

index 5a8b222bd63f7689e077fd0ba813c23e9ec5675d..3b2a668341b6780284575a11d408cfc9a2b23364 100644 (file)
@@ -874,3 +874,17 @@ DIR *opendirf(const char *format, ...)
 
        return opendir(path);
 }
+
+FILE *fopenf(const char *mode, const char *format, ...)
+{
+       va_list ap;
+       char path[PATH_MAX];
+
+       memset(path, 0, sizeof(path));
+
+       va_start(ap, format);
+       vsprintf(path, format, ap);
+       va_end(ap);
+
+       return fopen(path, mode);
+}
index 88a5fbf5ce477d6bc57e4d98d77262812ced9d28..99037c5d0fea1c3b220b0e66367326421ce84941 100644 (file)
@@ -46,6 +46,7 @@
        } while (0)
 
 DIR *opendirf(const char *format, ...) __attribute__((format (printf, 1, 2)));
+FILE *fopenf(const char *mode, const char *format, ...) __attribute__((format (printf, 2, 3)));
 
 /*
  * column IDs