[PATCH evtest] Add --version flag

Peter Hutterer peter.hutterer at who-t.net
Wed Aug 31 16:07:33 PDT 2011


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 at who-t.net>
---
 evtest.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/evtest.c b/evtest.c
index ea03979..74230ea 100644
--- a/evtest.c
+++ b/evtest.c
@@ -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();
 		}
-- 
1.7.6



More information about the xorg-devel mailing list