From: Masatake YAMATO Date: Sun, 9 May 2021 17:29:31 +0000 (+0900) Subject: lsfd: introduce fopenf helper function X-Git-Tag: v2.38-rc1~144^2~152 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18878c1ff930de464c9c2a737037b55626948d51;p=thirdparty%2Futil-linux.git lsfd: introduce fopenf helper function Signed-off-by: Masatake YAMATO --- diff --git a/misc-utils/lsfd.c b/misc-utils/lsfd.c index 5a8b222bd6..3b2a668341 100644 --- a/misc-utils/lsfd.c +++ b/misc-utils/lsfd.c @@ -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); +} diff --git a/misc-utils/lsfd.h b/misc-utils/lsfd.h index 88a5fbf5ce..99037c5d0f 100644 --- a/misc-utils/lsfd.h +++ b/misc-utils/lsfd.h @@ -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