From cfa1a004334d6af9808a04acd11de4a2e3b1f145 Mon Sep 17 00:00:00 2001 From: Job Snijders Date: Tue, 31 Dec 2019 14:36:44 +0100 Subject: [PATCH] Add -v version command line option --- bgpq4.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/bgpq4.c b/bgpq4.c index 723b900..414c3fc 100644 --- a/bgpq4.c +++ b/bgpq4.c @@ -77,10 +77,22 @@ usage(int ecode) " use 'host:port' to specify alternate port\n"); printf(" -S sources: only use specified IRR sources, in the specified order\n"); printf(" -T : disable pipelining (not recommended)\n"); - printf("\n" PACKAGE_NAME " version: " PACKAGE_VERSION "\n"); + printf(" -v : print version and exit\n"); + printf("\n" PACKAGE_NAME " version: " PACKAGE_VERSION " " + "(https://github.com/bgp/bgpq4)\n"); exit(ecode); } +void +version() +{ + printf(PACKAGE_NAME " - a versatile utility to generate BGP filters\n" + "version: " PACKAGE_VERSION "\n" + "website: https://github.com/bgp/bgpq4\n" + "maintainer: Job Snijders \n"); + exit(0); +} + void exclusive() { @@ -154,7 +166,7 @@ main(int argc, char* argv[]) if (getenv("IRRD_SOURCES")) expander.sources=getenv("IRRD_SOURCES"); - while ((c = getopt(argc,argv,"346a:AbBdDEF:S:jJKf:l:L:m:M:NnW:pr:R:G:tTh:UwXsz")) + while ((c = getopt(argc,argv,"346a:AbBdDEF:S:jJKf:l:L:m:M:NnW:pr:R:G:tTh:UwXsvz")) !=EOF) { switch (c) { case '3': @@ -376,6 +388,9 @@ main(int argc, char* argv[]) vendor_exclusive(); expander.vendor = V_CISCO_XR; break; + case 'v': + version(); + break; case 'z': if (expander.generation) exclusive();