Description: add missing fundamental information in the help.
 This patch completes the guide by adding essential information for new users.
 It also slightly improves performance and corrects the use of standard
 system streams (stderr, stdout).
Author: Lorenzo L. Ancora <admin@lorenzoancora.info>
Last-Update: 2020-01-04
Bug-Debian: https://bugs.debian.org/948182

--- a/wrapsrv.c
+++ b/wrapsrv.c
@@ -39,6 +39,14 @@
 #define NS_MAXMSG 65535
 #endif
 
+#define USAGE_TXT "Usage: wrapsrv <SRVNAME> <COMMAND> [COMMAND OPTIONS]\n\n\
+Use all matching DNS SRV (RFC 2782) records to build/execute command lines.\n\
+SRVNAME is the symbolic name of the service (case insensitive).\n\
+%%h and %%p sequences in COMMAND will be converted to hostname and port.\n\n\
+Example (URL building and printing):\n\t\
+wrapsrv _ftps._tcp.domain.example echo ftps://%%h:%%p/\n\n\
+Copyright (c) Farsight Security, Inc.; licensed under 'Apache License 2.0'.\n"
+
 /* Data types. */
 
 struct srv {
@@ -70,7 +78,7 @@ static struct srv *next_tuple(void);
 static void free_tuples(void);
 static void insert_tuple(char *, uint16_t, uint16_t, uint16_t);
 static void parse_answer_section(ns_msg *);
-static void usage(void);
+static void usage(FILE*);
 
 #ifdef DEBUG
 static void print_tuples(void);
@@ -349,10 +357,8 @@ do_cmd(struct srv *se, int argc, char **
 }
 
 static void
-usage(void) {
-	fprintf(stderr, "Usage: wrapsrv <SRVNAME> <COMMAND> [OPTION]...\n");
-	fprintf(stderr, "%%h and %%p sequences will be converted to "
-		"hostname and port.\n");
+usage(FILE* stream) {
+	fprintf(stream, USAGE_TXT);
 	exit(EXIT_FAILURE);
 }
 
@@ -367,8 +373,10 @@ main(int argc, char **argv) {
 	struct timeval tv;
 	unsigned int seed = 0;
 
-	if (argc < 3)
-		usage();
+	if (argc <= 1)
+		usage(stdout);
+	else if (argc < 3)
+		usage(stderr);
 
 	ISC_LIST_INIT(prio_list);
 
