diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-17 03:31:47 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-11-17 03:31:47 +0000 |
commit | 64933f2dc517eab440c4242234f079127e1f15a7 (patch) | |
tree | e47687e9081738291b381f88af14c9e40b0355af /libc | |
parent | 94cec9a5ee5301bf5d65b9ed7c93b8b74510a187 (diff) |
resolver: separate gethostent and gethostent_r into two .o files;
delete two stray files which compile to nothing
Diffstat (limited to 'libc')
-rw-r--r-- | libc/inet/Makefile.in | 27 | ||||
-rw-r--r-- | libc/inet/gethostent_r.c (renamed from libc/inet/resolvename.c) | 2 | ||||
-rw-r--r-- | libc/inet/resolv.c | 265 | ||||
-rw-r--r-- | libc/inet/resolveaddress.c | 8 |
4 files changed, 151 insertions, 151 deletions
diff --git a/libc/inet/Makefile.in b/libc/inet/Makefile.in index f6ee48f9d..b15f49e5f 100644 --- a/libc/inet/Makefile.in +++ b/libc/inet/Makefile.in @@ -12,7 +12,7 @@ INET_OUT := $(top_builddir)libc/inet CSRC := ifneq ($(UCLIBC_HAS_CRYPT_IMPL)$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),) -# des uses nthol +# des uses ntohl CSRC += ntohl.c endif ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),) @@ -25,21 +25,25 @@ CSRC += in6_addr.c endif # multi source addr.c -addr_CSRC := inet_aton.c inet_addr.c inet_ntoa.c inet_makeaddr.c \ +addr_CSRC := \ + inet_aton.c inet_addr.c inet_ntoa.c inet_makeaddr.c \ inet_lnaof.c inet_netof.c ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),) CSRC += $(addr_CSRC) endif # multi source resolv.c -resolv_CSRC += encodeh.c decodeh.c encoded.c decoded.c lengthd.c encodeq.c \ - decodeq.c lengthq.c encodea.c decodea.c \ - dnslookup.c resolveaddress.c opennameservers.c \ - closenameservers.c resolvename.c gethostbyname.c res_init.c \ - res_query.c gethostbyaddr.c read_etc_hosts_r.c get_hosts_byname_r.c \ - get_hosts_byaddr_r.c gethostbyname2.c getnameinfo.c gethostent.c \ - gethostbyname_r.c gethostbyname2_r.c gethostbyaddr_r.c \ - res_comp.c ns_name.c ethers.c +resolv_CSRC += \ + encodeh.c decodeh.c encoded.c decoded.c lengthd.c \ + encodeq.c decodeq.c lengthq.c encodea.c decodea.c \ + dnslookup.c opennameservers.c closenameservers.c \ + read_etc_hosts_r.c get_hosts_byaddr_r.c get_hosts_byname_r.c \ + getnameinfo.c \ + gethostbyaddr_r.c gethostbyname_r.c gethostbyname2_r.c gethostent_r.c \ + gethostbyaddr.c gethostbyname.c gethostbyname2.c gethostent.c \ + res_init.c res_query.c res_comp.c ns_name.c \ + ethers.c +#FIXME! ethers.c is a separate file, not a part of resolv.c - !? ifneq ($(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6),) CSRC += $(resolv_CSRC) @@ -49,7 +53,8 @@ endif # multi source socketcalls.c -socketcalls_CSRC += accept.c bind.c connect.c getpeername.c getsockname.c \ +socketcalls_CSRC += \ + accept.c bind.c connect.c getpeername.c getsockname.c \ getsockopt.c listen.c recv.c recvfrom.c recvmsg.c send.c sendmsg.c \ sendto.c setsockopt.c shutdown.c socket.c socketpair.c ifeq ($(UCLIBC_HAS_SOCKET),y) diff --git a/libc/inet/resolvename.c b/libc/inet/gethostent_r.c index 157878fd1..aeade155d 100644 --- a/libc/inet/resolvename.c +++ b/libc/inet/gethostent_r.c @@ -4,5 +4,5 @@ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ -#define L_resolvename +#define L_gethostent_r #include "resolv.c" diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c index 5fe8a8ed7..ebac845d3 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -1563,78 +1563,6 @@ int attribute_hidden __read_etc_hosts_r( #endif -#ifdef L_gethostent - -__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); - -static smallint __stay_open; -static FILE * __gethostent_fp; - -void endhostent(void) -{ - __UCLIBC_MUTEX_LOCK(mylock); - __stay_open = 0; - if (__gethostent_fp) { - fclose(__gethostent_fp); - __gethostent_fp = NULL; - } - __UCLIBC_MUTEX_UNLOCK(mylock); -} - -void sethostent(int stay_open) -{ - __UCLIBC_MUTEX_LOCK(mylock); - __stay_open = (stay_open != 0); - __UCLIBC_MUTEX_UNLOCK(mylock); -} - -int gethostent_r(struct hostent *result_buf, char *buf, size_t buflen, - struct hostent **result, int *h_errnop) -{ - int ret; - - __UCLIBC_MUTEX_LOCK(mylock); - if (__gethostent_fp == NULL) { - __gethostent_fp = __open_etc_hosts(); - if (__gethostent_fp == NULL) { - *result = NULL; - ret = TRY_AGAIN; - goto DONE; - } - } - - ret = __read_etc_hosts_r(__gethostent_fp, NULL, AF_INET, GETHOSTENT, - result_buf, buf, buflen, result, h_errnop); - if (__stay_open == 0) { - fclose(__gethostent_fp); - __gethostent_fp = NULL; - } -DONE: - __UCLIBC_MUTEX_UNLOCK(mylock); - return ret; -} -libc_hidden_def(gethostent_r) - -//TODO: move into separat .o file! -struct hostent *gethostent(void) -{ - static struct hostent h; - static char buf[ -#ifndef __UCLIBC_HAS_IPV6__ - sizeof(struct in_addr) + sizeof(struct in_addr *) * 2 + -#else - sizeof(struct in6_addr) + sizeof(struct in6_addr *) * 2 + -#endif /* __UCLIBC_HAS_IPV6__ */ - sizeof(char *) * ALIAS_DIM + - 80 /*namebuffer*/ + 2 /* margin */]; - struct hostent *host; - - gethostent_r(&h, buf, sizeof(buf), &host, &h_errno); - return host; -} -#endif - - #ifdef L_get_hosts_byname_r int attribute_hidden __get_hosts_byname_r(const char * name, int type, @@ -1681,69 +1609,11 @@ int attribute_hidden __get_hosts_byaddr_r(const char * addr, int len, int type, inet_ntop(type, addr, ipaddr, sizeof(ipaddr)); return __read_etc_hosts_r(NULL, ipaddr, type, GET_HOSTS_BYADDR, - result_buf, buf, buflen, result, h_errnop); + result_buf, buf, buflen, result, h_errnop); } #endif -#ifdef L_gethostbyname - -struct hostent *gethostbyname(const char *name) -{ - static struct hostent h; - static char buf[sizeof(struct in_addr) + - sizeof(struct in_addr *) * 2 + - sizeof(char *)*ALIAS_DIM + 384/*namebuffer*/ + 32/* margin */]; - struct hostent *hp; - - gethostbyname_r(name, &h, buf, sizeof(buf), &hp, &h_errno); - return hp; -} -libc_hidden_def(gethostbyname) -#endif - - -#ifdef L_gethostbyname2 - -struct hostent *gethostbyname2(const char *name, int family) -{ -#ifndef __UCLIBC_HAS_IPV6__ - return family == AF_INET ? gethostbyname(name) : (struct hostent*)NULL; -#else - static struct hostent h; - static char buf[sizeof(struct in6_addr) + - sizeof(struct in6_addr *) * 2 + - sizeof(char *)*ALIAS_DIM + 384/*namebuffer*/ + 32/* margin */]; - struct hostent *hp; - - gethostbyname2_r(name, family, &h, buf, sizeof(buf), &hp, &h_errno); - return hp; -#endif -} -#endif - - -#ifdef L_gethostbyaddr - -struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) -{ - static struct hostent h; - static char buf[ -#ifndef __UCLIBC_HAS_IPV6__ - sizeof(struct in_addr) + sizeof(struct in_addr *)*2 + -#else - sizeof(struct in6_addr) + sizeof(struct in6_addr *)*2 + -#endif /* __UCLIBC_HAS_IPV6__ */ - sizeof(char *)*ALIAS_DIM + 384 /*namebuffer*/ + 32 /* margin */]; - struct hostent *hp; - - gethostbyaddr_r(addr, len, type, &h, buf, sizeof(buf), &hp, &h_errno); - return hp; -} -libc_hidden_def(gethostbyaddr) -#endif - - #ifdef L_getnameinfo int getnameinfo(const struct sockaddr *sa, socklen_t addrlen, char *host, @@ -2488,6 +2358,139 @@ libc_hidden_def(gethostbyaddr_r) #endif +#ifdef L_gethostent_r + +__UCLIBC_MUTEX_STATIC(mylock, PTHREAD_MUTEX_INITIALIZER); + +static smallint __stay_open; +static FILE * __gethostent_fp; + +void endhostent(void) +{ + __UCLIBC_MUTEX_LOCK(mylock); + __stay_open = 0; + if (__gethostent_fp) { + fclose(__gethostent_fp); + __gethostent_fp = NULL; + } + __UCLIBC_MUTEX_UNLOCK(mylock); +} + +void sethostent(int stay_open) +{ + __UCLIBC_MUTEX_LOCK(mylock); + __stay_open = (stay_open != 0); + __UCLIBC_MUTEX_UNLOCK(mylock); +} + +int gethostent_r(struct hostent *result_buf, char *buf, size_t buflen, + struct hostent **result, int *h_errnop) +{ + int ret; + + __UCLIBC_MUTEX_LOCK(mylock); + if (__gethostent_fp == NULL) { + __gethostent_fp = __open_etc_hosts(); + if (__gethostent_fp == NULL) { + *result = NULL; + ret = TRY_AGAIN; + goto DONE; + } + } + + ret = __read_etc_hosts_r(__gethostent_fp, NULL, AF_INET, GETHOSTENT, + result_buf, buf, buflen, result, h_errnop); + if (__stay_open == 0) { + fclose(__gethostent_fp); + __gethostent_fp = NULL; + } +DONE: + __UCLIBC_MUTEX_UNLOCK(mylock); + return ret; +} +libc_hidden_def(gethostent_r) +#endif + + +#ifdef L_gethostent + +struct hostent *gethostent(void) +{ + static struct hostent h; + static char buf[ +#ifndef __UCLIBC_HAS_IPV6__ + sizeof(struct in_addr) + sizeof(struct in_addr *) * 2 + +#else + sizeof(struct in6_addr) + sizeof(struct in6_addr *) * 2 + +#endif /* __UCLIBC_HAS_IPV6__ */ + sizeof(char *) * ALIAS_DIM + + 80 /*namebuffer*/ + 2 /* margin */]; + struct hostent *host; + + gethostent_r(&h, buf, sizeof(buf), &host, &h_errno); + return host; +} +#endif + + +#ifdef L_gethostbyname + +struct hostent *gethostbyname(const char *name) +{ + static struct hostent h; + static char buf[sizeof(struct in_addr) + + sizeof(struct in_addr *) * 2 + + sizeof(char *)*ALIAS_DIM + 384/*namebuffer*/ + 32/* margin */]; + struct hostent *hp; + + gethostbyname_r(name, &h, buf, sizeof(buf), &hp, &h_errno); + return hp; +} +libc_hidden_def(gethostbyname) +#endif + + +#ifdef L_gethostbyname2 + +struct hostent *gethostbyname2(const char *name, int family) +{ +#ifndef __UCLIBC_HAS_IPV6__ + return family == AF_INET ? gethostbyname(name) : (struct hostent*)NULL; +#else + static struct hostent h; + static char buf[sizeof(struct in6_addr) + + sizeof(struct in6_addr *) * 2 + + sizeof(char *)*ALIAS_DIM + 384/*namebuffer*/ + 32/* margin */]; + struct hostent *hp; + + gethostbyname2_r(name, family, &h, buf, sizeof(buf), &hp, &h_errno); + return hp; +#endif +} +#endif + + +#ifdef L_gethostbyaddr + +struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type) +{ + static struct hostent h; + static char buf[ +#ifndef __UCLIBC_HAS_IPV6__ + sizeof(struct in_addr) + sizeof(struct in_addr *)*2 + +#else + sizeof(struct in6_addr) + sizeof(struct in6_addr *)*2 + +#endif /* __UCLIBC_HAS_IPV6__ */ + sizeof(char *)*ALIAS_DIM + 384 /*namebuffer*/ + 32 /* margin */]; + struct hostent *hp; + + gethostbyaddr_r(addr, len, type, &h, buf, sizeof(buf), &hp, &h_errno); + return hp; +} +libc_hidden_def(gethostbyaddr) +#endif + + #ifdef L_res_comp /* diff --git a/libc/inet/resolveaddress.c b/libc/inet/resolveaddress.c deleted file mode 100644 index d57366c98..000000000 --- a/libc/inet/resolveaddress.c +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> - * - * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - */ - -#define L_resolveaddress -#include "resolv.c" |