[PATCH 2/3] Add -version.

Corbin Simpson mostawesomedude at gmail.com
Fri Mar 26 16:18:19 PDT 2010


From: Eugene St Leger <grimrc at yahoo.com>

Part of #7968.

Massively simplified from the original patch.

Signed-off-by: Corbin Simpson <MostAwesomeDude at gmail.com>
---
 xdpyinfo.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/xdpyinfo.c b/xdpyinfo.c
index dc9829a..2251085 100644
--- a/xdpyinfo.c
+++ b/xdpyinfo.c
@@ -1569,10 +1569,18 @@ print_marked_extensions(Display *dpy)
     }
 }
 
+static void
+print_version(void)
+{
+    printf("xdpyinfo %s\n", PACKAGE_VERSION);
+    exit (EXIT_SUCCESS);
+}
+
 static void 
 usage(void)
 {
     fprintf (stderr, "usage:  %s [options]\n", ProgramName);
+    fprintf (stderr, "-version\t\tprint version\n");
     fprintf (stderr, "-display displayname\tserver to query\n");
     fprintf (stderr, "-queryExtensions\tprint info returned by XQueryExtension\n");
     fprintf (stderr, "-ext all\t\tprint detailed info for all supported extensions\n");
@@ -1594,8 +1602,10 @@ main(int argc, char *argv[])
     for (i = 1; i < argc; i++) {
 	char *arg = argv[i];
 	int len = strlen(arg);
-	
-	if (!strncmp("-display", arg, len)) {
+
+	if (!strncmp("-version", arg, len)) {
+		print_version ();
+	} else if (!strncmp("-display", arg, len)) {
 	    if (++i >= argc) usage ();
 	    displayname = argv[i];
 	} else if (!strncmp("-queryExtensions", arg, len)) {
-- 
1.6.6.1



More information about the xorg-devel mailing list