From 3eff8361b9f9e2ce7cdd58f63a418ed9cb9142ce Mon Sep 17 00:00:00 2001 From: Philippe Charnier Date: Fri, 29 Aug 1997 11:52:52 +0000 Subject: [PATCH] Use err(3). Add Xreferences. Delay the compute of default domain. Obtained from: OpenBSD --- usr.bin/ypmatch/ypmatch.1 | 9 ++++++--- usr.bin/ypmatch/ypmatch.c | 38 +++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/usr.bin/ypmatch/ypmatch.1 b/usr.bin/ypmatch/ypmatch.1 index 4dfbebdddc33..27fa8464c644 100644 --- a/usr.bin/ypmatch/ypmatch.1 +++ b/usr.bin/ypmatch/ypmatch.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: ypmatch.1,v 1.5 1997/02/22 19:58:12 peter Exp $ .\" .Dd December 3, 1993 .Dt YPMATCH 1 @@ -65,7 +65,10 @@ to their corresponding map names. Display the map nickname table. .El .Sh SEE ALSO +.Xr domainname 1 , .Xr ypcat 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/ypmatch/ypmatch.c b/usr.bin/ypmatch/ypmatch.c index 0923ba8da746..1e71f8cc805a 100644 --- a/usr.bin/ypmatch/ypmatch.c +++ b/usr.bin/ypmatch/ypmatch.c @@ -27,15 +27,18 @@ * SUCH DAMAGE. */ -#ifndef LINT -static char rcsid[] = "ypmatch.c,v 1.2 1993/05/16 02:49:03 deraadt Exp"; -#endif +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include #include #include -#include #include +#include +#include +#include #include #include @@ -56,16 +59,12 @@ struct ypalias { { "ethers", "ethers.byname" }, }; +static void usage() { - fprintf(stderr, "Usage:\n"); - fprintf(stderr, "\typmatch [-d domain] [-t] [-k] key [key ...] mname\n"); - fprintf(stderr, "\typmatch -x\n"); - fprintf(stderr, "where\n"); - fprintf(stderr, "\tmname may be either a mapname or a nickname for a map\n"); - fprintf(stderr, "\t-t inhibits map nickname translation\n"); - fprintf(stderr, "\t-k prints keys as well as values.\n"); - fprintf(stderr, "\t-x dumps the map nickname translation table.\n"); + fprintf(stderr, "%s\n%s\n", + "usage: ypmatch [-d domain] [-t] [-k] key [key ...] mname", + " ypmatch -x"); exit(1); } @@ -73,15 +72,12 @@ int main(argc, argv) char **argv; { - char *domainname; + char *domainname = NULL; char *inkey, *inmap, *outbuf; - extern char *optarg; - extern int optind; int outbuflen, key, notrans; int c, r, i; notrans = key = 0; - yp_get_default_domain(&domainname); while( (c=getopt(argc, argv, "xd:kt")) != -1) switch(c) { @@ -107,6 +103,9 @@ char **argv; if( (argc-optind) < 2 ) usage(); + if (!domainname) + yp_get_default_domain(&domainname); + inmap = argv[argc-1]; for(i=0; (!notrans) && i