aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert1996-08-31 22:11:26 +0000
committerPaul Eggert1996-08-31 22:11:26 +0000
commitb05af5d3332548299934a987ab21c71a4d42cffb (patch)
treef2a0fb45667d030f43fabc8d838f81734dbe66b2 /src
parentabd89b803137814128d5ca2da52bf0f9e71ccfcc (diff)
downloademacs-b05af5d3332548299934a987ab21c71a4d42cffb.tar.gz
emacs-b05af5d3332548299934a987ab21c71a4d42cffb.zip
(<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.
Diffstat (limited to 'src')
-rw-r--r--src/sysdep.c43
1 files changed, 43 insertions, 0 deletions
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;
81#include <unistd.h> 81#include <unistd.h>
82#endif 82#endif
83 83
84/* Get SI_SRPC_DOMAIN, if it is available. */
85#ifdef HAVE_SYS_SYSTEMINFO_H
86#include <sys/systeminfo.h>
87#endif
88
84#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ 89#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */
85#include <dos.h> 90#include <dos.h>
86#include "dosfns.h" 91#include "dosfns.h"
@@ -2233,6 +2238,44 @@ init_system_name ()
2233 } 2238 }
2234 } 2239 }
2235#endif /* HAVE_SOCKETS */ 2240#endif /* HAVE_SOCKETS */
2241#if (HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)) || HAVE_GETDOMAINNAME
2242 if (! index (hostname, '.'))
2243 {
2244 /* The hostname is not fully qualified. Append the domain name. */
2245
2246 int hostlen = strlen (hostname);
2247 int domain_size = 256;
2248
2249 for (;;)
2250 {
2251 char *fqdn = (char *) alloca (hostlen + 1 + domain_size);
2252 char *domain = fqdn + hostlen + 1;
2253#if HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)
2254 int sys_domain_size = sysinfo (SI_SRPC_DOMAIN, domain, domain_size);
2255 if (sys_domain_size <= 0)
2256 break;
2257 if (domain_size < sys_domain_size)
2258 {
2259 domain_size = sys_domain_size;
2260 continue;
2261 }
2262#else /* HAVE_GETDOMAINNAME */
2263 if (getdomainname (domain, domain_size - 1) != 0 || ! *domain)
2264 break;
2265 domain[domain_size - 1] = '\0';
2266 if (strlen (domain) == domain_size - 1)
2267 {
2268 domain_size *= 2;
2269 continue;
2270 }
2271#endif /* HAVE_GETDOMAINNAME */
2272 strcpy (fqdn, hostname);
2273 fqdn[hostlen] = '.';
2274 hostname = fqdn;
2275 break;
2276 }
2277 }
2278#endif /*! ((HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)) || HAVE_GETDOMAINNAME)*/
2236 Vsystem_name = build_string (hostname); 2279 Vsystem_name = build_string (hostname);
2237#endif /* HAVE_GETHOSTNAME */ 2280#endif /* HAVE_GETHOSTNAME */
2238#endif /* VMS */ 2281#endif /* VMS */