aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2021-03-29 00:03:14 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2021-03-29 00:47:41 +0200
commit12efeb634552cc993f9bacb8174b34214f777283 (patch)
treeeeee97e1fa5c0383a4d01ed89c0a2a0dffd3dc76 /src
parentd2e1bb55bcc38d6f118654fa38d6396e2f980721 (diff)
downloadblogc-12efeb634552cc993f9bacb8174b34214f777283.tar.gz
blogc-12efeb634552cc993f9bacb8174b34214f777283.tar.bz2
blogc-12efeb634552cc993f9bacb8174b34214f777283.zip
blogc: sysinfo: get fqdn if available
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