From 080d63db2f566ad6378069ca24359f3c635cc6e3 Mon Sep 17 00:00:00 2001 From: Denis Ovsienko Date: Tue, 15 Sep 2020 12:51:33 +0100 Subject: Improve "-h" text printing in rpcapd. [skip ci] Use stdout when there is no error, and stderr when there is an error. Include OpenSSL version in the output. See also tcpdump commit 49894b41. --- rpcapd/rpcapd.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/rpcapd/rpcapd.c b/rpcapd/rpcapd.c index 7df87340..206181e7 100644 --- a/rpcapd/rpcapd.c +++ b/rpcapd/rpcapd.c @@ -39,6 +39,7 @@ #include // for the errno variable #include // for strtok, etc #include // for malloc(), free(), ... +#include // for fprintf(), stderr, FILE etc #include // for PCAP_ERRBUF_SIZE #include // for signal() @@ -117,7 +118,7 @@ static unsigned __stdcall main_passive_serviceloop_thread(void *ptr); /*! \brief Prints the usage screen if it is launched in console mode. */ -static void printusage(void) +static void printusage(FILE * f) { const char *usagetext = "USAGE:" @@ -161,9 +162,12 @@ static void printusage(void) " specified from the command line are ignored\n\n" " -h print this help screen\n\n"; - (void)fprintf(stderr, "RPCAPD, a remote packet capture daemon.\n" - "Compiled with %s\n\n", pcap_lib_version()); - printf("%s", usagetext); + (void)fprintf(f, "RPCAPD, a remote packet capture daemon.\n" + "Compiled with %s\n", pcap_lib_version()); +#if defined(HAVE_OPENSSL) && defined(SSLEAY_VERSION) + (void)fprintf(f, "Compiled with %s\n", SSLeay_version(SSLEAY_VERSION)); +#endif + (void)fprintf(f, "\n%s", usagetext); } @@ -237,7 +241,7 @@ int main(int argc, char *argv[]) break; case 'i': #ifdef _WIN32 - printusage(); + printusage(stderr); exit(1); #else isrunbyinetd = 1; @@ -308,7 +312,7 @@ int main(int argc, char *argv[]) break; #endif case 'h': - printusage(); + printusage(stdout); exit(0); /*NOTREACHED*/ default: -- cgit v1.2.1