summaryrefslogtreecommitdiff
path: root/hostname.c
diff options
context:
space:
mode:
Diffstat (limited to 'hostname.c')
-rw-r--r--hostname.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/hostname.c b/hostname.c
new file mode 100644
index 0000000..23c5a16
--- /dev/null
+++ b/hostname.c
@@ -0,0 +1,15 @@
+#include <err.h>
+#include <unistd.h>
+
+#include "util.h"
+
+const char *
+hostname(void)
+{
+ if (gethostname(buf, sizeof(buf)) == -1) {
+ warn("hostname");
+ return NULL;
+ }
+
+ return buf;
+}