From 0018b2277da84417c9836149b1f1240f8d3850b7 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 11 May 2022 08:45:45 -0400 Subject: initial commit --- components/hostname.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 components/hostname.c (limited to 'components/hostname.c') diff --git a/components/hostname.c b/components/hostname.c new file mode 100644 index 0000000..23da677 --- /dev/null +++ b/components/hostname.c @@ -0,0 +1,16 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include + +#include "../util.h" + +const char * +hostname(void) +{ + if (gethostname(buf, sizeof(buf)) < 0) { + warn("gethostbyname:"); + return NULL; + } + + return buf; +} -- cgit v1.2.3