CVS update: php3
| From: | sas | Date: | Sat, 27 Feb 1999 17:04:46 +0000 |
| Subject: | CVS update: php3 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-4338@lists.php.net to get a copy of this message | ||
Date: Saturday February 27, 1999 @ 12:04
Author: sas
Update of /repository/php3
In directory asf:/u/temp/cvs-serv13746
Modified Files:
compat.c compat.h
Log Message:
moved inet_aton to compat "library"
Index: php3/compat.c
diff -c php3/compat.c:1.4 php3/compat.c:1.5
*** php3/compat.c:1.4 Thu Feb 18 12:48:49 1999
--- php3/compat.c Sat Feb 27 12:04:45 1999
***************
*** 26,32 ****
| Authors: Sascha Schumann <sas@schell.de> |
+----------------------------------------------------------------------+
! $Id: compat.c,v 1.4 1999/02/18 17:48:49 shane Exp $
*/
--- 26,32 ----
| Authors: Sascha Schumann <sas@schell.de> |
+----------------------------------------------------------------------+
! $Id: compat.c,v 1.5 1999/02/27 17:04:45 sas Exp $
*/
***************
*** 156,158 ****
--- 156,225 ----
}
#endif
#endif /* !HAVE_FLOCK */
+
+ #if !(HAVE_INET_ATON)
+
+ /*
+ * Check whether "cp" is a valid ascii representation
+ * of an Internet address and convert to a binary address.
+ * Returns 1 if the address is valid, 0 if not.
+ * This replaces inet_addr, the return value from which
+ * cannot distinguish between failure and a local broadcast address.
+ */
+
+ PHPAPI int
+ inet_aton(const char *cp, struct in_addr *ap)
+ {
+ int dots = 0;
+ register u_long acc = 0, addr = 0;
+
+ do {
+ register char cc = *cp;
+
+ switch (cc) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ acc = acc * 10 + (cc - '0');
+ break;
+
+ case '.':
+ if (++dots > 3) {
+ return 0;
+ }
+ /* Fall through */
+
+ case '\0':
+ if (acc > 255) {
+ return 0;
+ }
+ addr = addr << 8 | acc;
+ acc = 0;
+ break;
+
+ default:
+ return 0;
+ }
+ } while (*cp++) ;
+
+ /* Normalize the address */
+ if (dots < 3) {
+ addr <<= 8 * (3 - dots) ;
+ }
+
+ /* Store it if requested */
+ if (ap) {
+ ap->s_addr = htonl(addr);
+ }
+
+ return 1;
+ }
+
+ #endif /* !HAVE_INET_ATON */
Index: php3/compat.h
diff -c php3/compat.h:1.4 php3/compat.h:1.5
*** php3/compat.h:1.4 Thu Feb 18 12:48:50 1999
--- php3/compat.h Sat Feb 27 12:04:46 1999
***************
*** 24,27 ****
--- 24,31 ----
#endif /* WIN32|WINNT */
+ #if !HAVE_INET_ATON
+ extern PHPAPI int inet_aton(const char *, struct in_addr *);
+ #endif
+
#endif
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net