summaryrefslogtreecommitdiff
path: root/ext/standard/dns.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2008-12-31 14:30:38 +0000
committerIlia Alshanetsky <iliaa@php.net>2008-12-31 14:30:38 +0000
commit540242dc2d5d316541c01e935c5bb12032d9368c (patch)
tree33c1f1e3f58f9398a591195304d2e738b952a658 /ext/standard/dns.c
parentf77719d8005ad3c0684ba1b40c83e8463b204b5a (diff)
downloadphp-git-540242dc2d5d316541c01e935c5bb12032d9368c.tar.gz
[DOC]
Added gethostname() to return the current system host name.
Diffstat (limited to 'ext/standard/dns.c')
-rw-r--r--ext/standard/dns.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index 89771d6439..8a61d1d321 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -107,6 +107,27 @@
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)
{