Mercurial > emacs
comparison src/sysdep.c @ 20202:de9483a63b12
(init_system_name): If gethostname gives a proper
domain name, don't look farther for one.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Fri, 31 Oct 1997 23:01:48 +0000 |
parents | ce0b47a57e23 |
children | 3ef6fba94e13 |
comparison
equal
deleted
inserted
replaced
20201:09b52c2bc2f1 | 20202:de9483a63b12 |
---|---|
2239 Don't do this if we're going to dump; this can confuse system | 2239 Don't do this if we're going to dump; this can confuse system |
2240 libraries on some machines and make the dumped emacs core dump. */ | 2240 libraries on some machines and make the dumped emacs core dump. */ |
2241 #ifndef CANNOT_DUMP | 2241 #ifndef CANNOT_DUMP |
2242 if (initialized) | 2242 if (initialized) |
2243 #endif /* not CANNOT_DUMP */ | 2243 #endif /* not CANNOT_DUMP */ |
2244 { | 2244 if (! index (hostname, '.')) |
2245 struct hostent *hp; | 2245 { |
2246 int count; | 2246 struct hostent *hp; |
2247 for (count = 0;; count++) | 2247 int count; |
2248 { | 2248 for (count = 0;; count++) |
2249 { | |
2249 #ifdef TRY_AGAIN | 2250 #ifdef TRY_AGAIN |
2250 h_errno = 0; | 2251 h_errno = 0; |
2251 #endif | 2252 #endif |
2252 hp = gethostbyname (hostname); | 2253 hp = gethostbyname (hostname); |
2253 #ifdef TRY_AGAIN | 2254 #ifdef TRY_AGAIN |
2254 if (! (hp == 0 && h_errno == TRY_AGAIN)) | 2255 if (! (hp == 0 && h_errno == TRY_AGAIN)) |
2255 #endif | 2256 #endif |
2256 break; | 2257 break; |
2257 if (count >= 5) | 2258 if (count >= 5) |
2258 break; | 2259 break; |
2259 Fsleep_for (make_number (1), Qnil); | 2260 Fsleep_for (make_number (1), Qnil); |
2260 } | 2261 } |
2261 if (hp) | 2262 if (hp) |
2262 { | 2263 { |
2263 char *fqdn = (char *) hp->h_name; | 2264 char *fqdn = (char *) hp->h_name; |
2264 char *p; | 2265 char *p; |
2265 | 2266 |
2266 if (!index (fqdn, '.')) | 2267 if (!index (fqdn, '.')) |
2267 { | 2268 { |
2268 /* We still don't have a fully qualified domain name. | 2269 /* We still don't have a fully qualified domain name. |
2269 Try to find one in the list of alternate names */ | 2270 Try to find one in the list of alternate names */ |
2270 char **alias = hp->h_aliases; | 2271 char **alias = hp->h_aliases; |
2271 while (*alias && !index (*alias, '.')) | 2272 while (*alias && !index (*alias, '.')) |
2272 alias++; | 2273 alias++; |
2273 if (*alias) | 2274 if (*alias) |
2274 fqdn = *alias; | 2275 fqdn = *alias; |
2275 } | 2276 } |
2276 hostname = fqdn; | 2277 hostname = fqdn; |
2277 #if 0 | 2278 #if 0 |
2278 /* Convert the host name to lower case. */ | 2279 /* Convert the host name to lower case. */ |
2279 /* Using ctype.h here would introduce a possible locale | 2280 /* Using ctype.h here would introduce a possible locale |
2280 dependence that is probably wrong for hostnames. */ | 2281 dependence that is probably wrong for hostnames. */ |
2281 p = hostname; | 2282 p = hostname; |
2282 while (*p) | 2283 while (*p) |
2283 { | 2284 { |
2284 if (*p >= 'A' && *p <= 'Z') | 2285 if (*p >= 'A' && *p <= 'Z') |
2285 *p += 'a' - 'A'; | 2286 *p += 'a' - 'A'; |
2286 p++; | 2287 p++; |
2287 } | 2288 } |
2288 #endif | 2289 #endif |
2289 } | 2290 } |
2290 } | 2291 } |
2291 #endif /* HAVE_SOCKETS */ | 2292 #endif /* HAVE_SOCKETS */ |
2292 /* We used to try using getdomainname as an alternative | 2293 /* We used to try using getdomainname as an alternative |
2293 to sysinfo, here, but NIIBE Yutaka <gniibe@etl.go.jp> says that | 2294 to sysinfo, here, but NIIBE Yutaka <gniibe@etl.go.jp> says that |
2294 getdomainname gets the NIS/YP domain which often is not the same | 2295 getdomainname gets the NIS/YP domain which often is not the same |
2295 as in Internet domain name. */ | 2296 as in Internet domain name. */ |