dump usage() info to stdout when asking for help

This commit is contained in:
Mike Frysinger 2009-03-06 02:11:45 +00:00
parent 69a0d44d75
commit b9e72ce5af

View File

@ -169,6 +169,7 @@ USHORT o_wfile = 0;
USHORT o_random = 0; USHORT o_random = 0;
USHORT o_udpmode = 0; USHORT o_udpmode = 0;
USHORT o_verbose = 0; USHORT o_verbose = 0;
USHORT o_holler_stderr = 1;
unsigned int o_wait = 0; unsigned int o_wait = 0;
USHORT o_zero = 0; USHORT o_zero = 0;
/* o_tn in optional section */ /* o_tn in optional section */
@ -194,22 +195,23 @@ void holler (str, p1, p2, p3, p4, p5, p6)
char * str; char * str;
char * p1, * p2, * p3, * p4, * p5, * p6; char * p1, * p2, * p3, * p4, * p5, * p6;
{ {
FILE *o_holler_out = (o_holler_stderr ? stderr : stdout);
if (o_verbose) { if (o_verbose) {
fprintf (stderr, str, p1, p2, p3, p4, p5, p6); fprintf (o_holler_out, str, p1, p2, p3, p4, p5, p6);
#ifdef HAVE_BIND #ifdef HAVE_BIND
if (h_errno) { /* if host-lookup variety of error ... */ if (h_errno) { /* if host-lookup variety of error ... */
if (h_errno > 4) /* oh no you don't, either */ if (h_errno > 4) /* oh no you don't, either */
fprintf (stderr, "preposterous h_errno: %d", h_errno); fprintf (o_holler_out, "preposterous h_errno: %d", h_errno);
else else
fprintf (stderr, h_errs[h_errno]); /* handle it here */ fprintf (o_holler_out, h_errs[h_errno]); /* handle it here */
h_errno = 0; /* and reset for next call */ h_errno = 0; /* and reset for next call */
} }
#endif #endif
if (errno) { /* this gives funny-looking messages, but */ if (errno) { /* this gives funny-looking messages, but */
perror (" "); /* it's more portable than sys_errlist[]... */ perror (" "); /* it's more portable than sys_errlist[]... */
} else /* xxx: do something better? */ } else /* xxx: do something better? */
fprintf (stderr, "\n"); fprintf (o_holler_out, "\n");
fflush (stderr); fflush (o_holler_out);
} }
} /* holler */ } /* holler */
@ -1308,6 +1310,7 @@ void
helpme() helpme()
{ {
o_verbose = 1; o_verbose = 1;
o_holler_stderr = 0;
holler ("[v1.10]\n\ holler ("[v1.10]\n\
connect to somewhere: nc [-options] hostname port[s] [ports] ... \n\ connect to somewhere: nc [-options] hostname port[s] [ports] ... \n\
listen for inbound: nc -l -p port [-options] [hostname] [port]\n\ listen for inbound: nc -l -p port [-options] [hostname] [port]\n\