[PATCH v3 6/6] media-ctl: Add version command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a --version option to media-ctl to retrieve the version of
media-ctl.

Signed-off-by: Paul Elder <paul.elder@xxxxxxxxxxxxxxxx>

---
Changes in v3:
- embed PACKAGE_VERSION instead of string concatenation
---
 utils/media-ctl/options.c | 12 ++++++++++++
 utils/media-ctl/options.h |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/utils/media-ctl/options.c b/utils/media-ctl/options.c
index fb923775..bc4f374f 100644
--- a/utils/media-ctl/options.c
+++ b/utils/media-ctl/options.c
@@ -42,6 +42,11 @@ struct media_options media_opts = {
 	.devname = MEDIA_DEVNAME_DEFAULT,
 };
 
+static void version()
+{
+	printf("media-ctl %s\n", PACKAGE_VERSION);
+}
+
 static void usage(const char *argv0)
 {
 	unsigned int i;
@@ -66,6 +71,7 @@ static void usage(const char *argv0)
 	printf("    --print-dot		Print the device topology as a dot graph\n");
 	printf("-r, --reset		Reset all links to inactive\n");
 	printf("-v, --verbose		Be verbose\n");
+	printf("    --version		Show version information\n");
 	printf("\n");
 	printf("Links and formats are defined as\n");
 	printf("\tlinks           = link { ',' link } ;\n");
@@ -127,6 +133,7 @@ static void usage(const char *argv0)
 #define OPT_SET_DV			258
 #define OPT_LIST_KNOWN_MBUS_FMTS	259
 #define OPT_GET_DV			260
+#define OPT_VERSION			261
 
 static struct option opts[] = {
 	{"device", 1, 0, 'd'},
@@ -145,6 +152,7 @@ static struct option opts[] = {
 	{"print-topology", 0, 0, 'p'},
 	{"reset", 0, 0, 'r'},
 	{"verbose", 0, 0, 'v'},
+	{"version", 0, 0, OPT_VERSION},
 	{ },
 };
 
@@ -287,6 +295,10 @@ int parse_cmdline(int argc, char **argv)
 			list_known_mbus_formats();
 			exit(0);
 
+		case OPT_VERSION:
+			version();
+			exit(0);
+
 		default:
 			printf("Invalid option -%c\n", opt);
 			printf("Run %s -h for help.\n", argv[0]);
diff --git a/utils/media-ctl/options.h b/utils/media-ctl/options.h
index 7e0556fc..b1751f56 100644
--- a/utils/media-ctl/options.h
+++ b/utils/media-ctl/options.h
@@ -22,6 +22,8 @@
 #ifndef __OPTIONS_H
 #define __OPTIONS_H
 
+#include <config.h>
+
 struct media_options
 {
 	const char *devname;
-- 
2.27.0




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux