Back to index

php5  5.3.10
Defines | Functions
php_dns.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define INT16SZ   2
#define INT32SZ   4

Functions

 PHP_FUNCTION (gethostbyaddr)
 PHP_FUNCTION (gethostbyname)
 PHP_FUNCTION (gethostbynamel)

Define Documentation

#define INT16SZ   2

Definition at line 74 of file php_dns.h.

#define INT32SZ   4

Definition at line 78 of file php_dns.h.


Function Documentation

PHP_FUNCTION ( gethostbyaddr  )

Definition at line 153 of file dns.c.

{
       char *addr;
       int addr_len;
       char *hostname;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addr, &addr_len) == FAILURE) {
              return;
       }

       hostname = php_gethostbyaddr(addr);

       if (hostname == NULL) {
#if HAVE_IPV6 && HAVE_INET_PTON
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Address is not a valid IPv4 or IPv6 address");
#else
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Address is not in a.b.c.d form");
#endif
              RETVAL_FALSE;
       } else {
              RETVAL_STRING(hostname, 0);
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( gethostbyname  )

Definition at line 215 of file dns.c.

{
       char *hostname;
       int hostname_len;
       char *addr;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &hostname_len) == FAILURE) {
              return;
       }

       addr = php_gethostbyname(hostname);

       RETVAL_STRING(addr, 0);
}

Here is the call graph for this function:

PHP_FUNCTION ( gethostbynamel  )

Definition at line 233 of file dns.c.

{
       char *hostname;
       int hostname_len;
       struct hostent *hp;
       struct in_addr in;
       int i;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &hostname_len) == FAILURE) {
              return;
       }

       hp = gethostbyname(hostname);
       if (hp == NULL || hp->h_addr_list == NULL) {
              RETURN_FALSE;
       }

       array_init(return_value);

       for (i = 0 ; hp->h_addr_list[i] != 0 ; i++) {
              in = *(struct in_addr *) hp->h_addr_list[i];
              add_next_index_string(return_value, inet_ntoa(in), 1);
       }
}

Here is the call graph for this function: