aboutsummaryrefslogtreecommitdiff
path: root/slstatus/components/hostname.c
diff options
context:
space:
mode:
authorMarvin Borner2019-03-05 01:09:01 +0100
committerMarvin Borner2019-03-05 01:09:01 +0100
commit55457187d18221e76bd12f0fb2cfab65c49b92fb (patch)
tree8db042d2d80710d54100c2709ad4332153ac848a /slstatus/components/hostname.c
Initial commit
Diffstat (limited to 'slstatus/components/hostname.c')
-rw-r--r--slstatus/components/hostname.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/slstatus/components/hostname.c b/slstatus/components/hostname.c
new file mode 100644
index 0000000..23da677
--- /dev/null
+++ b/slstatus/components/hostname.c
@@ -0,0 +1,16 @@
+/* See LICENSE file for copyright and license details. */
+#include <stdio.h>
+#include <unistd.h>
+
+#include "../util.h"
+
+const char *
+hostname(void)
+{
+ if (gethostname(buf, sizeof(buf)) < 0) {
+ warn("gethostbyname:");
+ return NULL;
+ }
+
+ return buf;
+}