ypxfr_misc.c (90297) | ypxfr_misc.c (90298) |
---|---|
1/* 2 * Copyright (c) 1995 3 * Bill Paul <wpaul@ctr.columbia.edu>. 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 --- 18 unchanged lines hidden (view full) --- 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#ifndef lint 34static const char rcsid[] = | 1/* 2 * Copyright (c) 1995 3 * Bill Paul <wpaul@ctr.columbia.edu>. 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 --- 18 unchanged lines hidden (view full) --- 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#ifndef lint 34static const char rcsid[] = |
35 "$FreeBSD: head/libexec/ypxfr/ypxfr_misc.c 90297 2002-02-06 13:30:31Z des $"; | 35 "$FreeBSD: head/libexec/ypxfr/ypxfr_misc.c 90298 2002-02-06 15:26:07Z des $"; |
36#endif /* not lint */ 37 38#include <stdio.h> 39#include <string.h> 40#include <stdlib.h> 41#include <unistd.h> 42#include <sys/param.h> 43#include <rpc/rpc.h> 44#include <rpcsvc/yp.h> 45struct dom_binding {}; 46#include <rpcsvc/ypclnt.h> 47#include "ypxfr_extern.h" 48 | 36#endif /* not lint */ 37 38#include <stdio.h> 39#include <string.h> 40#include <stdlib.h> 41#include <unistd.h> 42#include <sys/param.h> 43#include <rpc/rpc.h> 44#include <rpcsvc/yp.h> 45struct dom_binding {}; 46#include <rpcsvc/ypclnt.h> 47#include "ypxfr_extern.h" 48 |
49char *ypxfrerr_string(code) 50 ypxfrstat code; | 49char * 50ypxfrerr_string(ypxfrstat code) |
51{ 52 switch (code) { 53 case YPXFR_SUCC: 54 return ("Map successfully transferred"); 55 break; 56 case YPXFR_AGE: 57 return ("Master's version not newer"); 58 break; --- 56 unchanged lines hidden (view full) --- 115 116/* 117 * Careful: yp_master() returns a pointer to a dynamically allocated 118 * buffer. Calling ypproc_master_2() ourselves also returns a pointer 119 * to dynamically allocated memory, though this time it's memory 120 * allocated by the XDR routines. We have to rememver to free() or 121 * xdr_free() the memory as required to avoid leaking memory. 122 */ | 51{ 52 switch (code) { 53 case YPXFR_SUCC: 54 return ("Map successfully transferred"); 55 break; 56 case YPXFR_AGE: 57 return ("Master's version not newer"); 58 break; --- 56 unchanged lines hidden (view full) --- 115 116/* 117 * Careful: yp_master() returns a pointer to a dynamically allocated 118 * buffer. Calling ypproc_master_2() ourselves also returns a pointer 119 * to dynamically allocated memory, though this time it's memory 120 * allocated by the XDR routines. We have to rememver to free() or 121 * xdr_free() the memory as required to avoid leaking memory. 122 */ |
123char *ypxfr_get_master(domain,map,source,yplib) 124 char *domain; 125 char *map; 126 char *source; 127 const int yplib; | 123char * 124ypxfr_get_master(char *domain, char *map, char *source, const int yplib) |
128{ 129 static char mastername[MAXPATHLEN + 2]; 130 131 bzero((char *)&mastername, sizeof(mastername)); 132 133 if (yplib) { 134 int res; 135 char *master; --- 54 unchanged lines hidden (view full) --- 190 return(NULL); 191 } 192 snprintf(mastername, sizeof(mastername), "%s", resp->peer); 193/* xdr_free(xdr_ypresp_master, (char *)&resp); */ 194 return((char *)&mastername); 195 } 196} 197 | 125{ 126 static char mastername[MAXPATHLEN + 2]; 127 128 bzero((char *)&mastername, sizeof(mastername)); 129 130 if (yplib) { 131 int res; 132 char *master; --- 54 unchanged lines hidden (view full) --- 187 return(NULL); 188 } 189 snprintf(mastername, sizeof(mastername), "%s", resp->peer); 190/* xdr_free(xdr_ypresp_master, (char *)&resp); */ 191 return((char *)&mastername); 192 } 193} 194 |
198unsigned long ypxfr_get_order(domain, map, source, yplib) 199 char *domain; 200 char *map; 201 char *source; 202 const int yplib; | 195unsigned long 196ypxfr_get_order(char *domain, char *map, char *source, const int yplib) |
203{ 204 if (yplib) { 205 unsigned long order; 206 int res; 207 if ((res = yp_order(domain, map, (int *)&order))) { 208 switch (res) { 209 case YPERR_DOMAIN: 210 yp_errno = YPXFR_NODOM; --- 44 unchanged lines hidden (view full) --- 255 break; 256 } 257 return(0); 258 } 259 return(resp->ordernum); 260 } 261} 262 | 197{ 198 if (yplib) { 199 unsigned long order; 200 int res; 201 if ((res = yp_order(domain, map, (int *)&order))) { 202 switch (res) { 203 case YPERR_DOMAIN: 204 yp_errno = YPXFR_NODOM; --- 44 unchanged lines hidden (view full) --- 249 break; 250 } 251 return(0); 252 } 253 return(resp->ordernum); 254 } 255} 256 |
263int ypxfr_match(server, domain, map, key, keylen) 264 char *server; 265 char *domain; 266 char *map; 267 char *key; 268 unsigned long keylen; | 257int 258ypxfr_match(char *server, char *domain, char *map, char *key, 259 unsigned long keylen) |
269{ 270 ypreq_key ypkey; 271 ypresp_val *ypval; 272 CLIENT *clnt; 273 static char buf[YPMAXRECORD + 2]; 274 275 bzero((char *)buf, sizeof(buf)); 276 --- 29 unchanged lines hidden --- | 260{ 261 ypreq_key ypkey; 262 ypresp_val *ypval; 263 CLIENT *clnt; 264 static char buf[YPMAXRECORD + 2]; 265 266 bzero((char *)buf, sizeof(buf)); 267 --- 29 unchanged lines hidden --- |