Commit 68dfa910 authored by Francis Dupont's avatar Francis Dupont
Browse files

Addressed comments about help and version

parent 0985d149
......@@ -150,6 +150,28 @@ static const char use_noarg[] = "No argument for command: %s";
static const char use_v6command[] = "Command not used for DHCPv4: %s";
#endif
#ifdef DHCPv6
#ifdef DHCP4o6
#define DHCLIENT_USAGE0 \
"[-4|-6] [-SNTPRI1dvrxi] [-nw] -4o6 <port>]\n" \
" [-p <port>] [-D LL|LLT] \n"
#else /* DHCP4o6 */
#define DHCLIENT_USAGE0 \
"[-4|-6] [-SNTPRI1dvrxi] [-nw] [-p <port>] [-D LL|LLT] \n"
#endif
#else /* DHCPv6 */
#define DHCLIENT_USAGE0 \
"[-I1dvrxi] [-nw] [-p <port>] [-D LL|LLT] \n"
#endif
#define DHCLIENT_USAGEC \
" [-s server-addr] [-cf config-file]\n" \
" [-df duid-file] [-lf lease-file]\n" \
" [-pf pid-file] [--no-pid] [-e VAR=val]\n" \
" [-sf script-file] [interface]*"
#define DHCLIENT_USAGEH "{--version|--help|-h}"
static void
usage(const char *sfmt, const char *sarg)
{
......@@ -164,22 +186,12 @@ usage(const char *sfmt, const char *sarg)
log_error(sfmt, sarg);
#endif
log_fatal("Usage: %s "
#ifdef DHCPv6
#ifdef DHCP4o6
"[-4|-6] [-SNTPRI1dvrxi] [-nw] -4o6 <port>]\n"
" [-p <port>] [-D LL|LLT] \n"
#else /* DHCP4o6 */
"[-4|-6] [-SNTPRI1dvrxi] [-nw] [-p <port>] [-D LL|LLT] \n"
#endif
#else /* DHCPv6 */
"[-I1dvrxi] [-nw] [-p <port>] [-D LL|LLT] \n"
#endif /* DHCPv6 */
" [-s server-addr] [-cf config-file]\n"
" [-df duid-file] [-lf lease-file]\n"
" [-pf pid-file] [--no-pid] [-e VAR=val]\n"
" [-sf script-file] [interface]*",
isc_file_basename(progname));
log_fatal("Usage: %s %s%s\n %s %s",
isc_file_basename(progname),
DHCLIENT_USAGE0,
DHCLIENT_USAGEC,
isc_file_basename(progname),
DHCLIENT_USAGEH);
}
int
......@@ -254,6 +266,24 @@ main(int argc, char **argv) {
strlen(PACKAGE_VERSION)));
IGNORE_RET(write(STDERR_FILENO, "\n", 1));
exit(0);
} else if (!strcmp(argv[i], "--help") ||
!strcmp(argv[i], "-h")) {
const char *pname = isc_file_basename(progname);
IGNORE_RET(write(STDERR_FILENO, "Usage: ", 7));
IGNORE_RET(write(STDERR_FILENO, pname, strlen(pname)));
IGNORE_RET(write(STDERR_FILENO, " ", 1));
IGNORE_RET(write(STDERR_FILENO, DHCLIENT_USAGE0,
strlen(DHCLIENT_USAGE0)));
IGNORE_RET(write(STDERR_FILENO, DHCLIENT_USAGEC,
strlen(DHCLIENT_USAGEC)));
IGNORE_RET(write(STDERR_FILENO, "\n", 1));
IGNORE_RET(write(STDERR_FILENO, " ", 7));
IGNORE_RET(write(STDERR_FILENO, pname, strlen(pname)));
IGNORE_RET(write(STDERR_FILENO, " ", 1));
IGNORE_RET(write(STDERR_FILENO, DHCLIENT_USAGEH,
strlen(DHCLIENT_USAGEH)));
IGNORE_RET(write(STDERR_FILENO, "\n", 1));
exit(0);
}
}
/* When not forbidden prepare to become a daemon */
......
......@@ -167,8 +167,9 @@ char *progname;
" [-s <subscriber-id>]\n" \
" -l lower0 [ ... -l lowerN]\n" \
" -u upper0 [ ... -u upperN]\n" \
" lower (client link): [address%%]interface[#index]\n" \
" upper (server link): [address%%]interface"
" lower (client link): [address%%]interface[#index]\n" \
" upper (server link): [address%%]interface\n\n" \
" %s {--version|--help|-h}"
#else
#define DHCRELAY_USAGE \
"Usage: %s [-d] [-q] [-a] [-D] [-A <length>] [-c <hops>] [-p <port>]\n" \
......@@ -178,7 +179,8 @@ char *progname;
" [-iu interface0 [ ... -iu interfaceN]\n" \
" [-id interface0 [ ... -id interfaceN]\n" \
" [-U interface]\n" \
" server0 [ ... serverN]\n\n"
" server0 [ ... serverN]\n\n" \
" %s {--version|--help|-h}"
#endif
/*!
......@@ -216,6 +218,7 @@ usage(const char *sfmt, const char *sarg) {
#ifdef DHCPv6
isc_file_basename(progname),
#endif
isc_file_basename(progname),
isc_file_basename(progname));
}
......@@ -272,6 +275,7 @@ main(int argc, char **argv) {
#ifdef DHCPv6
isc_file_basename(progname),
#endif
isc_file_basename(progname),
isc_file_basename(progname));
exit(0);
}
......
......@@ -135,6 +135,44 @@ static void omapi_listener_start (void *foo)
#ifndef UNIT_TEST
#define DHCPD_USAGE0 \
"[-p <UDP port #>] [-f] [-d] [-q] [-t|-T]\n"
#ifdef DHCPv6
#ifdef DHCP4o6
#define DHCPD_USAGE1 \
" [-4|-6] [-4o6 <port>]\n" \
" [-cf config-file] [-lf lease-file]\n"
#else /* DHCP4o6 */
#define DHCPD_USAGE1 \
" [-4|-6] [-cf config-file] [-lf lease-file]\n"
#endif /* DHCP4o6 */
#else /* !DHCPv6 */
#define DHCPD_USAGE1 \
" [-cf config-file] [-lf lease-file]\n"
#endif /* DHCPv6 */
#if defined (PARANOIA)
#define DHCPD_USAGEP \
" [-user user] [-group group] [-chroot dir]\n"
#else
#define DHCPD_USAGEP ""
#endif /* PARANOIA */
#if defined (TRACING)
#define DHCPD_USAGET \
" [-tf trace-output-file]\n" \
" [-play trace-input-file]\n"
#else
#define DHCPD_USAGET ""
#endif /* TRACING */
#define DHCPD_USAGEC \
" [-pf pid-file] [--no-pid] [-s server]\n" \
" [if0 [...ifN]]"
#define DHCPD_USAGEH "{--version|--help|-h}"
/*!
*
* \brief Print the generic usage message
......@@ -164,28 +202,15 @@ usage(const char *sfmt, const char *sarg) {
log_error(sfmt, sarg);
#endif
log_fatal("Usage: %s [-p <UDP port #>] [-f] [-d] [-q] [-t|-T]\n"
#ifdef DHCPv6
#ifdef DHCP4o6
" [-4|-6] [-4o6 <port>]\n"
" [-cf config-file] [-lf lease-file]\n"
#else /* DHCP4o6 */
" [-4|-6] [-cf config-file] [-lf lease-file]\n"
#endif /* DHCP4o6 */
#else /* !DHCPv6 */
" [-cf config-file] [-lf lease-file]\n"
#endif /* DHCPv6 */
#if defined (PARANOIA)
/* meld into the following string */
" [-user user] [-group group] [-chroot dir]\n"
#endif /* PARANOIA */
#if defined (TRACING)
" [-tf trace-output-file]\n"
" [-play trace-input-file]\n"
#endif /* TRACING */
" [-pf pid-file] [--no-pid] [-s server]\n"
" [if0 [...ifN]]",
isc_file_basename(progname));
log_fatal("Usage: %s %s%s%s%s%s\n %s %s",
isc_file_basename(progname),
DHCPD_USAGE0,
DHCPD_USAGE1,
DHCPD_USAGEP,
DHCPD_USAGET,
DHCPD_USAGEC,
isc_file_basename(progname),
DHCPD_USAGEH);
}
/* Note: If we add unit tests to test setup_chroot it will
......@@ -297,6 +322,34 @@ main(int argc, char **argv) {
strlen(PACKAGE_VERSION)));
IGNORE_RET(write(STDERR_FILENO, "\n", 1));
exit (0);
} else if (!strcmp(argv[i], "--help") ||
!strcmp(argv[i], "-h")) {
const char *pname = isc_file_basename(progname);
IGNORE_RET(write(STDERR_FILENO, "Usage: ", 7));
IGNORE_RET(write(STDERR_FILENO, pname, strlen(pname)));
IGNORE_RET(write(STDERR_FILENO, " ", 1));
IGNORE_RET(write(STDERR_FILENO, DHCPD_USAGE0,
strlen(DHCPD_USAGE0)));
IGNORE_RET(write(STDERR_FILENO, DHCPD_USAGE1,
strlen(DHCPD_USAGE1)));
#if defined (PARANOIA)
IGNORE_RET(write(STDERR_FILENO, DHCPD_USAGEP,
strlen(DHCPD_USAGEP)));
#endif
#if defined (TRACING)
IGNORE_RET(write(STDERR_FILENO, DHCPD_USAGET,
strlen(DHCPD_USAGET)));
#endif
IGNORE_RET(write(STDERR_FILENO, DHCPD_USAGEC,
strlen(DHCPD_USAGEC)));
IGNORE_RET(write(STDERR_FILENO, "\n", 1));
IGNORE_RET(write(STDERR_FILENO, " ", 7));
IGNORE_RET(write(STDERR_FILENO, pname, strlen(pname)));
IGNORE_RET(write(STDERR_FILENO, " ", 1));
IGNORE_RET(write(STDERR_FILENO, DHCPD_USAGEH,
strlen(DHCPD_USAGEH)));
IGNORE_RET(write(STDERR_FILENO, "\n", 1));
exit(0);
#ifdef TRACING
} else if (!strcmp (argv [i], "-play")) {
#ifndef DEBUG
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment