Add --help.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21732 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-07-31 01:40:30 +00:00
parent 15ea035aef
commit cd48123810

View File

@@ -119,7 +119,7 @@ int debug = 0;
int keepalive = 1; int keepalive = 1;
char *progname; char *progname;
static void usage (void); static void usage (int error_code);
/* /*
* The string to pass to getopt(). We do it this way so * The string to pass to getopt(). We do it this way so
@@ -177,6 +177,8 @@ main(int argc, char **argv)
print_version(NULL); print_version(NULL);
exit(0); exit(0);
} }
if (argc == 2 && strcmp(argv[1], "--help") == 0)
usage(0);
while ((ch = getopt(argc, argv, valid_opts)) != -1) { while ((ch = getopt(argc, argv, valid_opts)) != -1) {
switch(ch) { switch(ch) {
@@ -218,7 +220,7 @@ main(int argc, char **argv)
debug++; debug++;
break; break;
} }
usage(); usage(1);
/* NOTREACHED */ /* NOTREACHED */
break; break;
@@ -238,7 +240,7 @@ main(int argc, char **argv)
} else if (!strcmp(optarg, "options")) { } else if (!strcmp(optarg, "options")) {
diagnostic |= TD_OPTIONS; diagnostic |= TD_OPTIONS;
} else { } else {
usage(); usage(1);
/* NOT REACHED */ /* NOT REACHED */
} }
break; break;
@@ -283,7 +285,7 @@ main(int argc, char **argv)
lowpty = atoi(optarg); lowpty = atoi(optarg);
if ((lowpty > highpty) || (lowpty < 0) || if ((lowpty > highpty) || (lowpty < 0) ||
(highpty > 32767)) { (highpty > 32767)) {
usage(); usage(1);
/* NOT REACHED */ /* NOT REACHED */
} }
break; break;
@@ -341,7 +343,7 @@ main(int argc, char **argv)
fprintf(stderr, "telnetd: %c: unknown option\n", ch); fprintf(stderr, "telnetd: %c: unknown option\n", ch);
/* FALLTHROUGH */ /* FALLTHROUGH */
case '?': case '?':
usage(); usage(0);
/* NOTREACHED */ /* NOTREACHED */
} }
} }
@@ -354,7 +356,7 @@ main(int argc, char **argv)
struct servent *sp; struct servent *sp;
if (argc > 1) { if (argc > 1) {
usage (); usage (1);
} else if (argc == 1) { } else if (argc == 1) {
sp = roken_getservbyname (*argv, "tcp"); sp = roken_getservbyname (*argv, "tcp");
if (sp) if (sp)
@@ -370,7 +372,7 @@ main(int argc, char **argv)
} }
mini_inetd (port); mini_inetd (port);
} else if (argc > 0) { } else if (argc > 0) {
usage(); usage(1);
/* NOT REACHED */ /* NOT REACHED */
} }
@@ -463,7 +465,7 @@ main(int argc, char **argv)
} /* end of main */ } /* end of main */
static void static void
usage(void) usage(int exit_code)
{ {
fprintf(stderr, "Usage: telnetd"); fprintf(stderr, "Usage: telnetd");
#ifdef AUTHENTICATION #ifdef AUTHENTICATION