qstat (2.11-3) version_option.patch

Summary

 qstat.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

    
download this patch

Patch contents

Description: Add a --version option
 Add a --version option that just prints Qstat's version, and adapt
 usage() to use it instead of duplicating it.
Author: Jordi Mallach <jordi@debian.org>
Forwarded: no

Index: b/qstat.c
===================================================================
--- a/qstat.c	2010-06-07 00:10:13.841997312 +0200
+++ b/qstat.c	2010-06-07 00:10:17.082002496 +0200
@@ -2579,6 +2579,12 @@
 char * strndup( const char *string, size_t len);
 #define FORCE 1
 
+/* Print Qstat version information and exit */
+void print_version() {
+    printf( "\nqstat version %s\n", VERSION);
+    exit(0);
+}
+
 /* Print an error message and the program usage notes
  */
 
@@ -2682,7 +2688,7 @@
     printf( "Sort keys:\n");
     printf( "  servers: p=by-ping, g=by-game, i=by-IP-address, h=by-hostname, n=by-#-players, l=by-list-order\n");
     printf( "  players: P=by-ping, F=by-frags, T=by-team, N=by-name\n");
-    printf( "\nqstat version %s\n", VERSION);
+    print_version();
     exit(0);
 }
 
@@ -3238,6 +3244,9 @@
 	else if ( strcmp( argv[arg], "--help") == 0)  {
 		usage(NULL,argv,NULL);
 	}
+	else if ( strcmp( argv[arg], "--version") == 0)  {
+		print_version();
+	}
 	else if ( strcmp( argv[arg], "-f") == 0)  {
 	    arg++;
 	    if ( arg >= argc)