From: Michael Wallner Date: Mon, 7 Mar 2005 08:31:15 +0000 (+0000) Subject: * probably fixing getservby*() usage X-Git-Tag: RELEASE_0_6_1~4 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=074b1d2872d6ce1c7e35fe365aee9cf39ecace24;p=m6w6%2Fext-http * probably fixing getservby*() usage --- diff --git a/config.m4 b/config.m4 index 6c1e49e..f57308b 100644 --- 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 ---- diff --git a/http_api.c b/http_api.c index 4838783..af42cd5 100644 --- a/http_api.c +++ b/http_api.c @@ -23,7 +23,12 @@ #endif #include -#include + +#ifdef PHP_WIN32 +# include +#elif defined(HAVE_NETDB_H) +# include +#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