Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147805582
D3212.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D3212.id.diff
View Options
Index: head/usr.bin/ypcat/ypcat.c
===================================================================
--- head/usr.bin/ypcat/ypcat.c
+++ head/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 <deraadt@fsa.ca>
+ * Copyright (c) 1992, 1993, 1996 Theo de Raadt <deraadt@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 @@
#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 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 @@
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 @@
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);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 14, 7:32 PM (5 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29681829
Default Alt Text
D3212.id.diff (3 KB)
Attached To
Mode
D3212: Sync ypcat source code with OpenBSD version.
Attached
Detach File
Event Timeline
Log In to Comment