Skip to content

Commit fcc6ba8

Browse files
committed
Remove gethostbyname from ABI (mostly)
Callers should use php_network_getaddress* instead.
1 parent c2983d7 commit fcc6ba8

4 files changed

Lines changed: 0 additions & 287 deletions

File tree

build/ax_func_which_gethostbyname_r.m4

Lines changed: 0 additions & 196 deletions
This file was deleted.

configure.ac

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ dnl Include external macro definitions before the AC_INIT to also remove
44
dnl comments starting with # and empty newlines from the included files.
55
dnl ----------------------------------------------------------------------------
66
m4_include([build/ax_check_compile_flag.m4])
7-
m4_include([build/ax_func_which_gethostbyname_r.m4])
87
m4_include([build/ax_gcc_func_attribute.m4])
98

109
m4_include([build/libtool.m4])

main/network.c

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,91 +1459,3 @@ PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout)
14591459
return n;
14601460
}
14611461
#endif
1462-
1463-
#if defined(HAVE_GETHOSTBYNAME_R)
1464-
#ifdef HAVE_FUNC_GETHOSTBYNAME_R_6
1465-
static struct hostent * gethostname_re (const char *host,struct hostent *hostbuf,char **tmphstbuf,size_t *hstbuflen)
1466-
{
1467-
struct hostent *hp;
1468-
int herr,res;
1469-
1470-
if (*hstbuflen == 0) {
1471-
*hstbuflen = 1024;
1472-
*tmphstbuf = (char *)malloc (*hstbuflen);
1473-
}
1474-
1475-
while (( res =
1476-
gethostbyname_r(host,hostbuf,*tmphstbuf,*hstbuflen,&hp,&herr))
1477-
&& (errno == ERANGE)) {
1478-
/* Enlarge the buffer. */
1479-
*hstbuflen *= 2;
1480-
*tmphstbuf = (char *)realloc (*tmphstbuf,*hstbuflen);
1481-
}
1482-
1483-
if (res != 0) {
1484-
return NULL;
1485-
}
1486-
1487-
return hp;
1488-
}
1489-
#endif
1490-
#ifdef HAVE_FUNC_GETHOSTBYNAME_R_5
1491-
static struct hostent * gethostname_re (const char *host,struct hostent *hostbuf,char **tmphstbuf,size_t *hstbuflen)
1492-
{
1493-
struct hostent *hp;
1494-
int herr;
1495-
1496-
if (*hstbuflen == 0) {
1497-
*hstbuflen = 1024;
1498-
*tmphstbuf = (char *)malloc (*hstbuflen);
1499-
}
1500-
1501-
while ((NULL == ( hp =
1502-
gethostbyname_r(host,hostbuf,*tmphstbuf,*hstbuflen,&herr)))
1503-
&& (errno == ERANGE)) {
1504-
/* Enlarge the buffer. */
1505-
*hstbuflen *= 2;
1506-
*tmphstbuf = (char *)realloc (*tmphstbuf,*hstbuflen);
1507-
}
1508-
return hp;
1509-
}
1510-
#endif
1511-
#ifdef HAVE_FUNC_GETHOSTBYNAME_R_3
1512-
static struct hostent * gethostname_re (const char *host,struct hostent *hostbuf,char **tmphstbuf,size_t *hstbuflen)
1513-
{
1514-
if (*hstbuflen == 0) {
1515-
*hstbuflen = sizeof(struct hostent_data);
1516-
*tmphstbuf = (char *)malloc (*hstbuflen);
1517-
} else {
1518-
if (*hstbuflen < sizeof(struct hostent_data)) {
1519-
*hstbuflen = sizeof(struct hostent_data);
1520-
*tmphstbuf = (char *)realloc(*tmphstbuf, *hstbuflen);
1521-
}
1522-
}
1523-
memset((void *)(*tmphstbuf),0,*hstbuflen);
1524-
1525-
if (0 != gethostbyname_r(host,hostbuf,(struct hostent_data *)*tmphstbuf)) {
1526-
return NULL;
1527-
}
1528-
1529-
return hostbuf;
1530-
}
1531-
#endif
1532-
#endif
1533-
1534-
PHPAPI struct hostent* php_network_gethostbyname(const char *name) {
1535-
#if !defined(HAVE_GETHOSTBYNAME_R)
1536-
return gethostbyname(name);
1537-
#else
1538-
if (FG(tmp_host_buf)) {
1539-
free(FG(tmp_host_buf));
1540-
}
1541-
1542-
FG(tmp_host_buf) = NULL;
1543-
FG(tmp_host_buf_len) = 0;
1544-
1545-
memset(&FG(tmp_host_info), 0, sizeof(struct hostent));
1546-
1547-
return gethostname_re(name, &FG(tmp_host_info), &FG(tmp_host_buf), &FG(tmp_host_buf_len));
1548-
#endif
1549-
}

main/php_network.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,6 @@ PHPAPI void php_network_populate_name_from_sockaddr(
385385
PHPAPI zend_result php_network_parse_network_address_with_port(const char *addr,
386386
size_t addrlen, struct sockaddr *sa, socklen_t *sl);
387387

388-
PHPAPI struct hostent* php_network_gethostbyname(const char *name);
389-
390388
PHPAPI zend_result php_set_sock_blocking(php_socket_t socketd, bool block);
391389
END_EXTERN_C()
392390

0 commit comments

Comments
 (0)