diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-09-01 09:03:18 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-09-01 09:05:00 +1000 |
commit | bf31cd3348e0c222e7abed6fc4ac00d7ce50cf2a (patch) | |
tree | 6da2d9382c9364dfa906af886a14453c9e173813 | |
parent | 44794371e8978ec4b4aeb891f94c9fdd0dcf9dd0 (diff) |
Add --version flag
evtest versions are different enough now that it does matter what version a
user uses. Add a --version flag to ease triaging of bug reports.
"gcc -o evtest evtest.c" should continue to work, so add an extra ifdef for
the case PACKAGE_VERSION is undefined.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | evtest.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -39,6 +39,10 @@ #include <stdio.h> #include <stdint.h> +#if HAVE_CONFIG_H +#include <config.h> +#endif + #include <linux/version.h> #include <linux/input.h> @@ -74,6 +78,7 @@ enum evtest_mode { MODE_CAPTURE, MODE_QUERY, + MODE_VERSION, }; static const struct query_mode { @@ -654,6 +659,16 @@ static char* scan_devices(void) return filename; } +static int version(void) +{ +#ifndef PACKAGE_VERSION +#define PACKAGE_VERSION "<version undefined>" +#endif + printf("%s %s\n", program_invocation_short_name, PACKAGE_VERSION); + return EXIT_SUCCESS; +} + + /** * Print usage information. */ @@ -940,6 +955,7 @@ static int do_query(const char *device, const char *event_type, const char *keyn static const struct option long_options[] = { { "query", no_argument, NULL, MODE_QUERY }, + { "version", no_argument, NULL, MODE_VERSION }, { 0, }, }; @@ -959,6 +975,8 @@ int main (int argc, char **argv) case MODE_QUERY: mode = c; break; + case MODE_VERSION: + return version(); default: return usage(); } |