From c1f84cc1290e2c11ae2ba11f4915346821c4f0c7 Mon Sep 17 00:00:00 2001 From: Philippe Charnier Date: Fri, 29 Aug 1997 11:48:50 +0000 Subject: [PATCH] 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 --- usr.bin/ypcat/ypcat.1 | 9 ++++++--- usr.bin/ypcat/ypcat.c | 34 ++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/usr.bin/ypcat/ypcat.1 b/usr.bin/ypcat/ypcat.1 index 9b31994fe16..d0f380031bc 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 fdefa4341da..2604115a388 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 #include #include -#include #include +#include +#include +#include #include #include @@ -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