diff options
Diffstat (limited to 'sysdep/unix/main.c')
-rw-r--r-- | sysdep/unix/main.c | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c index 1f47680e..c1b92b7e 100644 --- a/sysdep/unix/main.c +++ b/sysdep/unix/main.c @@ -8,7 +8,9 @@ #undef LOCAL_DEBUG -#define _GNU_SOURCE 1 +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif #include <stdio.h> #include <stdlib.h> @@ -73,7 +75,7 @@ async_dump(void) #else static inline void -drop_uid(uid_t uid) +drop_uid(uid_t uid UNUSED) { die("Cannot change user on this platform"); } @@ -419,7 +421,7 @@ cli_get_command(cli *c) } static int -cli_rx(sock *s, int size UNUSED) +cli_rx(sock *s, uint size UNUSED) { cli_kick(s->data); return 0; @@ -439,7 +441,7 @@ cli_err(sock *s, int err) } static int -cli_connect(sock *s, int size UNUSED) +cli_connect(sock *s, uint size UNUSED) { cli *c; @@ -621,7 +623,7 @@ signal_init(void) * Parsing of command-line arguments */ -static char *opt_list = "c:dD:ps:P:u:g:flR"; +static char *opt_list = "c:dD:ps:P:u:g:flRh"; static int parse_and_exit; char *bird_name; static char *use_user; @@ -629,10 +631,43 @@ static char *use_group; static int run_in_foreground = 0; static void -usage(void) +display_usage(void) +{ + fprintf(stderr, "Usage: %s [--version] [--help] [-c <config-file>] [OPTIONS]\n", bird_name); +} + +static void +display_help(void) +{ + display_usage(); + + fprintf(stderr, + "\n" + "Options: \n" + " -c <config-file> Use given configuration file instead\n" + " of prefix/etc/bird.conf\n" + " -d Enable debug messages and run bird in foreground\n" + " -D <debug-file> Log debug messages to given file instead of stderr\n" + " -f Run bird in foreground\n" + " -g <group> Use given group ID\n" + " -h, --help Display this information\n" + " -l Look for a configuration file and a communication socket\n" + " file in the current working directory\n" + " -p Test configuration file and exit without start\n" + " -P <pid-file> Create a PID file with given filename\n" + " -R Apply graceful restart recovery after start\n" + " -s <control-socket> Use given filename for a control socket\n" + " -u <user> Drop privileges and use given user ID\n" + " --version Display version of BIRD\n"); + + exit(0); +} + +static void +display_version(void) { - fprintf(stderr, "Usage: %s [-c <config-file>] [-d] [-D <debug-file>] [-p] [-s <control-socket>] [-P <pid-file>] [-u <user>] [-g <group>] [-f] [-l] [-R]\n", bird_name); - exit(1); + fprintf(stderr, "BIRD version " BIRD_VERSION "\n"); + exit(0); } static inline char * @@ -706,12 +741,9 @@ parse_args(int argc, char **argv) if (argc == 2) { if (!strcmp(argv[1], "--version")) - { - fprintf(stderr, "BIRD version " BIRD_VERSION "\n"); - exit(0); - } + display_version(); if (!strcmp(argv[1], "--help")) - usage(); + display_help(); } while ((c = getopt(argc, argv, opt_list)) >= 0) switch (c) @@ -755,11 +787,19 @@ parse_args(int argc, char **argv) case 'R': graceful_restart_recovery(); break; + case 'h': + display_help(); + break; default: - usage(); + fputc('\n', stderr); + display_usage(); + exit(1); } if (optind < argc) - usage(); + { + display_usage(); + exit(1); + } } /* |