=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ypwhich/ypwhich.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- src/usr.bin/ypwhich/ypwhich.c 1999/03/19 22:21:27 1.10 +++ src/usr.bin/ypwhich/ypwhich.c 1999/03/20 15:36:12 1.11 @@ -1,4 +1,4 @@ -/* $OpenBSD: ypwhich.c,v 1.10 1999/03/19 22:21:27 deraadt Exp $ */ +/* $OpenBSD: ypwhich.c,v 1.11 1999/03/20 15:36:12 maja Exp $ */ /* $NetBSD: ypwhich.c,v 1.6 1996/05/13 02:43:48 thorpej Exp $ */ /* @@ -34,7 +34,7 @@ */ #ifndef LINT -static char rcsid[] = "$Id: ypwhich.c,v 1.10 1999/03/19 22:21:27 deraadt Exp $"; +static char rcsid[] = "$Id: ypwhich.c,v 1.11 1999/03/20 15:36:12 maja Exp $"; #endif #include @@ -57,6 +57,8 @@ #include #include +#include "yplib_host.h" + struct ypalias { char *alias, *name; } ypaliases[] = { @@ -74,7 +76,7 @@ usage() { fprintf(stderr, "Usage:\n"); - fprintf(stderr, "\typwhich [-d domain] [[-t] -m [mname] | host]\n"); + fprintf(stderr, "\typwhich [-d domain] [[-h host] [-t] -m [mname] | host]\n"); fprintf(stderr, "\typwhich -x\n"); exit(1); } @@ -149,6 +151,8 @@ struct sockaddr_in sin; int notrans, mode, getmap; int c, r, i; + CLIENT *client; + char *host = NULL; map = NULL; getmap = notrans = mode = 0; @@ -157,13 +161,16 @@ if (domain == NULL) errx(1, "YP domain name not set"); - while ((c = getopt(argc, argv, "xd:mt")) != -1) + while ((c = getopt(argc, argv, "xd:h:mt")) != -1) switch(c) { case 'x': for (i=0; i 1) usage(); + if (host != NULL) { + client = yp_bind_host(host,YPPROG,YPVERS,0,1); + } + if (argv[0]) { map = argv[0]; for (i=0; (!notrans) && imap, &master); + if (host != NULL) { + r = yp_master_host(client, + domain, ypml->map, &master); + } else { + r = yp_master(domain, ypml->map, &master); + } switch(r) { case 0: printf("%s %s\n", ypml->map, master);