aboutsummaryrefslogtreecommitdiff
path: root/src/port/gethostname.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/port/gethostname.c')
-rw-r--r--src/port/gethostname.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/port/gethostname.c b/src/port/gethostname.c
new file mode 100644
index 00000000000..568df7c497f
--- /dev/null
+++ b/src/port/gethostname.c
@@ -0,0 +1,24 @@
+/* $Id: gethostname.c,v 1.1 2002/07/18 04:13:59 momjian Exp $ */
+
+#include "c.h"
+
+#include <sys/types.h>
+#include <string.h>
+
+#include <sys/utsname.h>
+
+int
+gethostname(char *name, int namelen)
+{
+ static struct utsname mname;
+ static int called = 0;
+
+ if (!called)
+ {
+ called++;
+ uname(&mname);
+ }
+ strncpy(name, mname.nodename, (SYS_NMLN < namelen ? SYS_NMLN : namelen));
+
+ return 0;
+}