aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/ypcat
diff options
context:
space:
mode:
authorPhilippe Charnier <charnier@FreeBSD.org>1997-08-29 11:48:50 +0000
committerPhilippe Charnier <charnier@FreeBSD.org>1997-08-29 11:48:50 +0000
commitc1f84cc1290e2c11ae2ba11f4915346821c4f0c7 (patch)
treea5a0c282134c3923fff65e1774fc5a601800f9cb /usr.bin/ypcat
parent5d7128668c3d8eff32101e95a60f6bd5deffda49 (diff)
downloadsrc-c1f84cc1290e2c11ae2ba11f4915346821c4f0c7.tar.gz
src-c1f84cc1290e2c11ae2ba11f4915346821c4f0c7.zip
Use err(3). Add references to others man pages. Wait for the user to
supply the domain before computing a default one. Obtained from: OpenBSD
Notes
Notes: svn path=/head/; revision=28893
Diffstat (limited to 'usr.bin/ypcat')
-rw-r--r--usr.bin/ypcat/ypcat.19
-rw-r--r--usr.bin/ypcat/ypcat.c34
2 files changed, 24 insertions, 19 deletions
diff --git a/usr.bin/ypcat/ypcat.1 b/usr.bin/ypcat/ypcat.1
index 9b31994fe16f..d0f380031bc3 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 fdefa4341da1..2604115a3881 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);
}