Mercurial > emacs
changeset 16003:96349e2b7511
(<sys/systeminfo.h>): 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.
author | Paul Eggert <eggert@twinsun.com> |
---|---|
date | Sat, 31 Aug 1996 22:11:26 +0000 |
parents | c8cbde1d3f11 |
children | d58c27b8187e |
files | src/sysdep.c |
diffstat | 1 files changed, 43 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 <unistd.h> #endif +/* Get SI_SRPC_DOMAIN, if it is available. */ +#ifdef HAVE_SYS_SYSTEMINFO_H +#include <sys/systeminfo.h> +#endif + #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ #include <dos.h> #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 */