Xinqi Bao's Git

datetime: Add error message
[slstatus.git] / components / hostname.c
1 /* See LICENSE file for copyright and license details. */
2 #include <errno.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <unistd.h>
6
7 #include "../util.h"
8
9 const char *
10 hostname(void)
11 {
12 if (gethostname(buf, sizeof(buf)) < 0) {
13 fprintf(stderr, "gethostbyname: %s\n", strerror(errno));
14 return NULL;
15 }
16
17 return buf;
18 }