diff options
-rw-r--r-- | usr.bin/ypcat/ypcat.1 | 9 | ||||
-rw-r--r-- | usr.bin/ypcat/ypcat.c | 34 |
2 files changed, 24 insertions, 19 deletions
diff --git a/usr.bin/ypcat/ypcat.1 b/usr.bin/ypcat/ypcat.1 index 9b31994..d0f3800 100644 --- a/usr.bin/ypcat/ypcat.1 +++ b/usr.bin/ypcat/ypcat.1 @@ -26,7 +26,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $Id$ +.\" $Id: ypcat.1,v 1.5 1997/02/22 19:58:10 peter Exp $ .\" .Dd December 3, 1993 .Dt YPCAT 1 @@ -64,7 +64,10 @@ to their corresponding map names. Display the map nickname table. .El .Sh SEE ALSO +.Xr domainname 1 , .Xr ypmatch 1 , -.Xr yp 4 +.Xr yp 4 , +.Xr ypbind 8 , +.Xr ypset 8 .Sh AUTHOR -Theo De Raadt +.An Theo De Raadt Aq deraadt@theos.com . diff --git a/usr.bin/ypcat/ypcat.c b/usr.bin/ypcat/ypcat.c index fdefa43..2604115 100644 --- a/usr.bin/ypcat/ypcat.c +++ b/usr.bin/ypcat/ypcat.c @@ -27,15 +27,18 @@ * SUCH DAMAGE. */ -#ifndef LINT -static char rcsid[] = "ypcat.c,v 1.2 1993/05/16 02:49:01 deraadt Exp"; -#endif +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> -#include <stdio.h> #include <ctype.h> +#include <err.h> +#include <stdio.h> +#include <unistd.h> #include <rpc/rpc.h> #include <rpc/xdr.h> @@ -58,14 +61,16 @@ struct ypalias { int key; +static void usage() { - fprintf(stderr, "Usage:\n"); - fprintf(stderr, "\typcat [-k] [-d domainname] [-t] mapname\n"); - fprintf(stderr, "\typcat -x\n"); + fprintf(stderr, "%s\n%s\n", + "usage: ypcat [-k] [-d domainname] [-t] mapname", + " ypcat -x"); exit(1); } +int printit(instatus, inkey, inkeylen, inval, invallen, indata) int instatus; char *inkey; @@ -86,16 +91,13 @@ int main(argc, argv) char **argv; { - char *domainname; + char *domainname = NULL; struct ypall_callback ypcb; char *inmap; - extern char *optarg; - extern int optind; int notrans; int c, r, i; notrans = key = 0; - yp_get_default_domain(&domainname); while( (c=getopt(argc, argv, "xd:kt")) != -1) switch(c) { @@ -121,6 +123,9 @@ char **argv; if(optind + 1 != argc ) usage(); + if (!domainname) + yp_get_default_domain(&domainname); + inmap = argv[optind]; for(i=0; (!notrans) && i<sizeof ypaliases/sizeof ypaliases[0]; i++) if( strcmp(inmap, ypaliases[i].alias) == 0) @@ -133,12 +138,9 @@ char **argv; case 0: break; case YPERR_YPBIND: - fprintf(stderr, "ypcat: not running ypbind\n"); - exit(1); + errx(1, "not running ypbind"); default: - fprintf(stderr, "No such map %s. Reason: %s\n", - inmap, yperr_string(r)); - exit(1); + errx(1, "no such map %s. reason: %s", inmap, yperr_string(r)); } exit(0); } |