Deleted Added
full compact
gethostbynis.c (17141) gethostbynis.c (17903)
1/*-
2 * Copyright (c) 1994, Garrett Wollman
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#if defined(LIBC_SCCS) && !defined(lint)
1/*-
2 * Copyright (c) 1994, Garrett Wollman
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#if defined(LIBC_SCCS) && !defined(lint)
27static char sccsid[] = "@(#)$Id: gethostbynis.c,v 1.2 1996/03/16 21:25:58 wpaul Exp $";
28static char rcsid[] = "$Id: gethostbynis.c,v 1.2 1996/03/16 21:25:58 wpaul Exp $";
27static char sccsid[] = "@(#)$Id: gethostbynis.c,v 1.3 1996/07/12 18:54:35 jkh Exp $";
28static char rcsid[] = "$Id: gethostbynis.c,v 1.3 1996/07/12 18:54:35 jkh Exp $";
29#endif /* LIBC_SCCS and not lint */
30
31#include <sys/param.h>
32#include <sys/socket.h>
33#include <netinet/in.h>
34#include <arpa/inet.h>
35#include <netdb.h>
36#include <stdio.h>

--- 12 unchanged lines hidden (view full) ---

49
50#ifdef YP
51static char *host_aliases[MAXALIASES];
52static char hostaddr[MAXADDRS];
53static char *host_addrs[2];
54#endif /* YP */
55
56static struct hostent *
29#endif /* LIBC_SCCS and not lint */
30
31#include <sys/param.h>
32#include <sys/socket.h>
33#include <netinet/in.h>
34#include <arpa/inet.h>
35#include <netdb.h>
36#include <stdio.h>

--- 12 unchanged lines hidden (view full) ---

49
50#ifdef YP
51static char *host_aliases[MAXALIASES];
52static char hostaddr[MAXADDRS];
53static char *host_addrs[2];
54#endif /* YP */
55
56static struct hostent *
57_gethostbynis(name, map)
58 char *name, *map;
57_gethostbynis(name, map, af)
58 const char *name;
59 char *map;
60 int af;
59{
60#ifdef YP
61 register char *cp, **q;
62 char *result;
63 int resultlen;
64 static struct hostent h;
65 static char *domain = (char *)NULL;
66 static char ypbuf[YPMAXRECORD];
67
61{
62#ifdef YP
63 register char *cp, **q;
64 char *result;
65 int resultlen;
66 static struct hostent h;
67 static char *domain = (char *)NULL;
68 static char ypbuf[YPMAXRECORD];
69
70 switch(af) {
71 case AF_INET:
72 break;
73 default:
74 case AF_INET6:
75 errno = EAFNOSUPPORT;
76 return NULL;
77 }
78
68 if (domain == (char *)NULL)
69 if (yp_get_default_domain (&domain))
70 return ((struct hostent *)NULL);
71
72 if (yp_match(domain, map, name, strlen(name), &result, &resultlen))
73 return ((struct hostent *)NULL);
74
75 /* avoid potential memory leak */

--- 32 unchanged lines hidden (view full) ---

108 *q = NULL;
109 return (&h);
110#else
111 return (NULL);
112#endif /* YP */
113}
114
115struct hostent *
79 if (domain == (char *)NULL)
80 if (yp_get_default_domain (&domain))
81 return ((struct hostent *)NULL);
82
83 if (yp_match(domain, map, name, strlen(name), &result, &resultlen))
84 return ((struct hostent *)NULL);
85
86 /* avoid potential memory leak */

--- 32 unchanged lines hidden (view full) ---

119 *q = NULL;
120 return (&h);
121#else
122 return (NULL);
123#endif /* YP */
124}
125
126struct hostent *
116_gethostbynisname(name)
117 char *name;
127_gethostbynisname(name, af)
128 const char *name;
129 int af;
118{
130{
119 return _gethostbynis(name, "hosts.byname");
131 return _gethostbynis(name, "hosts.byname", af);
120}
121
122struct hostent *
132}
133
134struct hostent *
123_gethostbynisaddr(addr, len, type)
124 char *addr;
135_gethostbynisaddr(addr, len, af)
136 const char *addr;
125 int len;
137 int len;
126 int type;
138 int af;
127{
139{
128 return _gethostbynis(inet_ntoa(*(struct in_addr *)addr),"hosts.byaddr");
140 return _gethostbynis(inet_ntoa(*(struct in_addr *)addr),"hosts.byaddr", af);
129}
141}