Add help text for keyd
authorJonathan McDowell <noodles@earth.li>
Wed, 6 Apr 2011 02:08:12 +0000 (19:08 -0700)
committerJonathan McDowell <noodles@earth.li>
Wed, 6 Apr 2011 02:08:12 +0000 (19:08 -0700)
  Support -h option for printing help text.

keyd.c

diff --git a/keyd.c b/keyd.c
index ebf142c3972ac69b83c33d675d4a3e6942111257..c2d83491ea91fc6e23dcd75ee57ff0a9bbef1ec9 100644 (file)
--- a/keyd.c
+++ b/keyd.c
@@ -19,6 +19,7 @@
 #include <sys/un.h>
 #include <unistd.h>
 
 #include <sys/un.h>
 #include <unistd.h>
 
+#include "config.h"
 #include "charfuncs.h"
 #include "cleanup.h"
 #include "keyd.h"
 #include "charfuncs.h"
 #include "cleanup.h"
 #include "keyd.h"
@@ -378,6 +379,19 @@ int sock_accept(int fd)
        return 1;
 }
 
        return 1;
 }
 
+static void usage(void)
+{
+       puts("keyd " PACKAGE_VERSION " - backend key serving daemon for the "
+               "onak PGP keyserver.\n");
+       puts("Usage:\n");
+       puts("\tkeyd [options]\n");
+       puts("\tOptions:\n:");
+       puts("-c <file> - use <file> as the config file");
+       puts("-f        - run in the foreground");
+       puts("-h        - show this help text");
+       exit(EXIT_FAILURE);
+}
+
 int main(int argc, char *argv[])
 {
        int fd = -1;
 int main(int argc, char *argv[])
 {
        int fd = -1;
@@ -387,7 +401,7 @@ int main(int argc, char *argv[])
        bool foreground = false;
        int optchar;
 
        bool foreground = false;
        int optchar;
 
-       while ((optchar = getopt(argc, argv, "c:f")) != -1 ) {
+       while ((optchar = getopt(argc, argv, "c:fh")) != -1 ) {
                switch (optchar) {
                case 'c':
                        configfile = strdup(optarg);
                switch (optchar) {
                case 'c':
                        configfile = strdup(optarg);
@@ -395,6 +409,10 @@ int main(int argc, char *argv[])
                case 'f':
                        foreground = true;
                        break;
                case 'f':
                        foreground = true;
                        break;
+               case 'h':
+               default:
+                       usage();
+                       break;
                }
        }
 
                }
        }