Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/getent Implement "rpc"



details:   https://anonhg.NetBSD.org/src/rev/c97dd528f9e0
branches:  trunk
changeset: 573163:c97dd528f9e0
user:      ginsbach <ginsbach%NetBSD.org@localhost>
date:      Fri Jan 21 02:43:33 2005 +0000

description:
Implement "rpc"

diffstat:

 usr.bin/getent/getent.1 |   4 +++-
 usr.bin/getent/getent.c |  48 ++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 49 insertions(+), 3 deletions(-)

diffs (115 lines):

diff -r f60dff233372 -r c97dd528f9e0 usr.bin/getent/getent.1
--- a/usr.bin/getent/getent.1   Fri Jan 21 00:58:34 2005 +0000
+++ b/usr.bin/getent/getent.1   Fri Jan 21 02:43:33 2005 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: getent.1,v 1.8 2004/12/03 23:05:32 lukem Exp $
+.\"    $NetBSD: getent.1,v 1.9 2005/01/21 02:43:33 ginsbach Exp $
 .\"
 .\" Copyright (c) 2004 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -67,6 +67,7 @@
 .It networks Ta name network [alias ...]
 .It passwd Ta user:passwd:uid:gid:gecos:home_dir_shell
 .It protocols Ta name protocol [alias ...]
+.It rpc Ta name number [alias ...]
 .It services Ta name port/protocol [alias ...]
 .It shells Ta /path/to/shell
 .El
@@ -105,6 +106,7 @@
 .Xr nsswitch.conf 5 ,
 .Xr passwd 5 ,
 .Xr protocols 5 ,
+.Xr rpc 5 ,
 .Xr services 5 ,
 .Xr shells 5
 .Sh HISTORY
diff -r f60dff233372 -r c97dd528f9e0 usr.bin/getent/getent.c
--- a/usr.bin/getent/getent.c   Fri Jan 21 00:58:34 2005 +0000
+++ b/usr.bin/getent/getent.c   Fri Jan 21 02:43:33 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getent.c,v 1.5 2004/11/29 05:02:40 lukem Exp $ */
+/*     $NetBSD: getent.c,v 1.6 2005/01/21 02:43:33 ginsbach Exp $      */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: getent.c,v 1.5 2004/11/29 05:02:40 lukem Exp $");
+__RCSID("$NetBSD: getent.c,v 1.6 2005/01/21 02:43:33 ginsbach Exp $");
 #endif /* not lint */
 
 #include <sys/socket.h>
@@ -61,6 +61,8 @@
 
 #include <netinet/in.h>                /* for INET6_ADDRSTRLEN */
 
+#include <rpc/rpcent.h>
+
 static int     usage(void);
 static int     parsenum(const char *, unsigned long *);
 static int     group(int, char *[]);
@@ -68,6 +70,7 @@
 static int     networks(int, char *[]);
 static int     passwd(int, char *[]);
 static int     protocols(int, char *[]);
+static int     rpc(int, char *[]);
 static int     services(int, char *[]);
 static int     shells(int, char *[]);
 
@@ -87,6 +90,7 @@
        {       "networks",     networks,       },
        {       "passwd",       passwd,         },
        {       "protocols",    protocols,      },
+       {       "rpc",          rpc,            },
        {       "services",     services,       },
        {       "shells",       shells,         },
 
@@ -404,6 +408,46 @@
        return rv;
 }
 
+               /*
+                * rpc
+                */
+
+static int
+rpc(int argc, char *argv[])
+{
+       struct rpcent   *re;
+       unsigned long   id;
+       int             i, rv;
+       
+       assert(argc > 1);
+       assert(argv != NULL);
+
+#define RPCPRINT       printfmtstrings(re->r_aliases, "  ", " ", \
+                               "%-16s  %6d", \
+                               re->r_name, re->r_number)
+
+       setrpcent(1);
+       rv = RV_OK;
+       if (argc == 2) {
+               while ((re = getrpcent()) != NULL)
+                       RPCPRINT;
+       } else {
+               for (i = 2; i < argc; i++) {
+                       if (parsenum(argv[i], &id))
+                               re = getrpcbynumber((int)id);
+                       else
+                               re = getrpcbyname(argv[i]);
+                       if (re != NULL)
+                               RPCPRINT;
+                       else {
+                               rv = RV_NOTFOUND;
+                               break;
+                       }
+               }
+       }
+       endrpcent();
+       return rv;
+}
 
                /*
                 * services



Home | Main Index | Thread Index | Old Index