[uClibc-cvs] uClibc/libc/inet addr.c,1.12,1.13

Erik Andersen andersen at uclibc.org
Mon Aug 4 19:03:37 UTC 2003


Update of /var/cvs/uClibc/libc/inet
In directory winder:/tmp/cvs-serv13930

Modified Files:
	addr.c 
Log Message:
Update inet_aton() to support an undocumented feature of inet_aton,
per UNIX Network Programming, Volume 1, second edition:

    An undocumented feature of inet_aton is that if addrptr is
    a null pointer, the function still performs it validation
    of the input string, but does not store the result.



Index: addr.c
===================================================================
RCS file: /var/cvs/uClibc/libc/inet/addr.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- addr.c	17 Sep 2002 01:40:47 -0000	1.12
+++ addr.c	4 Aug 2003 19:03:33 -0000	1.13
@@ -24,20 +24,17 @@
 #include <ctype.h>
 #include <netinet/in.h>
 
-int inet_aton(const char *cp, struct in_addr *inp);
+int inet_aton(const char *cp, struct in_addr *addrptr);
 
 #ifdef L_inet_aton
-int inet_aton(cp, inp)
+int inet_aton(cp, addrptr)
 const char *cp;
-struct in_addr *inp;
+struct in_addr *addrptr;
 {
 	unsigned long addr;
 	int value;
 	int part;
 
-	if (!inp)
-		return 0;
-
 	addr = 0;
 	for (part = 1; part <= 4; part++) {
 
@@ -65,7 +62,16 @@
 		addr |= value;
 	}
 
-	inp->s_addr = htonl(addr);
+	/*  W. Richard Stevens in his book UNIX Network Programming,
+	 *  Volume 1, second edition, on page 71 says:
+	 *
+	 *  An undocumented feature of inet_aton is that if addrptr is
+	 *  a null pointer, the function still performs it validation
+	 *  of the input string, but does not store the result.
+	 */
+	if (addrptr) {
+	    addrptr->s_addr = htonl(addr);
+	}
 
 	return 1;
 }




More information about the uClibc-cvs mailing list