Mercurial > noffle
diff src/util.c @ 244:4e69e9b722ae noffle
[svn] * src/database.c,src/protocol.c,src/util.c,src/util.h: The latest IETF
article format draft draft-ietf-usefor-article-06.txt recommends that
Xref: references contain the FQDN of the server. We were using the
host name without the domain. So split the routine used for obtaining
the FQDN from protocol.c into util.c, and use it when adding Xrefs.
author | bears |
---|---|
date | Fri, 15 Mar 2002 10:50:33 +0000 |
parents | fbff73fe5b40 |
children | b660fadc1814 |
line wrap: on
line diff
--- a/src/util.c Fri Mar 15 10:49:56 2002 +0000 +++ b/src/util.c Fri Mar 15 10:50:33 2002 +0000 @@ -1,7 +1,7 @@ /* util.c - $Id: util.c 371 2002-02-26 17:13:31Z bears $ + $Id: util.c 375 2002-03-15 10:50:33Z bears $ */ #if HAVE_CONFIG_H @@ -21,8 +21,10 @@ #include <errno.h> #include <ctype.h> +#include <netdb.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/utsname.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> @@ -504,6 +506,31 @@ return oldAct.sa_handler; } +static Bool +getHostFQDN( Str result ) +{ + struct hostent *myHostEnt; + struct utsname myName; + + if ( uname( &myName ) >= 0 + && ( myHostEnt = gethostbyname( myName.nodename ) ) ) + { + Utl_cpyStr( result, myHostEnt->h_name ); + return TRUE; + } + return FALSE; +} + +Bool +Utl_getFQDN( Str result ) +{ + /* get hostname from Cfg-File */ + Utl_cpyStr( result, Cfg_hostnameMsgId() ); + if ( strlen( result ) != 0 ) + return TRUE; + return getHostFQDN( result ); +} + #if defined(UTIL_TEST) /* Test code borrowed from wildmat.c. Yep, still uses gets(). */