pajoye          Sat Aug 23 19:22:11 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/win32      inet.c inet.h 

  Modified files:              
    /php-src/ext/sockets        php_sockets_win.c sockets.c 
    /php-src/ext/standard       basic_functions.c dns.c flock_compat.c 
                                flock_compat.h 
    /php-src/main       network.c php_network.h 
    /php-src/win32/build        config.w32 
    /php-src/win32      glob.h 
  Log:
  - MFH:
   - drop bindlib usage on windows
   - inet_pton, inet_ntop and inet_aton are always available (VC9 uses the CRT 
implementation, VC6 our own)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/php_sockets_win.c?r1=1.12.2.1.2.2.2.1&r2=1.12.2.1.2.2.2.2&diff_format=u
Index: php-src/ext/sockets/php_sockets_win.c
diff -u php-src/ext/sockets/php_sockets_win.c:1.12.2.1.2.2.2.1 
php-src/ext/sockets/php_sockets_win.c:1.12.2.1.2.2.2.2
--- php-src/ext/sockets/php_sockets_win.c:1.12.2.1.2.2.2.1      Mon Dec 31 
07:17:13 2007
+++ php-src/ext/sockets/php_sockets_win.c       Sat Aug 23 19:22:07 2008
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_sockets_win.c,v 1.12.2.1.2.2.2.1 2007/12/31 07:17:13 sebastian Exp 
$ */
+/* $Id: php_sockets_win.c,v 1.12.2.1.2.2.2.2 2008/08/23 19:22:07 pajoye Exp $ 
*/
 
 
 #ifdef PHP_WIN32
@@ -72,13 +72,4 @@
        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
http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.171.2.9.2.14.2.5&r2=1.171.2.9.2.14.2.6&diff_format=u
Index: php-src/ext/sockets/sockets.c
diff -u php-src/ext/sockets/sockets.c:1.171.2.9.2.14.2.5 
php-src/ext/sockets/sockets.c:1.171.2.9.2.14.2.6
--- php-src/ext/sockets/sockets.c:1.171.2.9.2.14.2.5    Wed Jul 16 14:08:38 2008
+++ php-src/ext/sockets/sockets.c       Sat Aug 23 19:22:07 2008
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sockets.c,v 1.171.2.9.2.14.2.5 2008/07/16 14:08:38 jani Exp $ */
+/* $Id: sockets.c,v 1.171.2.9.2.14.2.6 2008/08/23 19:22:07 pajoye Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -33,8 +33,15 @@
 #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>
@@ -51,10 +58,6 @@
 # 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)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.725.2.31.2.64.2.61&r2=1.725.2.31.2.64.2.62&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.61 
php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.62
--- php-src/ext/standard/basic_functions.c:1.725.2.31.2.64.2.61 Thu Aug 21 
16:55:45 2008
+++ php-src/ext/standard/basic_functions.c      Sat Aug 23 19:22:08 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.725.2.31.2.64.2.61 2008/08/21 16:55:45 helly Exp 
$ */
+/* $Id: basic_functions.c,v 1.725.2.31.2.64.2.62 2008/08/23 19:22:08 pajoye 
Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -63,7 +63,11 @@
 #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>
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dns.c?r1=1.70.2.7.2.5.2.6&r2=1.70.2.7.2.5.2.7&diff_format=u
Index: php-src/ext/standard/dns.c
diff -u php-src/ext/standard/dns.c:1.70.2.7.2.5.2.6 
php-src/ext/standard/dns.c:1.70.2.7.2.5.2.7
--- php-src/ext/standard/dns.c:1.70.2.7.2.5.2.6 Fri May 23 09:40:44 2008
+++ php-src/ext/standard/dns.c  Sat Aug 23 19:22:08 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: dns.c,v 1.70.2.7.2.5.2.6 2008/05/23 09:40:44 mattwil Exp $ */
+/* $Id: dns.c,v 1.70.2.7.2.5.2.7 2008/08/23 19:22:08 pajoye Exp $ */
 
 /* {{{ includes */
 #include "php.h"
@@ -29,23 +29,10 @@
 #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
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/flock_compat.c?r1=1.29.2.1.2.1.2.1&r2=1.29.2.1.2.1.2.2&diff_format=u
Index: php-src/ext/standard/flock_compat.c
diff -u php-src/ext/standard/flock_compat.c:1.29.2.1.2.1.2.1 
php-src/ext/standard/flock_compat.c:1.29.2.1.2.1.2.2
--- php-src/ext/standard/flock_compat.c:1.29.2.1.2.1.2.1        Mon Dec 31 
07:17:14 2007
+++ php-src/ext/standard/flock_compat.c Sat Aug 23 19:22:09 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: flock_compat.c,v 1.29.2.1.2.1.2.1 2007/12/31 07:17:14 sebastian Exp $ 
*/
+/* $Id: flock_compat.c,v 1.29.2.1.2.1.2.2 2008/08/23 19:22:09 pajoye Exp $ */
 
 #include "php.h"
 #include <errno.h>
@@ -30,6 +30,7 @@
 
 #ifdef PHP_WIN32
 #include <io.h>
+#include "config.w32.h"
 #endif
 
 #ifdef NETWARE
@@ -44,7 +45,7 @@
 #endif /* !defined(HAVE_FLOCK) */
 
 PHPAPI int php_flock(int fd, int operation)
-#if HAVE_STRUCT_FLOCK
+#if HAVE_STRUCT_FLOCK /* {{{ */
 {
        struct flock flck;
        int ret;
@@ -73,7 +74,8 @@
 
        return ret;
 }
-#elif defined(PHP_WIN32)
+/* }}} */
+#elif defined(PHP_WIN32) /* {{{ */
 /*
  * Program:   Unix compatibility routines
  *
@@ -152,6 +154,7 @@
 #endif
     return -1;
 }
+/* }}} */
 #else
 #warning no proper flock support for your site
 {
@@ -160,6 +163,7 @@
 }
 #endif
 
+#ifndef PHP_WIN32
 #if !(HAVE_INET_ATON)
 /* {{{ inet_aton
  * Check whether "cp" is a valid ascii representation
@@ -223,6 +227,7 @@
 }
 /* }}} */
 #endif /* !HAVE_INET_ATON */
+#endif
 
 /*
  * Local variables:
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/flock_compat.h?r1=1.20.2.1.2.1.2.1&r2=1.20.2.1.2.1.2.2&diff_format=u
Index: php-src/ext/standard/flock_compat.h
diff -u php-src/ext/standard/flock_compat.h:1.20.2.1.2.1.2.1 
php-src/ext/standard/flock_compat.h:1.20.2.1.2.1.2.2
--- php-src/ext/standard/flock_compat.h:1.20.2.1.2.1.2.1        Mon Dec 31 
07:17:14 2007
+++ php-src/ext/standard/flock_compat.h Sat Aug 23 19:22:10 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: flock_compat.h,v 1.20.2.1.2.1.2.1 2007/12/31 07:17:14 sebastian Exp $ 
*/
+/* $Id: flock_compat.h,v 1.20.2.1.2.1.2.2 2008/08/23 19:22:10 pajoye Exp $ */
 
 #ifndef FLOCK_COMPAT_H
 #define FLOCK_COMPAT_H
@@ -49,7 +49,6 @@
 #include <arpa/inet.h>
 #endif
 
-extern int inet_aton(const char *, struct in_addr *);
 #endif
 
 #endif /* FLOCK_COMPAT_H */
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.118.2.2.2.6.2.7&r2=1.118.2.2.2.6.2.8&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.118.2.2.2.6.2.7 
php-src/main/network.c:1.118.2.2.2.6.2.8
--- php-src/main/network.c:1.118.2.2.2.6.2.7    Fri Jul 11 13:11:49 2008
+++ php-src/main/network.c      Sat Aug 23 19:22:10 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: network.c,v 1.118.2.2.2.6.2.7 2008/07/11 13:11:49 jani Exp $ */
+/* $Id: network.c,v 1.118.2.2.2.6.2.8 2008/08/23 19:22:10 pajoye Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -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>
http://cvs.php.net/viewvc.cgi/php-src/main/php_network.h?r1=1.56.2.1.2.1.2.2&r2=1.56.2.1.2.1.2.3&diff_format=u
Index: php-src/main/php_network.h
diff -u php-src/main/php_network.h:1.56.2.1.2.1.2.2 
php-src/main/php_network.h:1.56.2.1.2.1.2.3
--- php-src/main/php_network.h:1.56.2.1.2.1.2.2 Mon Dec 31 07:17:17 2007
+++ php-src/main/php_network.h  Sat Aug 23 19:22:10 2008
@@ -16,26 +16,13 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_network.h,v 1.56.2.1.2.1.2.2 2007/12/31 07:17:17 sebastian Exp $ */
+/* $Id: php_network.h,v 1.56.2.1.2.1.2.3 2008/08/23 19:22:10 pajoye Exp $ */
 
 #ifndef _PHP_NETWORK_H
 #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
http://cvs.php.net/viewvc.cgi/php-src/win32/build/config.w32?r1=1.40.2.8.2.10.2.30&r2=1.40.2.8.2.10.2.31&diff_format=u
Index: php-src/win32/build/config.w32
diff -u php-src/win32/build/config.w32:1.40.2.8.2.10.2.30 
php-src/win32/build/config.w32:1.40.2.8.2.10.2.31
--- php-src/win32/build/config.w32:1.40.2.8.2.10.2.30   Fri Aug  1 11:25:42 2008
+++ php-src/win32/build/config.w32      Sat Aug 23 19:22:10 2008
@@ -1,5 +1,5 @@
 // vim:ft=javascript
-// $Id: config.w32,v 1.40.2.8.2.10.2.30 2008/08/01 11:25:42 pajoye Exp $
+// $Id: config.w32,v 1.40.2.8.2.10.2.31 2008/08/23 19:22:10 pajoye Exp $
 // "Master" config file; think of it as a configure.in
 // equivalent.
 
@@ -247,17 +247,6 @@
                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()
@@ -291,9 +280,6 @@
 
 probe_basic_headers();
 add_extra_dirs();
-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");
-}
 
 //DEFINE("PHP_BUILD", PHP_PHP_BUILD);
 
@@ -317,6 +303,7 @@
        php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
        strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c 
network.c \
        php_open_temporary_file.c php_logos.c output.c internal_functions.c 
php_sprintf.c");
+ADD_SOURCES("win32", "inet.c");
 
 ADD_SOURCES("main/streams", "streams.c cast.c memory.c filter.c 
plain_wrapper.c \
        userspace.c transports.c xp_socket.c mmap.c glob_wrapper.c");
http://cvs.php.net/viewvc.cgi/php-src/win32/glob.h?r1=1.1&r2=1.1.24.1&diff_format=u
Index: php-src/win32/glob.h
diff -u php-src/win32/glob.h:1.1 php-src/win32/glob.h:1.1.24.1
--- php-src/win32/glob.h:1.1    Sun May 19 14:32:24 2002
+++ php-src/win32/glob.h        Sat Aug 23 19:22:10 2008
@@ -1,4 +1,4 @@
-/*      $Id: glob.h,v 1.1 2002/05/19 14:32:24 edink Exp $ */
+/*      $Id: glob.h,v 1.1.24.1 2008/08/23 19:22:10 pajoye Exp $ */
 /*     OpenBSD: glob.h,v 1.7 2002/02/17 19:42:21 millert Exp   */
 /*     NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp        */
 
@@ -43,7 +43,9 @@
 #ifndef _GLOB_H_
 #define        _GLOB_H_
 
-#include <sys/cdefs.h>
+#ifndef PHP_WIN32
+# include <sys/cdefs.h>
+#endif
 
 struct stat;
 typedef struct {
@@ -93,9 +95,8 @@
 #define        GLOB_NOSYS      (-4)    /* Function not supported. */
 #define GLOB_ABEND     GLOB_ABORTED
 
-__BEGIN_DECLS
+BEGIN_EXTERN_C()
 int    glob(const char *, int, int (*)(const char *, int), glob_t *);
 void   globfree(glob_t *);
-__END_DECLS
-
+END_EXTERN_C()
 #endif /* !_GLOB_H_ */

http://cvs.php.net/viewvc.cgi/php-src/win32/inet.c?view=markup&rev=1.1
Index: php-src/win32/inet.c
+++ php-src/win32/inet.c
#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

http://cvs.php.net/viewvc.cgi/php-src/win32/inet.h?view=markup&rev=1.1
Index: php-src/win32/inet.h
+++ php-src/win32/inet.h
#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

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to