From af9cfbc64363b61aa5903dd916e9fbc152084d4c Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 3 Feb 2000 21:54:10 +0000 Subject: [PATCH] move reference implementations into lwres_ namespace. --- lib/lwres/gai_strerror.c | 2 +- lib/lwres/getaddrinfo.c | 18 +- lib/lwres/gethost.c | 50 ++-- lib/lwres/getipnode.c | 12 +- lib/lwres/getnameinfo.c | 2 +- lib/lwres/getnet.c | 20 +- lib/lwres/herror.c | 10 +- lib/lwres/include/lwres/netdb.h.in | 362 +++++++++++------------------ 8 files changed, 199 insertions(+), 277 deletions(-) diff --git a/lib/lwres/gai_strerror.c b/lib/lwres/gai_strerror.c index 57bac5759f..0914f55e76 100644 --- a/lib/lwres/gai_strerror.c +++ b/lib/lwres/gai_strerror.c @@ -11,7 +11,7 @@ you didn't get a copy, you may request one from . #include char * -gai_strerror(int errnum) { +lwres_gai_strerror(int errnum) { switch(errnum) { case 0: return "no error"; diff --git a/lib/lwres/getaddrinfo.c b/lib/lwres/getaddrinfo.c index 5f10b4f63b..6309f46f03 100644 --- a/lib/lwres/getaddrinfo.c +++ b/lib/lwres/getaddrinfo.c @@ -3,7 +3,7 @@ * The Berkeley Software Design Inc. software License Agreement specifies * the terms and conditions for redistribution. * - * BSDI $Id: getaddrinfo.c,v 1.10 2000/02/03 01:28:49 explorer Exp $ + * BSDI $Id: getaddrinfo.c,v 1.11 2000/02/03 21:54:08 marka Exp $ */ @@ -51,7 +51,7 @@ static void set_order(int, int (**)(const char *, int, struct addrinfo **, #define ISC_AI_MASK (AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST) int -getaddrinfo(const char *hostname, const char *servname, +lwres_getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res) { struct servent *sp; @@ -185,7 +185,7 @@ getaddrinfo(const char *hostname, const char *servname, if (family == AF_INET6 || family == 0) { ai = ai_alloc(AF_INET6, sizeof(struct sockaddr_in6)); if (ai == NULL) { - freeaddrinfo(ai_list); + lwres_freeaddrinfo(ai_list); return (EAI_MEMORY); } ai->ai_socktype = socktype; @@ -338,7 +338,7 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip, ERR(EAI_FAIL); if (hostname == NULL && (flags & AI_PASSIVE) == 0) { if ((ai = ai_clone(*aip, AF_INET)) == NULL) { - freeaddrinfo(*aip); + lwres_freeaddrinfo(*aip); ERR(EAI_MEMORY); } @@ -351,7 +351,7 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip, for (i = 0; i < by->naddrs; i++) { ai = ai_clone(*aip, AF_INET); if (ai == NULL) { - freeaddrinfo(*aip); + lwres_freeaddrinfo(*aip); ERR(EAI_MEMORY); } *aip = ai; @@ -388,7 +388,7 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, ERR(EAI_FAIL); if (hostname == NULL && (flags & AI_PASSIVE) == 0) { if ((ai = ai_clone(*aip, AF_INET6)) == NULL) { - freeaddrinfo(*aip); + lwres_freeaddrinfo(*aip); ERR(EAI_MEMORY); } @@ -400,7 +400,7 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, LWRES_ADDRTYPE_V6, &by) == 0) { for (i = 0; i < by->naddrs; i++) { if ((ai = ai_clone(*aip, AF_INET6)) == NULL) { - freeaddrinfo(*aip); + lwres_freeaddrinfo(*aip); ERR(EAI_MEMORY); } *aip = ai; @@ -421,7 +421,7 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, } void -freeaddrinfo(struct addrinfo *ai) { +lwres_freeaddrinfo(struct addrinfo *ai) { struct addrinfo *ai_next; while (ai != NULL) { @@ -499,7 +499,7 @@ ai_clone(struct addrinfo *oai, int family) { sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in))); if (ai == NULL) { - freeaddrinfo(oai); + lwres_freeaddrinfo(oai); return (NULL); } if (oai == NULL) diff --git a/lib/lwres/gethost.c b/lib/lwres/gethost.c index eb12dc53c4..c97877ef11 100644 --- a/lib/lwres/gethost.c +++ b/lib/lwres/gethost.c @@ -32,73 +32,73 @@ static struct hostent *he = NULL; static int copytobuf(struct hostent *, struct hostent *, char *, int); struct hostent * -gethostbyname(const char *name) { +lwres_gethostbyname(const char *name) { int error; if (he != NULL) - freehostent(he); + lwres_freehostent(he); - he = getipnodebyname(name, AF_INET, 0, &error); - h_errno = error; + he = lwres_getipnodebyname(name, AF_INET, 0, &error); + lwres_h_errno = error; return (he); } struct hostent * -gethostbyname2(const char *name, int af) { +lwres_gethostbyname2(const char *name, int af) { int error; if (he != NULL) - freehostent(he); + lwres_freehostent(he); - he = getipnodebyname(name, af, 0, &error); - h_errno = error; + he = lwres_getipnodebyname(name, af, 0, &error); + lwres_h_errno = error; return (he); } struct hostent * -gethostbyaddr(const char *addr, int len, int type) { +lwres_gethostbyaddr(const char *addr, int len, int type) { int error; if (he != NULL) - freehostent(he); + lwres_freehostent(he); - he = getipnodebyaddr(addr, len, type, &error); - h_errno = error; + he = lwres_getipnodebyaddr(addr, len, type, &error); + lwres_h_errno = error; return (he); } struct hostent * -gethostent(void) { +lwres_gethostent(void) { if (he != NULL) - freehostent(he); + lwres_freehostent(he); return (NULL); } void -sethostent(int stayopen) { +lwres_sethostent(int stayopen) { /* empty */ (void)stayopen; } void -endhostent(void) { +lwres_endhostent(void) { /* empty */ } struct hostent * -gethostbyname_r(const char *name, struct hostent *resbuf, +lwres_gethostbyname_r(const char *name, struct hostent *resbuf, char *buf, int buflen, int *error) { struct hostent *he; int res; - he = getipnodebyname(name, AF_INET, 0, error); + he = lwres_getipnodebyname(name, AF_INET, 0, error); if (he == NULL) return (NULL); res = copytobuf(he, resbuf, buf, buflen); if (he != NULL) - freehostent(he); + lwres_freehostent(he); if (res != 0) { errno = ERANGE; return (NULL); @@ -107,17 +107,17 @@ gethostbyname_r(const char *name, struct hostent *resbuf, } struct hostent * -gethostbyaddr_r(const char *addr, int len, int type, struct hostent *resbuf, +lwres_gethostbyaddr_r(const char *addr, int len, int type, struct hostent *resbuf, char *buf, int buflen, int *error) { struct hostent *he; int res; - he = getipnodebyaddr(addr, len, type, error); + he = lwres_getipnodebyaddr(addr, len, type, error); if (he == NULL) return (NULL); res = copytobuf(he, resbuf, buf, buflen); if (he != NULL) - freehostent(he); + lwres_freehostent(he); if (res != 0) { errno = ERANGE; return (NULL); @@ -126,7 +126,7 @@ gethostbyaddr_r(const char *addr, int len, int type, struct hostent *resbuf, } struct hostent * -gethostent_r(struct hostent *resbuf, char *buf, int buflen, int *error) { +lwres_gethostent_r(struct hostent *resbuf, char *buf, int buflen, int *error) { (void)resbuf; (void)buf; (void)buflen; @@ -135,13 +135,13 @@ gethostent_r(struct hostent *resbuf, char *buf, int buflen, int *error) { } void -sethostent_r(int stayopen) { +lwres_sethostent_r(int stayopen) { (void)stayopen; /* empty */ } void -endhostent_r(void) { +lwres_endhostent_r(void) { /* empty */ } diff --git a/lib/lwres/getipnode.c b/lib/lwres/getipnode.c index 98ea9450c4..0073d82b7a 100644 --- a/lib/lwres/getipnode.c +++ b/lib/lwres/getipnode.c @@ -83,7 +83,7 @@ static struct hostent * hostfromname(lwres_gabnresponse_t *name, int af); */ struct hostent * -getipnodebyname(const char *name, int af, int flags, int *error_num) { +lwres_getipnodebyname(const char *name, int af, int flags, int *error_num) { int have_v4 = 1, have_v6 = 1; struct in_addr in4; struct in6_addr in6; @@ -179,16 +179,16 @@ getipnodebyname(const char *name, int af, int flags, int *error_num) { cleanup: if (he1 != NULL) - freehostent(he1); + lwres_freehostent(he1); if (he2 != NULL) - freehostent(he2); + lwres_freehostent(he2); if (lwrctx != NULL) lwres_context_destroy(&lwrctx); return (he3); } struct hostent * -getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { +lwres_getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { struct hostent *he1, *he2; lwres_context_t *lwrctx = NULL; lwres_gnbaresponse_t *by = NULL; @@ -246,7 +246,7 @@ getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { /* Convert from AF_INET to AF_INET6 */ he2 = copyandmerge(he1, NULL, af, error_num); - freehostent(he1); + lwres_freehostent(he1); if (he2 == NULL) return (NULL); /* @@ -281,7 +281,7 @@ getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { } void -freehostent(struct hostent *he) { +lwres_freehostent(struct hostent *he) { char **cpp; int names = 1; int addresses = 1; diff --git a/lib/lwres/getnameinfo.c b/lib/lwres/getnameinfo.c index 7db48afd18..672f242d8f 100644 --- a/lib/lwres/getnameinfo.c +++ b/lib/lwres/getnameinfo.c @@ -75,7 +75,7 @@ static struct afd { #define ERR(x) do { result = (x); goto cleanup; } while (0) int -getnameinfo(const struct sockaddr *sa, size_t salen, char *host, +lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { struct afd *afd; diff --git a/lib/lwres/getnet.c b/lib/lwres/getnet.c index d73767fc20..383acb73b2 100644 --- a/lib/lwres/getnet.c +++ b/lib/lwres/getnet.c @@ -25,7 +25,7 @@ #include "assert_p.h" struct netent * -getnetbyname(const char *name) { +lwres_getnetbyname(const char *name) { /* XXX */ UNUSED(name); @@ -33,7 +33,7 @@ getnetbyname(const char *name) { } struct netent * -getnetbyaddr(unsigned long net, int type) { +lwres_getnetbyaddr(unsigned long net, int type) { if (type == AF_INET) return (NULL); @@ -44,48 +44,48 @@ getnetbyaddr(unsigned long net, int type) { } struct netent * -getnetent() { +lwres_getnetent() { return (NULL); } void -setnetent(int stayopen) { +lwres_setnetent(int stayopen) { UNUSED(stayopen); /* empty */ } void -endnetent() { +lwres_endnetent() { /* empty */ } struct netent * -getnetbyname_r(const char *name, struct netent *resbuf, char *buf, +lwres_getnetbyname_r(const char *name, struct netent *resbuf, char *buf, int buflen) { return (NULL); } struct netent * -getnetbyaddr_r(long addr, int type, struct netent *resbuf, char *buf, +lwres_getnetbyaddr_r(long addr, int type, struct netent *resbuf, char *buf, int buflen) { return (NULL); } struct netent * -getnetent_r(struct netent *resbuf, char *buf, int buflen) { +lwres_getnetent_r(struct netent *resbuf, char *buf, int buflen) { return (NULL); } void -setnetent_r(int stayopen) { +lwres_setnetent_r(int stayopen) { (void)stayopen; } void -endnetent_r(void) { +lwres_endnetent_r(void) { /* empty */ } diff --git a/lib/lwres/herror.c b/lib/lwres/herror.c index 9c1460718e..9a6f5d8c67 100644 --- a/lib/lwres/herror.c +++ b/lib/lwres/herror.c @@ -50,13 +50,13 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: herror.c,v 1.1 2000/01/27 08:08:02 marka Exp $"; +static const char rcsid[] = "$Id: herror.c,v 1.2 2000/02/03 21:54:10 marka Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include -int h_errno; +int lwres_h_errno; /* * these have never been declared in any header file so make them static @@ -78,8 +78,8 @@ static int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] }; * print the error indicated by the h_errno value. */ void -herror(const char *s) { - fprintf(stderr, "%s: %s\n", s, hstrerror(h_errno)); +lwres_herror(const char *s) { + fprintf(stderr, "%s: %s\n", s, lwres_hstrerror(lwres_h_errno)); } /* @@ -87,7 +87,7 @@ herror(const char *s) { * return the string associated with a given "host" errno value. */ const char * -hstrerror(int err) { +lwres_hstrerror(int err) { if (err < 0) return ("Resolver internal error"); else if (err < h_nerr) diff --git a/lib/lwres/include/lwres/netdb.h.in b/lib/lwres/include/lwres/netdb.h.in index 5a2cf4102f..a03514a444 100644 --- a/lib/lwres/include/lwres/netdb.h.in +++ b/lib/lwres/include/lwres/netdb.h.in @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 Internet Software Consortium. + * Copyright(C) 2000 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -18,157 +18,15 @@ #ifndef LWRES_NETDB_H #define LWRES_NETDB_H 1 -/* - * ++Copyright++ 1980, 1983, 1988, 1993 - * - - * Copyright (c) 1980, 1983, 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * Portions Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by WIDE Project and - * its contributors. - * 4. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * --Copyright-- - */ - -/* - * @(#)netdb.h 8.1 (Berkeley) 6/2/93 - * $Id: netdb.h.in,v 1.13 2000/02/03 02:21:18 marka Exp $ - */ - -#include -#if 0 -#include -#endif +#include #include -#ifndef _PATH_HEQUIV -#define _PATH_HEQUIV "/etc/hosts.equiv" -#endif -#ifndef _PATH_HOSTS -#define _PATH_HOSTS "/etc/hosts" -#endif -#ifndef _PATH_NETWORKS -#define _PATH_NETWORKS "/etc/networks" -#endif -#ifndef _PATH_PROTOCOLS -#define _PATH_PROTOCOLS "/etc/protocols" -#endif -#ifndef _PATH_SERVICES -#define _PATH_SERVICES "/etc/services" -#endif - /* - * Structures returned by network data base library. All addresses are - * supplied in host order, and returned in network order (suitable for - * use in system calls). + * Define if does not declare struct addrinfo. */ -struct hostent { - char *h_name; /* official name of host */ - char **h_aliases; /* alias list */ - int h_addrtype; /* host address type */ - int h_length; /* length of address */ - char **h_addr_list; /* list of addresses from name server */ -#define h_addr h_addr_list[0] /* address, for backward compatiblity */ -}; - -/* - * Assumption here is that a network number - * fits in an unsigned long -- probably a poor one. - */ -struct netent { - char *n_name; /* official name of net */ - char **n_aliases; /* alias list */ - int n_addrtype; /* net address type */ - unsigned long n_net; /* network # */ -}; - -struct servent { - char *s_name; /* official service name */ - char **s_aliases; /* alias list */ - int s_port; /* port # */ - char *s_proto; /* protocol to use */ -}; - -struct protoent { - char *p_name; /* official protocol name */ - char **p_aliases; /* alias list */ - int p_proto; /* protocol # */ -}; +@ISC_LWRES_NEEDADDRINFO@ +#ifdef ISC_LWRES_NEEDADDRINFO struct addrinfo { int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ int ai_family; /* PF_xxx */ @@ -179,12 +37,26 @@ struct addrinfo { struct sockaddr *ai_addr; /* binary address */ struct addrinfo *ai_next; /* next structure in linked list */ }; +#endif + +/* + * Undefine all #defines we are interested in as may or may not have + * defined them. + */ /* * Error return codes from gethostbyname() and gethostbyaddr() - * (left in extern int h_errno). + *(left in extern int h_errno). */ +#undef NETDB_INTERNAL +#undef NETDB_SUCCESS +#undef HOST_NOT_FOUND +#undef TRY_AGAIN +#undef NO_RECOVERY +#undef NO_DATA +#undef NO_ADDRESS + #define NETDB_INTERNAL -1 /* see errno */ #define NETDB_SUCCESS 0 /* no problem */ #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ @@ -197,6 +69,21 @@ struct addrinfo { * Error return codes from getaddrinfo() */ +#undef EAI_ADDRFAMILY +#undef EAI_AGAIN +#undef EAI_BADFLAGS +#undef EAI_FAIL +#undef EAI_FAMILY +#undef EAI_MEMORY +#undef EAI_NODATA +#undef EAI_NONAME +#undef EAI_SERVICE +#undef EAI_SOCKTYPE +#undef EAI_SYSTEM +#undef EAI_BADHINTS +#undef EAI_PROTOCOL +#undef EAI_MAX + #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ #define EAI_AGAIN 2 /* temporary failure in name resolution */ #define EAI_BADFLAGS 3 /* invalid value for ai_flags */ @@ -215,28 +102,45 @@ struct addrinfo { /* * Flag values for getaddrinfo() */ +#undef AI_PASSIVE +#undef AI_CANONNAME +#undef AI_NUMERICHOST + #define AI_PASSIVE 0x00000001 #define AI_CANONNAME 0x00000002 #define AI_NUMERICHOST 0x00000004 -#define AI_MASK 0x00000007 /* * Flag values for getipnodebyname() */ +#undef AI_V4MAPPED +#undef AI_ALL +#undef AI_ADDRCONFIG +#undef AI_DEFAULT + #define AI_V4MAPPED 0x00000008 #define AI_ALL 0x00000010 #define AI_ADDRCONFIG 0x00000020 #define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG) /* - * Constants for getnameinfo() + * Constants for lwres_getnameinfo() */ +#undef NI_MAXHOST +#undef NI_MAXSERV + #define NI_MAXHOST 1025 #define NI_MAXSERV 32 /* - * Flag values for getnameinfo() + * Flag values for lwres_getnameinfo() */ +#undef NI_NOFQDN +#undef NI_NUMERICHOST +#undef NI_NAMEREQD +#undef NI_NUMERICSERV +#undef NI_DGRAM + #define NI_NOFQDN 0x00000001 #define NI_NUMERICHOST 0x00000002 #define NI_NAMEREQD 0x00000004 @@ -251,6 +155,10 @@ struct addrinfo { #ifdef LWRES_NAMESPACE +/* + * Use our versions not the ones from the C library. + */ + #define getnameinfo lwres_getnameinfo #define getaddrinfo lwres_getaddrinfo #define freeaddrinfo lwres_freeaddrinfo @@ -277,6 +185,7 @@ struct addrinfo { #define sethostent_r lwres_sethostent_r #define endhostent_r lwres_endhostent_r +#ifdef notyet #define getservbyname lwres_getservbyname #define getservbyport lwres_getservbyport #define getservent lwres_getservent @@ -300,6 +209,7 @@ struct addrinfo { #define getprotoent_r lwres_getprotoent_r #define setprotoent_r lwres_setprotoent_r #define endprotoent_r lwres_endprotoent_r +#endif #define getnetbyname lwres_getnetbyname #define getnetbyaddr lwres_getnetbyaddr @@ -317,93 +227,105 @@ struct addrinfo { #endif -extern int h_errno; - LWRES_LANG_BEGINDECLS -#ifndef __P -#define __P(x) x -#endif -void endhostent __P((void)); -void endnetent __P((void)); -void endprotoent __P((void)); -void endservent __P((void)); -struct hostent *gethostbyaddr __P((const char *, int, int)); -struct hostent *gethostbyname __P((const char *)); -struct hostent *gethostbyname2 __P((const char *, int)); -struct hostent *gethostent __P((void)); -struct netent *getnetbyaddr __P((unsigned long, int)); -struct netent *getnetbyname __P((const char *)); -struct netent *getnetent __P((void)); -struct protoent *getprotobyname __P((const char *)); -struct protoent *getprotobynumber __P((int)); -struct protoent *getprotoent __P((void)); -struct servent *getservbyname __P((const char *, const char *)); -struct servent *getservbyport __P((int, const char *)); -struct servent *getservent __P((void)); -void herror __P((const char *)); -const char *hstrerror __P((int)); -void sethostent __P((int)); -/* void sethostfile __P((const char *)); */ -void setnetent __P((int)); -void setprotoent __P((int)); -void setservent __P((int)); -int getaddrinfo __P((const char *, const char *, - const struct addrinfo *, struct addrinfo **)); -int getnameinfo __P((const struct sockaddr *, size_t, char *, - size_t, char *, size_t, int)); -void freeaddrinfo __P((struct addrinfo *)); -char *gai_strerror __P((int)); -struct hostent *getipnodebyname __P((const char *, int, int, int *)); -struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *)); -void freehostent __P((struct hostent *)); + +extern int lwres_h_errno; + +int lwres_getaddrinfo(const char *, const char *, + const struct addrinfo *, struct addrinfo **); +int lwres_getnameinfo(const struct sockaddr *, size_t, char *, + size_t, char *, size_t, int); +void lwres_freeaddrinfo(struct addrinfo *); +char *lwres_gai_strerror(int); + +struct hostent *lwres_gethostbyaddr(const char *, int, int); +struct hostent *lwres_gethostbyname(const char *); +struct hostent *lwres_gethostbyname2(const char *, int); +struct hostent *lwres_gethostent(void); +struct hostent *lwres_getipnodebyname(const char *, int, int, int *); +struct hostent *lwres_getipnodebyaddr(const void *, size_t, int, int *); +void lwres_endhostent(void); +void lwres_sethostent(int); +/* void lwres_sethostfile(const char *); */ +void lwres_freehostent(struct hostent *); + +struct netent *lwres_getnetbyaddr(unsigned long, int); +struct netent *lwres_getnetbyname(const char *); +struct netent *lwres_getnetent(void); +void lwres_endnetent(void); +void lwres_setnetent(int); + +#ifdef notyet +struct protoent *lwres_getprotobyname(const char *); +struct protoent *lwres_getprotobynumber(int); +struct protoent *lwres_getprotoent(void); +void lwres_endprotoent(void); +void lwres_setprotoent(int); + +struct servent *lwres_getservbyname(const char *, const char *); +struct servent *lwres_getservbyport(int, const char *); +struct servent *lwres_getservent(void); +void lwres_endservent(void); +void lwres_setservent(int); +#endif /* notyet */ + +void lwres_herror(const char *); +const char *lwres_hstrerror(int); #ifdef _REENTRANT -struct hostent *gethostbyaddr_r __P((const char *, int, int, struct hostent *, - char *, int, int *)); -struct hostent *gethostbyname_r __P((const char *, struct hostent *, - char *, int, int *)); -struct hostent *gethostent_r __P((struct hostent *, char *, int, int *)); -void sethostent_r __P((int)); -void endhostent_r __P((void)); +struct hostent *lwres_gethostbyaddr_r(const char *, int, int, struct hostent *, + char *, int, int *); +struct hostent *lwres_gethostbyname_r(const char *, struct hostent *, + char *, int, int *); +struct hostent *lwres_gethostent_r(struct hostent *, char *, int, int *); +void lwres_sethostent_r(int); +void lwres_endhostent_r(void); -struct netent *getnetbyname_r __P((const char *, struct netent *, - char *, int)); -struct netent *getnetbyaddr_r __P((long, int, struct netent *, - char *, int)); -struct netent *getnetent_r __P((struct netent *, char *, int)); -void setnetent_r __P((int)); -void endnetent_r __P((void)); +struct netent *lwres_getnetbyname_r(const char *, struct netent *, + char *, int); +struct netent *lwres_getnetbyaddr_r(long, int, struct netent *, + char *, int); +struct netent *lwres_getnetent_r(struct netent *, char *, int); +void lwres_setnetent_r(int); +void lwres_endnetent_r(void); -struct protoent *getprotobyname_r __P((const char *, - struct protoent *, char *, int)); -struct protoent *getprotobynumber_r __P((int, - struct protoent *, char *, int)); -struct protoent *getprotoent_r __P((struct protoent *, char *, int)); -void setprotoent_r __P((int)); -void endprotoent_r __P((void)); +#ifdef notyet +struct protoent *lwres_getprotobyname_r(const char *, + struct protoent *, char *, int); +struct protoent *lwres_getprotobynumber_r(int, + struct protoent *, char *, int); +struct protoent *lwres_getprotoent_r(struct protoent *, char *, int); +void lwres_setprotoent_r(int); +void lwres_endprotoent_r(void); + +struct servent *lwres_getservbyname_r(const char *name, const char *, + struct servent *, char *, int); +struct servent *lwres_getservbyport_r(int port, const char *, + struct servent *, char *, int); +struct servent *lwres_getservent_r(struct servent *, char *, int); +void lwres_setservent_r(int); +void lwres_endservent_r(void); +#endif /* notyet */ +#endif /* _REENTRANT */ -struct servent *getservbyname_r __P((const char *name, const char *, - struct servent *, char *, int)); -struct servent *getservbyport_r __P((int port, const char *, - struct servent *, char *, int)); -struct servent *getservent_r __P((struct servent *, char *, int)); -void setservent_r __P((int)); -void endservent_r __P((void)); -#endif LWRES_LANG_ENDDECLS +#ifdef notyet /* This is nec'y to make this include file properly replace the sun version. */ #ifdef sun #ifdef __GNU_LIBRARY__ #include -#else +#else /* !__GNU_LIBRARY__ */ struct rpcent { char *r_name; /* name of server for this rpc program */ char **r_aliases; /* alias list */ int r_number; /* rpc program number */ }; -struct rpcent *getrpcbyname(), *getrpcbynumber(), *getrpcent(); +struct rpcent *lwres_getrpcbyname(); +struct rpcent *lwres_getrpcbynumber(), +struct rpcent *lwres_getrpcent(); #endif /* __GNU_LIBRARY__ */ #endif /* sun */ +#endif /* notyet */ #endif