Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <stdarg.h>
+#include <libgen.h>
#define NORETURN __attribute__((noreturn))
exit(EXIT_FAILURE);
}
+
+void print_version(void)
+{
+ char *prog, *tmp;
+
+ tmp = strdup(progname);
+ if (!tmp)
+ prog = progname;
+ else
+ prog = basename(tmp);
+
+ printf("%s (libgpiod) %s\n", prog, gpiod_version_string());
+ printf("Copyright (C) 2017 Bartosz Golaszewski\n");
+ printf("License GPLv3+: GNU GPL version 3 or later\n");
+ printf("This is free software: you are free to change and redistribute it.\n");
+ printf("There is NO WARRANTY, to the extent permitted by law.\n");
+
+ if (tmp)
+ free(tmp);
+}
const char * get_progname(void);
void die(const char *fmt, ...);
void die_perror(const char *fmt, ...);
+void print_version(void);
#endif /* __GPIOD_TOOLS_COMMON_H__ */