aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blogc/sysinfo.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/blogc/sysinfo.c b/src/blogc/sysinfo.c
index cdb860e..3c30996 100644
--- a/src/blogc/sysinfo.c
+++ b/src/blogc/sysinfo.c
@@ -18,6 +18,10 @@
#include <time.h>
#endif /* HAVE_TIME_H */
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
@@ -38,6 +42,12 @@ blogc_sysinfo_get_hostname(void)
if (-1 == gethostname(buf, 1024))
return NULL;
+#ifdef HAVE_NETDB_H
+ struct hostent *h = gethostbyname(buf);
+ if (h != NULL && h->h_name != NULL)
+ return bc_strdup(h->h_name);
+#endif
+
// FIXME: return FQDN instead of local host name
return bc_strdup(buf);
#endif