summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-08-29 11:52:52 +0000
committercharnier <charnier@FreeBSD.org>1997-08-29 11:52:52 +0000
commite94e60b6cd96fdcc544276ff5a193ae0d49dca3b (patch)
treedf900e6bcf5b795c3f77b57b56f26677091acbd1 /usr.bin
parentc1711414d341d04f19f6fa4573f8f057709c6ba0 (diff)
downloadFreeBSD-src-e94e60b6cd96fdcc544276ff5a193ae0d49dca3b.zip
FreeBSD-src-e94e60b6cd96fdcc544276ff5a193ae0d49dca3b.tar.gz
Use err(3). Add Xreferences. Delay the compute of default domain.
Obtained from: OpenBSD
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ypmatch/ypmatch.19
-rw-r--r--usr.bin/ypmatch/ypmatch.c38
2 files changed, 23 insertions, 24 deletions
diff --git a/usr.bin/ypmatch/ypmatch.1 b/usr.bin/ypmatch/ypmatch.1
index 4dfbebd..27fa846 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 0923ba8..1e71f8c 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 <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>
@@ -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<sizeof ypaliases/sizeof ypaliases[0]; i++)
if( strcmp(inmap, ypaliases[i].alias) == 0)
@@ -123,13 +122,10 @@ char **argv;
printf("%*.*s\n", outbuflen, outbuflen, outbuf);
break;
case YPERR_YPBIND:
- fprintf(stderr, "yp_match: not running ypbind\n");
- exit(1);
+ errx(1, "not running ypbind");
default:
- fprintf(stderr, "Can't match key %s in map %s. Reason: %s\n",
+ errx(1, "can't match key %s in map %s. reason: %s",
inkey, inmap, yperr_string(r));
- exit(1);
- break;
}
}
exit(0);
OpenPOWER on IntegriCloud