Author: araujo (ports committer) Date: Tue Aug 4 02:41:14 2015 New Revision: 286267 URL: https://svnweb.freebsd.org/changeset/base/286267
Log: Remove the 3rd clause of BSD LICENSE. Sync the code with the OpenBSD version. Small style(9) fix up. Differential Revision: D3212 Reviewed by: rodrigc, bapt Obtained from: OpenBSD Sponsored by: gandi.net Modified: head/usr.bin/ypcat/ypcat.c Modified: head/usr.bin/ypcat/ypcat.c ============================================================================== --- head/usr.bin/ypcat/ypcat.c Tue Aug 4 02:34:51 2015 (r286266) +++ head/usr.bin/ypcat/ypcat.c Tue Aug 4 02:41:14 2015 (r286267) @@ -1,5 +1,7 @@ +/* $OpenBSD: ypcat.c,v 1.16 2015/02/08 23:40:35 deraadt Exp $ */ + /* - * Copyright (c) 1992/3 Theo de Raadt <dera...@fsa.ca> + * Copyright (c) 1992, 1993, 1996 Theo de Raadt <dera...@theos.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -10,9 +12,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 +33,20 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/types.h> #include <sys/socket.h> +#include <unistd.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <ctype.h> +#include <err.h> #include <rpc/rpc.h> #include <rpc/xdr.h> -#include <rpcsvc/yp_prot.h> +#include <rpcsvc/yp.h> #include <rpcsvc/ypclnt.h> -#include <ctype.h> -#include <err.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> +void usage(void); +int printit(u_long, char *, int, char *, int, void *); static const struct ypalias { char *alias, *name; @@ -64,17 +65,18 @@ static const struct ypalias { static int key; -static void +void usage(void) { - fprintf(stderr, "%s\n%s\n", - "usage: ypcat [-kt] [-d domainname] mapname", - " ypcat -x"); + fprintf(stderr, + "usage: ypcat [-kt] [-d domainname] mapname\n" + " ypcat -x\n"); exit(1); } -static int -printit(unsigned long instatus, char *inkey, int inkeylen, char *inval, int invallen, void *dummy __unused) +int +printit(u_long instatus, char *inkey, int inkeylen, char *inval, int invallen, + void *indata) { if (instatus != YP_TRUE) return (instatus); @@ -87,31 +89,29 @@ printit(unsigned long instatus, char *in int main(int argc, char *argv[]) { - char *domainname = NULL; + char *domain = NULL, *inmap; struct ypall_callback ypcb; - char *inmap; - int notrans; - int c, r; + extern char *optarg; + extern int optind; + int notrans, c, r; u_int i; notrans = key = 0; - while ((c = getopt(argc, argv, "xd:kt")) != -1) switch (c) { case 'x': - for (i = 0; i<sizeof ypaliases/sizeof ypaliases[0]; i++) + for (i=0; i<sizeof ypaliases/sizeof ypaliases[0]; i++) printf("Use \"%s\" for \"%s\"\n", - ypaliases[i].alias, - ypaliases[i].name); + ypaliases[i].alias, ypaliases[i].name); exit(0); case 'd': - domainname = optarg; + domain = optarg; break; case 't': - notrans++; + notrans = 1; break; case 'k': - key++; + key = 1; break; default: usage(); @@ -120,24 +120,29 @@ main(int argc, char *argv[]) if (optind + 1 != argc) usage(); - if (!domainname) - yp_get_default_domain(&domainname); + if (!domain) + yp_get_default_domain(&domain); inmap = argv[optind]; - for (i = 0; (!notrans) && i<sizeof ypaliases/sizeof ypaliases[0]; i++) - if (strcmp(inmap, ypaliases[i].alias) == 0) - inmap = ypaliases[i].name; + if (!notrans) { + for (i=0; i<sizeof ypaliases/sizeof ypaliases[0]; i++) + if (strcmp(inmap, ypaliases[i].alias) == 0) + inmap = ypaliases[i].name; + } ypcb.foreach = printit; ypcb.data = NULL; - r = yp_all(domainname, inmap, &ypcb); + r = yp_all(domain, inmap, &ypcb); switch (r) { case 0: break; case YPERR_YPBIND: - errx(1, "not running ypbind"); + errx(1, "ypcat: not running ypbind\n"); + exit(1); default: - errx(1, "no such map %s. reason: %s", inmap, yperr_string(r)); + errx(1, "No such map %s. Reason: %s\n", + inmap, yperr_string(r)); + exit(1); } exit(0); } _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"