diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-01-20 12:50:53 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-01-20 12:50:53 +0000 |
commit | d164e644e5085e124e57447dbdc30feb26812cd0 (patch) | |
tree | e6bc7c7f9da8a16d1a8a53e1d1bc5dcad15decc8 /usr.sbin | |
parent | 3833d3697698c891b6ab74fd31d5f66138ca5da8 (diff) |
getopt & usage, prodded by theo
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index 1f40cfad9b2..41f44738293 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.29 2004/01/19 10:41:34 henning Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.30 2004/01/20 12:50:52 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -89,6 +89,7 @@ static const struct keywords keywords_neighbor[] = { { "down", NEIGHBOR_DOWN} }; +void usage(void); int main(int, char *[]); int match_keyword(const char *, const struct keywords [], size_t); void show_summary_head(void); @@ -112,6 +113,15 @@ int show_interface_msg(struct imsg *); struct imsgbuf ibuf; +void +usage(void) +{ + extern char *__progname; + + fprintf(stderr, "usage: %s <command> [arg [...]]\n", __progname); + exit (1); +} + int main(int argc, char *argv[]) { @@ -121,6 +131,18 @@ main(int argc, char *argv[]) struct imsg imsg; enum actions action = SHOW_SUMMARY; struct bgpd_addr addr; + int ch; + + while ((ch = getopt(argc, argv, "")) != -1) { + switch (ch) { + default: + usage(); + /* not reached */ + } + } + + argc -= optind; + argv += optind; if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { err(1, "control_init: socket"); |