Implemented support for command-line options that print version information
on stdout: -version, --version and -v are all equivalent.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2578 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx
index 637af28..baf9fcc 100644
--- a/unix/x0vncserver/x0vncserver.cxx
+++ b/unix/x0vncserver/x0vncserver.cxx
@@ -368,11 +368,17 @@
 
 char* programName;
 
+static void printVersion(FILE *fp)
+{
+  fprintf(fp, "TightVNC Server version %s, built %s\n",
+          VERSION, buildtime);
+}
+
 static void usage()
 {
-  fprintf(stderr, "TightVNC Server version %s, built %s\n\n",
-          VERSION, buildtime);
-  fprintf(stderr, "Usage: %s [<parameters>]\n", programName);
+  printVersion(stderr);
+  fprintf(stderr, "\nUsage: %s [<parameters>]\n", programName);
+  fprintf(stderr, "       %s --version\n", programName);
   fprintf(stderr,"\n"
           "Parameters can be turned on with -<param> or off with -<param>=0\n"
           "Parameters which take a value can be specified as "
@@ -403,6 +409,12 @@
           continue;
         }
       }
+      if (strcmp(argv[i], "-v") == 0 ||
+          strcmp(argv[i], "-version") == 0 ||
+          strcmp(argv[i], "--version") == 0) {
+        printVersion(stdout);
+        return 0;
+      }
       usage();
     }