# HG changeset patch # User Paul Eggert # Date 841529486 0 # Node ID 96349e2b7511a634fac6fd7409cc3e33239a7c48 # Parent c8cbde1d3f11535c0219540bdf301592265727f0 (): Include if HAVE_SYS_SYSTEMINFO_H is defined. (init_system_name): Use sysinfo or getdomainname to append domain name if host name is not already fully qualified. diff -r c8cbde1d3f11 -r 96349e2b7511 src/sysdep.c --- a/src/sysdep.c Sat Aug 31 22:03:30 1996 +0000 +++ b/src/sysdep.c Sat Aug 31 22:11:26 1996 +0000 @@ -81,6 +81,11 @@ #include #endif +/* Get SI_SRPC_DOMAIN, if it is available. */ +#ifdef HAVE_SYS_SYSTEMINFO_H +#include +#endif + #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ #include #include "dosfns.h" @@ -2233,6 +2238,44 @@ } } #endif /* HAVE_SOCKETS */ +#if (HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)) || HAVE_GETDOMAINNAME + if (! index (hostname, '.')) + { + /* The hostname is not fully qualified. Append the domain name. */ + + int hostlen = strlen (hostname); + int domain_size = 256; + + for (;;) + { + char *fqdn = (char *) alloca (hostlen + 1 + domain_size); + char *domain = fqdn + hostlen + 1; +#if HAVE_SYSINFO && defined (SI_SRPC_DOMAIN) + int sys_domain_size = sysinfo (SI_SRPC_DOMAIN, domain, domain_size); + if (sys_domain_size <= 0) + break; + if (domain_size < sys_domain_size) + { + domain_size = sys_domain_size; + continue; + } +#else /* HAVE_GETDOMAINNAME */ + if (getdomainname (domain, domain_size - 1) != 0 || ! *domain) + break; + domain[domain_size - 1] = '\0'; + if (strlen (domain) == domain_size - 1) + { + domain_size *= 2; + continue; + } +#endif /* HAVE_GETDOMAINNAME */ + strcpy (fqdn, hostname); + fqdn[hostlen] = '.'; + hostname = fqdn; + break; + } + } +#endif /*! ((HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)) || HAVE_GETDOMAINNAME)*/ Vsystem_name = build_string (hostname); #endif /* HAVE_GETHOSTNAME */ #endif /* VMS */