Implement usage
authorPierre Habouzit <madcoder@debian.org>
Fri, 30 Nov 2007 08:36:27 +0000 (09:36 +0100)
committerPierre Habouzit <madcoder@debian.org>
Fri, 30 Nov 2007 08:36:27 +0000 (09:36 +0100)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
main-postlicyd.c

index fe4a851..04172dd 100644 (file)
@@ -38,6 +38,8 @@
 #include "epoll.h"
 #include "threads.h"
 
+#define DAEMON_NAME             "postlicyd"
+
 /* administrivia {{{ */
 
 static int main_initialize(void)
@@ -59,6 +61,15 @@ static void main_shutdown(void)
 module_init(main_initialize);
 module_exit(main_shutdown);
 
+void usage(void)
+{
+    fputs("usage: "DAEMON_NAME" [options] config\n"
+          "\n"
+          "Options:\n"
+          "    -p <pidfile> file to write our pid to\n"
+         , stderr);
+}
+
 /* }}} */
 
 void *job_run(int fd, void *data)
@@ -100,11 +111,16 @@ int main(int argc, char *argv[])
             pidfile = optarg;
             break;
           default:
-            //usage();
+            usage();
             return EXIT_FAILURE;
         }
     }
 
+    if (argc - optind != 1) {
+        usage();
+        return EXIT_FAILURE;
+    }
+
     if (pidfile) {
         f = fopen(pidfile, "w");
         if (!f) {