diff -Nur syslog-ng-1.9.4+20050518/src/misc.c syslog-ng-1.9.4+20050518-fqdn/src/misc.c --- syslog-ng-1.9.4+20050518/src/misc.c 2005-05-18 00:11:57.000000000 +0200 +++ syslog-ng-1.9.4+20050518-fqdn/src/misc.c 2005-05-18 19:44:16.241848117 +0200 @@ -45,6 +45,21 @@ } char * +getlonghostname(char *buf, size_t bufsize) +{ + gethostname(buf, bufsize - 1); + if (NULL == strchr(buf, '.')) + { + struct hostent *result = gethostbyname(buf); + if (result) + { + strncpy(buf, result->h_name, bufsize - 1); + } + } + return buf; +} + +char * getshorthostname(char *buf, size_t bufsize) { char *s; @@ -98,7 +113,14 @@ { if (!local_hostname[0]) { - getshorthostname(local_hostname, sizeof(local_hostname)); + if (usefqdn) + { + getlonghostname(local_hostname, sizeof(local_hostname)); + } + else + { + getshorthostname(local_hostname, sizeof(local_hostname)); + } } hname = local_hostname; diff -Nur syslog-ng-1.9.4+20050518/src/misc.h syslog-ng-1.9.4+20050518-fqdn/src/misc.h --- syslog-ng-1.9.4+20050518/src/misc.h 2005-05-18 00:11:57.000000000 +0200 +++ syslog-ng-1.9.4+20050518-fqdn/src/misc.h 2005-05-18 19:41:20.541652859 +0200 @@ -33,6 +33,7 @@ GString *g_string_assign_len(GString *s, gchar *val, gint len); char *getshorthostname(char *buf, size_t buflen); +char *getlonghostname(char *buf, size_t buflen); GString *resolve_hostname(GSockAddr *saddr, int usedns, int usefqdn); gboolean g_fd_set_nonblock(int fd, gboolean enable);