Skip to content

Remove inet_aton function #13479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
1 change: 1 addition & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
- The configure option --with-pspell has been removed.
- Symbol SIZEOF_SHORT removed (size of 2 on 32-bit and 64-bit platforms).
- Symbol DBA_CDB_MAKE removed in ext/dba.
- Symbol HAVE_INET_ATON and function inet_aton removed.

b. Unix build system changes
- The configure option --with-imap-ssl has been removed.
Expand Down
3 changes: 0 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,6 @@ case $host_alias in
;;
esac

dnl Check for inet_aton in -lc and -lresolv.
PHP_CHECK_FUNC(inet_aton, resolv)

dnl Then headers.
dnl ----------------------------------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "php_ini.h"
#ifdef PHP_WIN32
# include "windows_common.h"
# include <win32/inet.h>
# include <windows.h>
# include <Ws2tcpip.h>
# include "php_sockets.h"
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;

#ifndef PHP_WIN32
# include <netdb.h>
#else
#include "win32/inet.h"
#endif

#ifdef HAVE_ARPA_INET_H
Expand Down
1 change: 0 additions & 1 deletion ext/standard/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#endif

#ifdef PHP_WIN32
# include "win32/inet.h"
# include <winsock2.h>
# include <windows.h>
# include <Ws2tcpip.h>
Expand Down
66 changes: 0 additions & 66 deletions ext/standard/flock_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,69 +149,3 @@ PHPAPI int php_flock(int fd, int operation)
return 0;
}
#endif

#ifndef PHP_WIN32
#ifndef HAVE_INET_ATON
/* {{{ 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.
*/
int inet_aton(const char *cp, struct in_addr *ap)
{
int dots = 0;
unsigned long acc = 0, addr = 0;

do {
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 */
#endif
12 changes: 0 additions & 12 deletions ext/standard/flock_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,4 @@ PHPAPI int flock(int fd, int operation);
# define ftruncate(a, b) chsize(a, b)
#endif /* defined(PHP_WIN32) */

#ifndef HAVE_INET_ATON
# ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
# endif
# ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
# endif
# ifndef PHP_WIN32
extern int inet_aton(const char *, struct in_addr *);
# endif
#endif

#endif /* FLOCK_COMPAT_H */
5 changes: 0 additions & 5 deletions main/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#ifdef PHP_WIN32
# include <Ws2tcpip.h>
# include "win32/inet.h"
# include "win32/winutil.h"
# define O_RDONLY _O_RDONLY
# include "win32/param.h"
Expand Down Expand Up @@ -60,10 +59,6 @@
#endif
#endif

#ifndef HAVE_INET_ATON
int inet_aton(const char *, struct in_addr *);
#endif

#include "php_network.h"

#if defined(PHP_WIN32) || defined(__riscos__)
Expand Down
4 changes: 1 addition & 3 deletions main/php_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@

#include <php.h>

#ifdef PHP_WIN32
# include "win32/inet.h"
#else
#ifndef PHP_WIN32
# undef closesocket
# define closesocket close
# include <netinet/tcp.h>
Expand Down
2 changes: 1 addition & 1 deletion win32/build/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ if (VS_TOOLSET && VCVERS >= 1914) {
ADD_SOURCES("win32", "dllmain.c glob.c readdir.c \
registry.c select.c sendmail.c time.c winutil.c wsyslog.c globals.c \
getrusage.c ftok.c ioutil.c codepage.c nice.c \
inet.c fnmatch.c sockets.c console.c signal.c");
fnmatch.c sockets.c console.c signal.c");

ADD_FLAG("CFLAGS_BD_WIN32", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
if (VS_TOOLSET && VCVERS >= 1914) {
Expand Down
27 changes: 0 additions & 27 deletions win32/inet.c

This file was deleted.

25 changes: 0 additions & 25 deletions win32/inet.h

This file was deleted.

1 change: 0 additions & 1 deletion win32/sendmail.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <winbase.h>
#include "sendmail.h"
#include "php_ini.h"
#include "inet.h"

#include "php_win32_globals.h"

Expand Down