diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2021-03-29 00:03:14 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2021-03-29 00:47:41 +0200 |
commit | 12efeb634552cc993f9bacb8174b34214f777283 (patch) | |
tree | eeee97e1fa5c0383a4d01ed89c0a2a0dffd3dc76 /src | |
parent | d2e1bb55bcc38d6f118654fa38d6396e2f980721 (diff) | |
download | blogc-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.c | 10 |
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 |