* probably fixing getservby*() usage
authorMichael Wallner <mike@php.net>
Mon, 7 Mar 2005 08:31:15 +0000 (08:31 +0000)
committerMichael Wallner <mike@php.net>
Mon, 7 Mar 2005 08:31:15 +0000 (08:31 +0000)
config.m4
http_api.c

index 6c1e49e0e95d7e1a0614aa6b72b6cc24e770f6ed..f57308b27a460e333f4d7f30e02bd68b63b61c48 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -8,6 +8,18 @@ PHP_ARG_WITH([curl], [for CURL support],
 
 if test "$PHP_HTTP" != "no"; then
 
+dnl -------
+dnl NETDB.H
+dnl -------
+
+       AC_MSG_CHECKING(for netdb.h)
+       if test -r /usr/include/netdb.h -o -r /usr/local/include/netdb.h; then
+               AC_DEFINE(HAVE_NETDB_H, 1, [Have netdb.h])
+               AC_MSG_RESULT(found in default path)
+       else
+               AC_MSG_RESULT(not found in default path)
+       fi
+
 dnl ----
 dnl CURL
 dnl ----
index 48387837c4fd068ed13f87298389230d468feba6..af42cd5e641cb68a785d72176a967899e78abd92 100644 (file)
 #endif
 
 #include <ctype.h>
-#include <netdb.h>
+
+#ifdef PHP_WIN32
+#      include <winsock2.h>
+#elif defined(HAVE_NETDB_H)
+#      include <netdb.h>
+#endif
 
 #include "php.h"
 #include "php_version.h"
@@ -887,7 +892,7 @@ PHP_HTTP_API char *_http_absolute_uri_ex(
        const char *host,       size_t host_len,
        unsigned port TSRMLS_DC)
 {
-#ifdef ZEND_ENGINE_2
+#if defined(PHP_WIN32) || defined(HAVE_NETDB_H)
        struct servent *se;
 #endif
        php_url *purl, furl = {NULL};
@@ -918,7 +923,7 @@ PHP_HTTP_API char *_http_absolute_uri_ex(
                furl.scheme = scheme = estrdup(proto);
        } else if (purl->scheme) {
                furl.scheme = purl->scheme;
-#ifdef ZEND_ENGINE_2
+#if defined(PHP_WIN32) || defined(HAVE_NETDB_H)
        } else if (port && (se = getservbyport(port, "tcp"))) {
                furl.scheme = (scheme = estrdup(se->s_name));
 #endif
@@ -931,7 +936,7 @@ PHP_HTTP_API char *_http_absolute_uri_ex(
        } else if (purl->port) {
                furl.port = purl->port;
        } else if (strncmp(furl.scheme, "http", 4)) {
-#ifdef ZEND_ENGINE_2
+#if defined(PHP_WIN32) || defined(HAVE_NETDB_H)
                if (se = getservbyname(furl.scheme, "tcp")) {
                        furl.port = se->s_port;
                } else