]> granicus.if.org Git - php/commitdiff
[DOC]
authorIlia Alshanetsky <iliaa@php.net>
Wed, 31 Dec 2008 14:30:38 +0000 (14:30 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 31 Dec 2008 14:30:38 +0000 (14:30 +0000)
Added gethostname() to return the current system host name.

NEWS
configure.in
ext/standard/basic_functions.c
ext/standard/dns.c
ext/standard/dns.h
win32/build/config.w32.h.in

diff --git a/NEWS b/NEWS
index f579a7be07d9e4a84e55ad07345ca3a0d1c5d30d..a82f7828cd5166895ec7005d0583cd9bf54e6bca 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ PHP                                                                        NEWS
 
 - Added json_last_error() to return any error information from json_decode().
   (Scott)
+- Added gethostname() to return the current system host name. (Ilia)
 - Added shm_has_var() function. (Mike)
 - Added depth parameter to json_decode() to lower the nesting depth from the
   maximum if required. (Scott)
index 11273a0d0ec37da326337d842172a1f08f8dd869..d953676f9510c6f401b37a7bcbb8ae39958163d4 100644 (file)
@@ -575,6 +575,7 @@ getprotobyname \
 getprotobynumber \
 getservbyname \
 getservbyport \
+gethostname \
 getrusage \
 gettimeofday \
 gmtime_r \
index c986e8034c5a9e9526e0baba32e5d492361f3e0d..0b8c19f480832cce38d2bf0f531fa75f74303247 100644 (file)
@@ -991,6 +991,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_gethostbynamel, 0)
        ZEND_ARG_INFO(0, hostname)
 ZEND_END_ARG_INFO()
 
+#ifdef HAVE_GETHOSTNAME
+ZEND_BEGIN_ARG_INFO(arginfo_gethostname, 0)
+ZEND_END_ARG_INFO()
+#endif
+
 #if HAVE_RES_SEARCH && !(defined(__BEOS__)||defined(PHP_WIN32) || defined(NETWARE))
 ZEND_BEGIN_ARG_INFO_EX(arginfo_dns_check_record, 0, 0, 1)
        ZEND_ARG_INFO(0, host)
@@ -2990,6 +2995,10 @@ const zend_function_entry basic_functions[] = { /* {{{ */
        PHP_FE(gethostbyname,                                                                                                   arginfo_gethostbyname)
        PHP_FE(gethostbynamel,                                                                                                  arginfo_gethostbynamel)
 
+#ifdef HAVE_GETHOSTNAME
+       PHP_FE(gethostname,                                                                                                     arginfo_gethostname)
+#endif
+
 #if HAVE_RES_SEARCH && !(defined(__BEOS__) || defined(PHP_WIN32) || defined(NETWARE))
        PHP_FE(dns_check_record,                                                                                                arginfo_dns_check_record)
        PHP_FALIAS(checkdnsrr,                  dns_check_record,                                               arginfo_dns_check_record)
index 89771d6439103b13ac0da362a8c567ecf28d80c7..8a61d1d3214985e6c59822c9126710c55037b23e 100644 (file)
 static char *php_gethostbyaddr(char *ip);
 static char *php_gethostbyname(char *name);
 
+#ifdef HAVE_GETHOSTNAME
+/* {{{ proto string gethostname()
+   Get the host name of the current machine */
+PHP_FUNCTION(gethostname)
+{
+       char buf[4096];
+
+       if (zend_parse_parameters_none() == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+
+       if (gethostname(buf, sizeof(buf) - 1)) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to fetch host [%d]: %s", errno, strerror(errno));
+               RETURN_FALSE;
+       }
+
+       RETURN_STRING(buf, 1);
+}
+/* }}} */
+#endif
+
 /* {{{ proto string gethostbyaddr(string ip_address)
    Get the Internet host name corresponding to a given IP address */
 PHP_FUNCTION(gethostbyaddr)
@@ -134,6 +155,7 @@ PHP_FUNCTION(gethostbyaddr)
 }
 /* }}} */
 
+
 /* {{{ php_gethostbyaddr */
 static char *php_gethostbyaddr(char *ip)
 {
index 38386879a1cd1768a440604563618728584cd060..3d1a1b21b9357c21efb99353985f3c276222cc9f 100644 (file)
@@ -31,6 +31,10 @@ PHP_FUNCTION(gethostbyaddr);
 PHP_FUNCTION(gethostbyname);
 PHP_FUNCTION(gethostbynamel);
 
+#ifdef HAVE_GETHOSTNAME
+PHP_FUNCTION(gethostname);
+#endif
+
 #if HAVE_RES_SEARCH && !(defined(__BEOS__)||defined(PHP_WIN32))
 
 PHP_FUNCTION(dns_check_record);
index 820fe3fe8f775445bf87f5a61b15d877414ce837..a2ebcec0f4eb072f366ef5727898139b05d51286 100644 (file)
@@ -53,6 +53,7 @@
 /* its in win32/time.c */
 #define HAVE_USLEEP 1
 
+#define HAVE_GETHOSTNAME 1
 #define HAVE_GETCWD 1
 #define HAVE_POSIX_READDIR_R 1
 #define NEED_ISBLANK 1