diff --git a/usr.bin/ypmatch/ypmatch.c b/usr.bin/ypmatch/ypmatch.c index ff4253fbaf0c..66fa84aae100 100644 --- a/usr.bin/ypmatch/ypmatch.c +++ b/usr.bin/ypmatch/ypmatch.c @@ -1,5 +1,8 @@ +/* $OpenBSD: ypmatch.c,v 1.16 2015/02/08 23:40:35 deraadt Exp $ */ +/* $NetBSD: ypmatch.c,v 1.8 1996/05/07 01:24:52 jtc Exp $ */ + /* - * Copyright (c) 1992/3 Theo de Raadt + * Copyright (c) 1992, 1993, 1996 Theo de Raadt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -10,9 +13,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -34,18 +34,19 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include -#include +void usage(void); static const struct ypalias { char *alias, *name; @@ -62,30 +63,37 @@ static const struct ypalias { { "ethers", "ethers.byname" }, }; -static void +void usage(void) { - fprintf(stderr, "%s\n%s\n", - "usage: ypmatch [-kt] [-d domainname] key ... mapname", - " ypmatch -x"); + fprintf(stderr, + "usage: ypmatch [-kt] [-d domain] key ... mapname\n" + " ypmatch -x\n"); + fprintf(stderr, + "where\n" + "\tmapname may be either a mapname or a nickname for a map.\n" + "\t-k prints keys as well as values.\n" + "\t-t inhibits map nickname translation.\n" + "\t-x dumps the map nickname translation table.\n"); exit(1); } int main(int argc, char *argv[]) { - char *domainname = NULL; - char *inkey, *inmap, *outbuf; - int outbuflen, key, notrans; + char *domainname, *inkey, *inmap, *outbuf; + extern char *optarg; + extern int optind; + int outbuflen, key, notrans, rval; int c, r; u_int i; + domainname = NULL; notrans = key = 0; - - while ((c = getopt(argc, argv, "xd:kt")) != -1) + while ((c=getopt(argc, argv, "xd:kt")) != -1) switch (c) { case 'x': - for (i = 0; i