[uClibc-cvs] CVS update of uClibc/libc/inet (resolv.c)

Erik Andersen andersen at codepoet.org
Tue Sep 7 10:34:36 UTC 2004


    Date: Tuesday, September 7, 2004 @ 04:34:36
  Author: andersen
    Path: /var/cvs/uClibc/libc/inet

Modified: resolv.c (1.57 -> 1.58)

Implement gethostent_r


Index: uClibc/libc/inet/resolv.c
diff -u uClibc/libc/inet/resolv.c:1.57 uClibc/libc/inet/resolv.c:1.58
--- uClibc/libc/inet/resolv.c:1.57	Tue Sep  7 04:34:09 2004
+++ uClibc/libc/inet/resolv.c	Tue Sep  7 04:34:35 2004
@@ -111,8 +111,8 @@
  *   and read_etc_hosts; getnameinfo() port from glibc; defined
  *   defined ip6addr_any and in6addr_loopback)
  *
- * 2-Feb-2002 Erik Andersen <andersee at debian.org>
- * Added gethostent(), sethostent(), and endhostent()
+ * 2-Feb-2002 Erik Andersen <andersen at codepoet.org>
+ *   Added gethostent(), sethostent(), and endhostent()
  *
  * 17-Aug-2002 Manuel Novoa III <mjn3 at codepoet.org>
  *   Fixed __read_etc_hosts_r to return alias list, and modified buffer
@@ -128,6 +128,9 @@
  *   and ns_name_ntop() from glibc 2.3.2 for compatibility with ipsec-tools 
  *   and openldap.
  *
+ * 7-Sep-2004 Erik Andersen <andersen at codepoet.org>
+ *   Added gethostent_r()
+ *
  */
 
 #define __FORCE_GLIBC
@@ -1042,6 +1045,8 @@
 }
 #endif
 
+
+
 #ifdef L_res_init
 struct __res_state _res;
 
@@ -1554,6 +1559,29 @@
     UNLOCK;
 }
 
+int gethostent_r(struct hostent *result_buf, char *buf, size_t buflen,
+	struct hostent **result, int *h_errnop)
+{
+    int ret;
+
+    LOCK;
+    if (__gethostent_fp == NULL) {
+	__open_etc_hosts(&__gethostent_fp);
+	if (__gethostent_fp == NULL) {
+	    UNLOCK;
+	    *result=NULL;
+	    return 0;
+	}
+    }
+
+    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);
+    }
+    UNLOCK;
+    return(ret);
+}
 
 struct hostent *gethostent (void)
 {
@@ -1569,19 +1597,7 @@
     struct hostent *host;
 
     LOCK;
-    if (__gethostent_fp == NULL) {
-	__open_etc_hosts(&__gethostent_fp);
-	if (__gethostent_fp == NULL) {
-	    UNLOCK;
-	    return((struct hostent *)NULL);
-	}
-    }
-
-    __read_etc_hosts_r(__gethostent_fp, NULL, AF_INET, GETHOSTENT, 
-		   &h, buf, sizeof(buf), &host, &h_errno);
-    if (__stay_open==0) {
-	fclose(__gethostent_fp);
-    }
+    gethostent_r(&h, buf, sizeof(buf), &host, &h_errno);
     UNLOCK;
     return(host);
 }



More information about the uClibc-cvs mailing list