From 84edc0379a7e92da268eefcaa46cf219367e652a Mon Sep 17 00:00:00 2001 From: Urban Wallasch Date: Wed, 31 Jul 2019 21:56:57 +0200 Subject: [PATCH] * Added use message to telehttpd. --- telehttpd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/telehttpd.c b/telehttpd.c index ff684b3..ede748d 100644 --- a/telehttpd.c +++ b/telehttpd.c @@ -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; } -- 2.30.2