Index: usr.bin/ypcat/ypcat.c =================================================================== --- usr.bin/ypcat/ypcat.c +++ usr.bin/ypcat/ypcat.c @@ -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 + * Copyright (c) 1992, 1993, 1996 Theo de Raadt * 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 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include -#include +#include #include -#include -#include -#include -#include -#include -#include +void usage(void); +int printit(u_long, char *, int, char *, int, void *); static const struct ypalias { char *alias, *name; @@ -64,80 +65,84 @@ 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); + return instatus; if (key) printf("%*.*s ", inkeylen, inkeylen, inkey); printf("%*.*s\n", invallen, invallen, inval); - return (0); + return 0; } 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