diff --git a/iodine.c b/iodine.c index dbbc2ca..d889b5e 100644 --- a/iodine.c +++ b/iodine.c @@ -117,12 +117,18 @@ extern char *__progname; static void usage() { - printf("Usage: %s [-u user] nameserver topdomain\n", __progname); - printf("-f is to keep running in foreground\n"); - printf("-u name to drop privileges and run as user 'name'\n"); + printf("Usage: %s [-f] [-u user] nameserver topdomain\n", __progname); exit(2); } +static void +help() { + printf("Usage: %s [-f] [-u user] nameserver topdomain\n", __progname); + printf(" -f is to keep running in foreground\n"); + printf(" -u name to drop privileges and run as user 'name'\n"); + exit(0); +} + int main(int argc, char **argv) { @@ -141,11 +147,14 @@ main(int argc, char **argv) usage(); } - while ((choice = getopt(argc, argv, "fu:")) != -1) { + while ((choice = getopt(argc, argv, "fhu:")) != -1) { switch(choice) { case 'f': foreground = 1; break; + case 'h': + help(); + break; case 'u': username = optarg; break; diff --git a/iodined.c b/iodined.c index b1a1862..4cffdd8 100644 --- a/iodined.c +++ b/iodined.c @@ -117,11 +117,17 @@ extern char *__progname; static void usage() { printf("Usage: %s [-f] [-u user] topdomain\n", __progname); - printf("-f is to keep running in foreground\n"); - printf("-u name to drop privileges and run as user 'name'\n"); exit(2); } +static void +help() { + printf("Usage: %s [-f] [-u user] topdomain\n", __progname); + printf(" -f to keep running in foreground\n"); + printf(" -u name to drop privileges and run as user 'name'\n"); + exit(0); +} + int main(int argc, char **argv) { @@ -140,11 +146,14 @@ main(int argc, char **argv) usage(); } - while ((choice = getopt(argc, argv, "fu:")) != -1) { + while ((choice = getopt(argc, argv, "fhu:")) != -1) { switch(choice) { case 'f': foreground = 1; break; + case 'h': + help(); + break; case 'u': username = optarg; break;