ypcat.c (87672) | ypcat.c (90297) |
---|---|
1/* 2 * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> 31 | 1/* 2 * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> 31 |
32__FBSDID("$FreeBSD: head/usr.bin/ypcat/ypcat.c 87672 2001-12-11 22:08:58Z markm $"); | 32__FBSDID("$FreeBSD: head/usr.bin/ypcat/ypcat.c 90297 2002-02-06 13:30:31Z des $"); |
33 34#include <sys/param.h> 35#include <sys/types.h> 36#include <sys/socket.h> 37 38#include <rpc/rpc.h> 39#include <rpc/xdr.h> 40#include <rpcsvc/yp_prot.h> --- 29 unchanged lines hidden (view full) --- 70 "usage: ypcat [-k] [-d domainname] [-t] mapname", 71 " ypcat -x"); 72 exit(1); 73} 74 75static int 76printit(unsigned long instatus, char *inkey, int inkeylen, char *inval, int invallen, void *dummy __unused) 77{ | 33 34#include <sys/param.h> 35#include <sys/types.h> 36#include <sys/socket.h> 37 38#include <rpc/rpc.h> 39#include <rpc/xdr.h> 40#include <rpcsvc/yp_prot.h> --- 29 unchanged lines hidden (view full) --- 70 "usage: ypcat [-k] [-d domainname] [-t] mapname", 71 " ypcat -x"); 72 exit(1); 73} 74 75static int 76printit(unsigned long instatus, char *inkey, int inkeylen, char *inval, int invallen, void *dummy __unused) 77{ |
78 if(instatus != YP_TRUE) 79 return instatus; 80 if(key) | 78 if (instatus != YP_TRUE) 79 return (instatus); 80 if (key) |
81 printf("%*.*s ", inkeylen, inkeylen, inkey); 82 printf("%*.*s\n", invallen, invallen, inval); | 81 printf("%*.*s ", inkeylen, inkeylen, inkey); 82 printf("%*.*s\n", invallen, invallen, inval); |
83 return 0; | 83 return (0); |
84} 85 86int 87main(int argc, char *argv[]) 88{ 89 char *domainname = NULL; 90 struct ypall_callback ypcb; 91 char *inmap; 92 int notrans; 93 int c, r; 94 u_int i; 95 96 notrans = key = 0; 97 | 84} 85 86int 87main(int argc, char *argv[]) 88{ 89 char *domainname = NULL; 90 struct ypall_callback ypcb; 91 char *inmap; 92 int notrans; 93 int c, r; 94 u_int i; 95 96 notrans = key = 0; 97 |
98 while( (c=getopt(argc, argv, "xd:kt")) != -1) 99 switch(c) { | 98 while ((c = getopt(argc, argv, "xd:kt")) != -1) 99 switch (c) { |
100 case 'x': | 100 case 'x': |
101 for(i=0; i<sizeof ypaliases/sizeof ypaliases[0]; i++) | 101 for (i = 0; i<sizeof ypaliases/sizeof ypaliases[0]; i++) |
102 printf("Use \"%s\" for \"%s\"\n", 103 ypaliases[i].alias, 104 ypaliases[i].name); 105 exit(0); 106 case 'd': 107 domainname = optarg; 108 break; 109 case 't': 110 notrans++; 111 break; 112 case 'k': 113 key++; 114 break; 115 default: 116 usage(); 117 } 118 | 102 printf("Use \"%s\" for \"%s\"\n", 103 ypaliases[i].alias, 104 ypaliases[i].name); 105 exit(0); 106 case 'd': 107 domainname = optarg; 108 break; 109 case 't': 110 notrans++; 111 break; 112 case 'k': 113 key++; 114 break; 115 default: 116 usage(); 117 } 118 |
119 if(optind + 1 != argc ) | 119 if (optind + 1 != argc) |
120 usage(); 121 122 if (!domainname) 123 yp_get_default_domain(&domainname); 124 125 inmap = argv[optind]; | 120 usage(); 121 122 if (!domainname) 123 yp_get_default_domain(&domainname); 124 125 inmap = argv[optind]; |
126 for(i=0; (!notrans) && i<sizeof ypaliases/sizeof ypaliases[0]; i++) 127 if( strcmp(inmap, ypaliases[i].alias) == 0) | 126 for (i = 0; (!notrans) && i<sizeof ypaliases/sizeof ypaliases[0]; i++) 127 if (strcmp(inmap, ypaliases[i].alias) == 0) |
128 inmap = ypaliases[i].name; 129 ypcb.foreach = printit; 130 ypcb.data = NULL; 131 132 r = yp_all(domainname, inmap, &ypcb); | 128 inmap = ypaliases[i].name; 129 ypcb.foreach = printit; 130 ypcb.data = NULL; 131 132 r = yp_all(domainname, inmap, &ypcb); |
133 switch(r) { | 133 switch (r) { |
134 case 0: 135 break; 136 case YPERR_YPBIND: 137 errx(1, "not running ypbind"); 138 default: 139 errx(1, "no such map %s. reason: %s", inmap, yperr_string(r)); 140 } 141 exit(0); 142} | 134 case 0: 135 break; 136 case YPERR_YPBIND: 137 errx(1, "not running ypbind"); 138 default: 139 errx(1, "no such map %s. reason: %s", inmap, yperr_string(r)); 140 } 141 exit(0); 142} |