svn commit: trunk/uClibc: include libc/inet
vda at uclibc.org
vda at uclibc.org
Mon Nov 17 03:31:48 UTC 2008
Author: vda
Date: 2008-11-16 19:31:47 -0800 (Sun, 16 Nov 2008)
New Revision: 24069
Log:
resolver: separate gethostent and gethostent_r into two .o files;
delete two stray files which compile to nothing
Added:
trunk/uClibc/libc/inet/gethostent_r.c
Removed:
trunk/uClibc/libc/inet/resolveaddress.c
trunk/uClibc/libc/inet/resolvename.c
Modified:
trunk/uClibc/include/resolv.h
trunk/uClibc/libc/inet/Makefile.in
trunk/uClibc/libc/inet/resolv.c
Changeset:
Modified: trunk/uClibc/include/resolv.h
===================================================================
--- trunk/uClibc/include/resolv.h 2008-11-17 03:01:01 UTC (rev 24068)
+++ trunk/uClibc/include/resolv.h 2008-11-17 03:31:47 UTC (rev 24069)
@@ -149,7 +149,7 @@
* is the number of addresses of all kinds.
*
* If this differs from established usage and you need
- * to change this, please describe how is it supposed to work.
+ * to change this, please describe how it is supposed to work.
*/
union {
struct {
Modified: trunk/uClibc/libc/inet/Makefile.in
===================================================================
--- trunk/uClibc/libc/inet/Makefile.in 2008-11-17 03:01:01 UTC (rev 24068)
+++ trunk/uClibc/libc/inet/Makefile.in 2008-11-17 03:31:47 UTC (rev 24069)
@@ -12,7 +12,7 @@
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 @@
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 @@
# 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)
Added: trunk/uClibc/libc/inet/gethostent_r.c
===================================================================
--- trunk/uClibc/libc/inet/gethostent_r.c (rev 0)
+++ trunk/uClibc/libc/inet/gethostent_r.c 2008-11-17 03:31:47 UTC (rev 24069)
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_gethostent_r
+#include "resolv.c"
Modified: trunk/uClibc/libc/inet/resolv.c
===================================================================
--- trunk/uClibc/libc/inet/resolv.c 2008-11-17 03:01:01 UTC (rev 24068)
+++ trunk/uClibc/libc/inet/resolv.c 2008-11-17 03:31:47 UTC (rev 24069)
@@ -1563,78 +1563,6 @@
#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 @@
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 @@
#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
/*
Deleted: trunk/uClibc/libc/inet/resolveaddress.c
===================================================================
--- trunk/uClibc/libc/inet/resolveaddress.c 2008-11-17 03:01:01 UTC (rev 24068)
+++ trunk/uClibc/libc/inet/resolveaddress.c 2008-11-17 03:31:47 UTC (rev 24069)
@@ -1,8 +0,0 @@
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#define L_resolveaddress
-#include "resolv.c"
Deleted: trunk/uClibc/libc/inet/resolvename.c
===================================================================
--- trunk/uClibc/libc/inet/resolvename.c 2008-11-17 03:01:01 UTC (rev 24068)
+++ trunk/uClibc/libc/inet/resolvename.c 2008-11-17 03:31:47 UTC (rev 24069)
@@ -1,8 +0,0 @@
-/*
- * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#define L_resolvename
-#include "resolv.c"
More information about the uClibc-cvs
mailing list