From: Paul Eggert Date: Sat, 31 Aug 1996 22:11:26 +0000 (+0000) Subject: (): Include if HAVE_SYS_SYSTEMINFO_H is defined. X-Git-Tag: emacs-20.1~3941 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b05af5d3332548299934a987ab21c71a4d42cffb;p=emacs.git (): 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 --git a/src/sysdep.c b/src/sysdep.c index 5baf95c92b5..d00dcbb6266 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -81,6 +81,11 @@ extern int h_errno; #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 @@ init_system_name () } } #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 */