]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/c: add print_version_with_features()
authorKarel Zak <kzak@redhat.com>
Mon, 13 Jun 2022 10:01:51 +0000 (12:01 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Jun 2022 10:01:51 +0000 (12:01 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/c.h

index db0c58b5099e1f7cd5e296a63b5264c75dfb0c04..bb6c436cd1d7477d5f464c2582bf78c43e1412ce 100644 (file)
@@ -438,6 +438,27 @@ static inline int xusleep(useconds_t usec)
                exit(eval); \
 })
 
+static inline void print_features(const char **features)
+{
+       if (features && *features) {
+               const char **p = features;
+               while (p && *p) {
+                       fputs(p == features ? " (" : ", ", stdout);
+                       fputs(*p++, stdout);
+               }
+               fputc(')', stdout);
+       }
+}
+
+#define UTIL_LINUX_VERSION_NOBREAK _("%s from %s"), program_invocation_short_name, PACKAGE_STRING
+
+#define print_version_with_features(eval, features) __extension__ ({ \
+               printf(UTIL_LINUX_VERSION_NOBREAK); \
+               print_features(features); \
+               fputc('\n', stdout); \
+               exit(eval); \
+})
+
 /*
  * seek stuff
  */