* Added use message to telehttpd.
authorUrban Wallasch <urban.wallasch@freenet.de>
Wed, 31 Jul 2019 19:56:57 +0000 (21:56 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Wed, 31 Jul 2019 19:56:57 +0000 (21:56 +0200)
telehttpd.c

index ff684b37f639e0ca51980b50e97bfa9739baddc2..ede748d82fb96b435d063b8b44ca0da209feefa4 100644 (file)
@@ -203,6 +203,22 @@ static int serve_http(void) {
     return 0;
 }
 
+static void usage( const char *me )
+{
+    const char *p;
+    if ( NULL != ( p = strrchr( me, '/' ) ) )
+        me = ++p;
+    fprintf( stderr, "Usage: %s [options]\n", me );
+    fprintf( stderr,
+        " Options:\n"
+        "  -b str   bind interface; default: * (all)\n"
+        "  -h str   host name; default: localhost\n"
+        "  -i file  file to serve as index file; default: index.html\n"
+        "  -o str   origin; default: http://localhost\n"
+        "  -p N     TCP listen port; default: 8837\n"
+    );
+}
+
 static int config( int argc, char *argv[] ) {
     int opt;
     const char *ostr = "+b:h:i:o:p:";
@@ -226,11 +242,13 @@ static int config( int argc, char *argv[] ) {
             break;
         case ':':
             EPRINT( "Missing argument for option '%c'\n", optopt );
+            usage( argv[0] );
             return -1;
             break;
         case '?':
         default:
             EPRINT( "Unrecognized option '%c'\n", optopt );
+            usage( argv[0] );
             return -1;
             break;
         }