]> granicus.if.org Git - php/commitdiff
- drop bindlib usage on windows
authorPierre Joye <pajoye@php.net>
Thu, 21 Aug 2008 23:37:40 +0000 (23:37 +0000)
committerPierre Joye <pajoye@php.net>
Thu, 21 Aug 2008 23:37:40 +0000 (23:37 +0000)
- inet_pton, inet_ntop and inet_aton are always available (VC9 uses the CRT implementation, VC6 our own)

ext/ftp/ftp.c
ext/sockets/php_sockets_win.c
ext/sockets/sockets.c
ext/standard/basic_functions.c
ext/standard/dns.c
ext/standard/flock_compat.c
main/network.c
main/php_network.h
win32/build/config.w32
win32/inet.c [new file with mode: 0644]
win32/inet.h [new file with mode: 0644]

index 30ca6b920ab29307f4c47f5294c8987ce3284277..3a8d835bb6c49721d5de13588ef7b0c9e590d4dd 100644 (file)
@@ -37,6 +37,7 @@
 #include <string.h>
 #include <time.h>
 #ifdef PHP_WIN32
+#include "win32/inet.h"
 #include <winsock2.h>
 #elif defined(NETWARE)
 #ifdef USE_WINSOCK    /* Modified to use Winsock (NOVSOCK2.H), atleast for now */
index 70913599e8b7787f534cc173dc3943268db1c6c2..807324f2a247c7ffb3c55d7d08ecf042b13b284f 100644 (file)
@@ -72,13 +72,4 @@ int socketpair(int domain, int type, int protocol, SOCKET sock[2]) {
        return 0;
 }
 
-int inet_aton(const char *cp, struct in_addr *inp) {
-  inp->s_addr = inet_addr(cp);
-
-  if (inp->s_addr == INADDR_NONE) {
-         return 0;
-  }
-
-  return 1;
-}
 #endif
index dd0ab791133fd2909a472834f319863a375c0b2a..5e2b09c5489e7ff02c278c4ea06289de7bc2d06a 100644 (file)
 #include "ext/standard/file.h"
 #include "ext/standard/info.h"
 #include "php_ini.h"
-
-#ifndef PHP_WIN32
+#ifdef PHP_WIN32
+# include "win32/inet.h"
+# include <winsock2.h>
+# include <windows.h>
+# include <Ws2tcpip.h>
+# include "php_sockets.h"
+# include "php_sockets_win.h"
+# define IS_INVALID_SOCKET(a)  (a->bsd_socket == INVALID_SOCKET)
+#else
 # include "php_sockets.h"
 # include <sys/types.h>
 # include <sys/socket.h>
 # include <sys/uio.h>
 # define IS_INVALID_SOCKET(a)  (a->bsd_socket < 0)
 # define set_errno(a) (errno = a)
-#else /* windows */
-# include "php_sockets.h"
-# include "php_sockets_win.h"
-# define IS_INVALID_SOCKET(a)  (a->bsd_socket == INVALID_SOCKET)
 #endif
 
 ZEND_DECLARE_MODULE_GLOBALS(sockets)
index 113c36bc62ecac9e874bc31396e8d793b75463ed..c2a4e15a8c92060dc0d6846bda41633673953e11 100644 (file)
@@ -61,7 +61,11 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
 #include <netinet/in.h>
 #endif
 
-#include <netdb.h>
+#ifndef PHP_WIN32
+# include <netdb.h>
+#else
+#include "win32/inet.h"
+#endif
 
 #if HAVE_ARPA_INET_H
 # include <arpa/inet.h>
index 652829141a0e1566107ea8bc8e2c745f7595d957..16aa034bbe12eba4028a2a665dccb4023e0b7ae5 100644 (file)
 #endif
 
 #ifdef PHP_WIN32
-#if HAVE_LIBBIND
-#ifndef WINNT
-#define WINNT 1
-#endif
-/* located in www.php.net/extra/bindlib.zip */
-#if HAVE_ARPA_INET_H
-#include "arpa/inet.h"
-#endif
-#include "netdb.h"
-#if HAVE_ARPA_NAMESERV_H
-#include "arpa/nameser.h"
-#endif
-#if HAVE_RESOLV_H
-#include "resolv.h"
-#endif
-#endif /* HAVE_LIBBIND */
-#include <winsock2.h>
+# include "win32/inet.h"
+# include <winsock2.h>
+# include <windows.h>
+# include <Ws2tcpip.h>
 #else  /* This holds good for NetWare too, both for Winsock and Berkeley sockets */
 #include <netinet/in.h>
 #if HAVE_ARPA_INET_H
index 9b0bf46d4aa77ed4ab449fef40aae89bc428ef97..d5b262ef9cb1a8b7750288c5ff7d700854b17f32 100644 (file)
@@ -30,6 +30,7 @@
 
 #ifdef PHP_WIN32
 #include <io.h>
+#include "config.w32.h"
 #endif
 
 #ifdef NETWARE
index 51d76faf6b848abbfbf93527c07c0439a48fa395..1ce446494f433c018874dfde5ec7a24d93b62317 100644 (file)
@@ -26,8 +26,9 @@
 #include <stddef.h>
 
 #ifdef PHP_WIN32
-#define O_RDONLY _O_RDONLY
-#include "win32/param.h"
+# include "win32/inet.h"
+# define O_RDONLY _O_RDONLY
+# include "win32/param.h"
 #elif defined(NETWARE)
 #include <sys/timeval.h>
 #include <sys/param.h>
index f5db18f8369646fbe9bccc7db0be34d78d18f3f3..a9a0d568315452301f01290eb51736eeb751d257 100644 (file)
 #define _PHP_NETWORK_H
 
 #ifdef PHP_WIN32
-# ifndef WINNT
-#  define WINNT 1
-# endif
-# undef FD_SETSIZE
-# include "arpa/inet.h"
-  /* Apache folks decided that strtoul was evil and redefined
-   * it to something that breaks the windows headers */
-# undef strtoul
-/* defines socklen_t and some IPV6 stuff */
-# include <ws2tcpip.h>
-# if HAVE_WSPIAPI_H
-   /* getaddrinfo */
-#  include <wspiapi.h>
-# endif
+# include "win32/inet.h"
 #else
 # undef closesocket
 # define closesocket close
index 6310c1ccdf6df71c676ddf6428e0939b750188e7..656fe497950ea9f90ed6ccfee0977fd57c9f8eed 100644 (file)
@@ -247,17 +247,6 @@ function probe_basic_headers()
                php_usual_include_suspects += ";" + PHP_PHP_BUILD + "\\include";
                php_usual_lib_suspects += ";" + PHP_PHP_BUILD + "\\lib";
        }
-
-       p = CHECK_HEADER_ADD_INCLUDE("arpa\\nameser.h", "CFLAGS", php_usual_include_suspects);
-
-       // hack to catch common location of libs
-       if (typeof(p) == "string") {
-               p = p.replace(new RegExp("include$"), "lib");
-               ADD_FLAG("LDFLAGS", '/libpath:"' + p + '" ');
-               php_usual_lib_suspects += ";" + p;
-       } else if (!p) {
-               ERROR("We really need that arpa\\nameser.h file - it is part of the bindlib package");
-       }
 }
 
 function add_extra_dirs()
@@ -292,12 +281,6 @@ function add_extra_dirs()
 probe_basic_headers();
 add_extra_dirs();
 
-// We can't probe for libs before this line
-
-if (!(CHECK_LIB("resolv_a.lib") || CHECK_LIB("resolv.lib"))) {
-       ERROR("We really need that arpa\\nameser.h file - it is part of the bindlib package");
-}
-
 // Do we want static ICU lib
 ARG_WITH('static-icu', 'Link against the static version of the ICU library', 'no');
 if (PHP_STATIC_ICU == "yes") {
diff --git a/win32/inet.c b/win32/inet.c
new file mode 100644 (file)
index 0000000..117c6d8
--- /dev/null
@@ -0,0 +1,89 @@
+#if _MSC_VER < 1500
+#include "config.w32.h"
+#include "php.h"
+#include <winsock2.h>
+#include <windows.h>
+#include <Ws2tcpip.h>
+
+#include "inet.h"
+
+PHPAPI int
+inet_pton(int af, const char* src, void* dst)
+{
+       int address_length;
+       struct sockaddr_storage sa;
+       struct sockaddr_in *sin = (struct sockaddr_in *)&sa;
+       struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa;
+
+       switch (af) {
+               case AF_INET:
+                       address_length = sizeof (struct sockaddr_in);
+                       break;
+
+               case AF_INET6:
+                       address_length = sizeof (struct sockaddr_in6);
+                       break;
+
+               default:
+                       return -1;
+       }
+
+       if (WSAStringToAddress ((LPTSTR) src, af, NULL, (LPSOCKADDR) &sa, &address_length) == 0) {
+               switch (af) {
+                       case AF_INET:
+                               memcpy (dst, &sin->sin_addr, sizeof (struct in_addr));
+                               break;
+
+                       case AF_INET6:
+                               memcpy (dst, &sin6->sin6_addr, sizeof (struct in6_addr));
+                               break;
+               }
+               return 1;
+       }
+
+       return 0;
+}
+
+PHPAPI const char* inet_ntop(int af, const void* src, char* dst, size_t size)
+{
+       int address_length;
+       DWORD string_length = size;
+       struct sockaddr_storage sa;
+       struct sockaddr_in *sin = (struct sockaddr_in *)&sa;
+       struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa;
+
+       memset (&sa, 0, sizeof (sa));
+       switch (af) {
+               case AF_INET:
+                       address_length = sizeof (struct sockaddr_in);
+                       sin->sin_family = af;
+                       memcpy (&sin->sin_addr, src, sizeof (struct in_addr));
+                       break;
+
+               case AF_INET6:
+                       address_length = sizeof (struct sockaddr_in6);
+                       sin6->sin6_family = af;
+                       memcpy (&sin6->sin6_addr, src, sizeof (struct in6_addr));
+                       break;
+
+               default:
+                       return NULL;
+       }
+
+       if (WSAAddressToString ((LPSOCKADDR) &sa, address_length, NULL, dst, &string_length) == 0) {
+               return dst;
+       }
+
+       return NULL;
+}
+
+int inet_aton(const char *cp, struct in_addr *inp) {
+  inp->s_addr = inet_addr(cp);
+
+  if (inp->s_addr == INADDR_NONE) {
+          return 0;
+  }
+
+  return 1;
+}
+#endif
diff --git a/win32/inet.h b/win32/inet.h
new file mode 100644 (file)
index 0000000..41a92da
--- /dev/null
@@ -0,0 +1,10 @@
+#if _MSC_VER >= 1500
+# include <In6addr.h>
+#endif
+#include <Ws2tcpip.h>
+
+#if _MSC_VER < 1500
+PHPAPI int inet_pton(int af, const char* src, void* dst);
+PHPAPI const char* inet_ntop(int af, const void* src, char* dst, size_t size);
+PHPAPI int inet_aton(const char *cp, struct in_addr *inp);
+#endif