From de4cf2cf7e7b20594312ce6e7c5fceb6790a5401 Mon Sep 17 00:00:00 2001 From: krolyxon Date: Wed, 1 Jun 2022 23:52:05 +0530 Subject: first 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