Add -v option to print version.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Wed, 24 Oct 2007 21:28:32 +0000 (21:28 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Wed, 24 Oct 2007 21:28:32 +0000 (21:28 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2574 cb58f699-b61c-0410-a6fe-9272a202ed29

shibd/shibd.cpp

index 9c6839b..526d624 100644 (file)
@@ -59,6 +59,7 @@ bool shibd_shutdown = false;
 const char* shar_config = NULL;\r
 const char* shar_schemadir = NULL;\r
 bool shar_checkonly = false;\r
+bool shar_version = false;\r
 static int unlink_socket = 0;\r
 const char* pidfile = NULL;\r
 \r
@@ -220,6 +221,7 @@ static void usage(char* whoami)
     fprintf(stderr, "  -t\tcheck configuration file for problems.\n");\r
     fprintf(stderr, "  -f\tforce removal of listener socket.\n");\r
     fprintf(stderr, "  -p\tpid file to use.\n");\r
+    fprintf(stderr, "  -v\tprint software version.\n");\r
     fprintf(stderr, "  -h\tprint this help message.\n");\r
     exit(1);\r
 }\r
@@ -228,7 +230,7 @@ static int parse_args(int argc, char* argv[])
 {\r
     int opt;\r
 \r
-    while ((opt = getopt(argc, argv, "c:x:p:fth")) > 0) {\r
+    while ((opt = getopt(argc, argv, "c:x:p:ftvh")) > 0) {\r
         switch (opt) {\r
             case 'c':\r
                 shar_config=optarg;\r
@@ -242,6 +244,9 @@ static int parse_args(int argc, char* argv[])
             case 't':\r
                 shar_checkonly=true;\r
                 break;\r
+            case 'v':\r
+                shar_version=true;\r
+                break;\r
             case 'p':\r
                 pidfile=optarg;\r
                 break;\r
@@ -254,11 +259,15 @@ static int parse_args(int argc, char* argv[])
 \r
 int main(int argc, char *argv[])\r
 {\r
-    if (setup_signals() != 0)\r
-        return -1;\r
-\r
     if (parse_args(argc, argv) != 0)\r
         usage(argv[0]);\r
+    else if (shar_version) {\r
+        fprintf(stdout, PACKAGE_STRING);\r
+        return 0;\r
+    }\r
+\r
+    if (setup_signals() != 0)\r
+        return -1;\r
 \r
     if (!shar_config)\r
         shar_config=getenv("SHIBSP_CONFIG");\r