summary refs log tree commit diff
path: root/sunrpc/rpcinfo.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-02-06 20:13:07 +0000
committerUlrich Drepper <drepper@redhat.com>2009-02-06 20:13:07 +0000
commitcbbcaf2369b2111d9388ce54ea18854319dbfab3 (patch)
tree0ffc9cafd19065f44923eee2d1e6fac3afb114d4 /sunrpc/rpcinfo.c
parente2e390fad8271da33a51075cc2bf27c9fe78861b (diff)
downloadglibc-cbbcaf2369b2111d9388ce54ea18854319dbfab3.tar.gz
glibc-cbbcaf2369b2111d9388ce54ea18854319dbfab3.tar.xz
glibc-cbbcaf2369b2111d9388ce54ea18854319dbfab3.zip
* debug/xtrace.sh: Unify translatable messages.
	* elf/ldd.bash.in: Likewise.
	* elf/sprof.c: Likewise.
	* locale/programs/locale.c: Likewise.
	* malloc/memusage.sh: Likewise.
	* nss/getent.c: Likewise.

2009-02-06  Joseph Myers  <joseph@codesourcery.com>

	* debug/pcprofiledump.c (print_version,
	argp_program_version_hook): New function.
	* elf/ldconfig.c (more_help): New function.
	(argp): Use it.
	* elf/sln.c (usage): New function.
	(main): Support --help and --version.
	* malloc/memusagestat.c (print_version): New function.
	(argp_program_version_hook): New variable.
	* nscd/nscd.c (more_help): New function.
	(argp): Use it.
	* posix/getconf.c (main): Send --version output to stdout.
	Support --help.
	* sunrpc/rpc_main.c (usage, options_usage): Take STREAM and STATUS
	arguments.  All callers changed.
	(print_version): New function.
	(parseargs): Support --help and --version.
	* sunrpc/rpcinfo.c (usage): Take STREAM argument.  All callers
	changed.
	(print_version): New function.
	(main): Use getopt_long.  Support --help and --version.
	* sysdeps/unix/sysv/linux/lddlibc4.c (main): Support --help and
	--version.

2009-02-06  Ulrich Drepper  <drepper@redhat.com>
Diffstat (limited to 'sunrpc/rpcinfo.c')
-rw-r--r--sunrpc/rpcinfo.c59
1 files changed, 43 insertions, 16 deletions
diff --git a/sunrpc/rpcinfo.c b/sunrpc/rpcinfo.c
index d9da989660..91f360c2f3 100644
--- a/sunrpc/rpcinfo.c
+++ b/sunrpc/rpcinfo.c
@@ -58,6 +58,9 @@ static char sccsid[] = "@(#)rpcinfo.c 1.22 87/08/12 SMI";
 #include <locale.h>
 #include <libintl.h>
 
+#include "../version.h"
+#define PACKAGE _libc_intl_domainname
+
 #define MAXHOSTLEN 256
 
 #define	MIN_VERS	((u_long) 0)
@@ -70,7 +73,8 @@ static void pmapdump (int argc, char **argv);
 static bool_t reply_proc (void *res, struct sockaddr_in *who);
 static void brdcst (int argc, char **argv) __attribute__ ((noreturn));
 static void deletereg (int argc, char **argv);
-static void usage (void);
+static void usage (FILE *stream);
+static void print_version (void);
 static u_long getprognum (char *arg);
 static u_long getvers (char *arg);
 static void get_inet_address (struct sockaddr_in *addr, char *host);
@@ -92,6 +96,11 @@ main (int argc, char **argv)
   int errflg;
   int function;
   u_short portnum;
+  static const struct option long_options[] = {
+    { "help", no_argument, NULL, 'H' },
+    { "version", no_argument, NULL, 'V' },
+    { NULL, 0, NULL, 0 }
+  };
 
   setlocale (LC_ALL, "");
   textdomain (_libc_intl_domainname);
@@ -99,7 +108,7 @@ main (int argc, char **argv)
   function = NONE;
   portnum = 0;
   errflg = 0;
-  while ((c = getopt (argc, argv, "ptubdn:")) != -1)
+  while ((c = getopt_long (argc, argv, "ptubdn:", long_options, NULL)) != -1)
     {
       switch (c)
 	{
@@ -143,6 +152,14 @@ main (int argc, char **argv)
 	    function = DELETES;
 	  break;
 
+	case 'H':
+	  usage (stdout);
+	  return 0;
+
+	case 'V':
+	  print_version ();
+	  return 0;
+
 	case '?':
 	  errflg = 1;
 	}
@@ -150,7 +167,7 @@ main (int argc, char **argv)
 
   if (errflg || function == NONE)
     {
-      usage ();
+      usage (stderr);
       return 1;
     }
 
@@ -160,7 +177,7 @@ main (int argc, char **argv)
     case PMAPDUMP:
       if (portnum != 0)
 	{
-	  usage ();
+	  usage (stderr);
 	  return 1;
 	}
       pmapdump (argc - optind, argv + optind);
@@ -177,7 +194,7 @@ main (int argc, char **argv)
     case BRDCST:
       if (portnum != 0)
 	{
-	  usage ();
+	  usage (stderr);
 	  return 1;
 	}
       brdcst (argc - optind, argv + optind);
@@ -208,7 +225,7 @@ udpping (portnum, argc, argv)
 
   if (argc < 2 || argc > 3)
     {
-      usage ();
+      usage (stderr);
       exit (1);
     }
   prognum = getprognum (argv[1]);
@@ -363,7 +380,7 @@ tcpping (portnum, argc, argv)
 
   if (argc < 2 || argc > 3)
     {
-      usage ();
+      usage (stderr);
       exit (1);
     }
   prognum = getprognum (argv[1]);
@@ -532,7 +549,7 @@ pmapdump (argc, argv)
 
   if (argc > 1)
     {
-      usage ();
+      usage (stderr);
       exit (1);
     }
   if (argc == 1)
@@ -624,7 +641,7 @@ brdcst (argc, argv)
 
   if (argc != 2)
     {
-      usage ();
+      usage (stderr);
       exit (1);
     }
   prognum = getprognum (argv[0]);
@@ -650,7 +667,7 @@ deletereg (argc, argv)
 
   if (argc != 2)
     {
-      usage ();
+      usage (stderr);
       exit (1);
     }
   if (getuid ())
@@ -669,15 +686,25 @@ deletereg (argc, argv)
 }
 
 static void
-usage ()
+usage (FILE *stream)
 {
   fputs (_("Usage: rpcinfo [ -n portnum ] -u host prognum [ versnum ]\n"),
-	 stderr);
+	 stream);
   fputs (_("       rpcinfo [ -n portnum ] -t host prognum [ versnum ]\n"),
-	 stderr);
-  fputs (_("       rpcinfo -p [ host ]\n"), stderr);
-  fputs (_("       rpcinfo -b prognum versnum\n"), stderr);
-  fputs (_("       rpcinfo -d prognum versnum\n"), stderr);
+	 stream);
+  fputs (_("       rpcinfo -p [ host ]\n"), stream);
+  fputs (_("       rpcinfo -b prognum versnum\n"), stream);
+  fputs (_("       rpcinfo -d prognum versnum\n"), stream);
+  fputc ('\n', stream);
+  fprintf (stream, _("\
+For bug reporting instructions, please see:\n\
+<http://www.gnu.org/software/libc/bugs.html>.\n"));
+}
+
+static void
+print_version (void)
+{
+  printf ("rpcinfo (GNU %s) %s\n", PACKAGE, VERSION);
 }
 
 static u_long