292 |
return; |
return; |
293 |
} |
} |
294 |
|
|
295 |
|
char * |
296 |
|
get_localname () |
297 |
|
{ |
298 |
|
static char *localname = NULL; |
299 |
|
|
300 |
|
if (!localname) { |
301 |
|
char *name; |
302 |
|
int name_len = 256; |
303 |
|
int status = 1; |
304 |
|
struct hostent *hp; |
305 |
|
|
306 |
|
name = malloc (name_len); |
307 |
|
while (name |
308 |
|
&& (status = gethostname (name, name_len)) == 0 |
309 |
|
&& !memchr (name, 0, name_len)) { |
310 |
|
name_len *= 2; |
311 |
|
name = realloc (name, name_len); |
312 |
|
} |
313 |
|
if (status) { |
314 |
|
info (NORMAL, |
315 |
|
_("Can't find out my own hostname")); |
316 |
|
exit (1); |
317 |
|
} |
318 |
|
|
319 |
|
hp = gethostbyname (name); |
320 |
|
if (hp) { |
321 |
|
struct in_addr inaddr; |
322 |
|
inaddr.s_addr = *(unsigned int *) hp->h_addr; |
323 |
|
hp = gethostbyaddr ((const char *) &inaddr, |
324 |
|
sizeof (struct in_addr), AF_INET); |
325 |
|
if (hp) { |
326 |
|
free (name); |
327 |
|
name = strdup ((char *) hp->h_name); |
328 |
|
} |
329 |
|
} |
330 |
|
localname = name; |
331 |
|
} |
332 |
|
return localname; |
333 |
|
} |
334 |
|
|
335 |
|
char * |
336 |
|
get_localdomain() |
337 |
|
{ |
338 |
|
if (!anubis_domain) { |
339 |
|
char *localname = get_localname(), |
340 |
|
*p = strchr(localname, '.'); |
341 |
|
if (!p) |
342 |
|
anubis_domain = strdup(localname); |
343 |
|
else |
344 |
|
anubis_domain = strdup(p+1); |
345 |
|
} |
346 |
|
return anubis_domain; |
347 |
|
} |
348 |
/* EOF */ |
/* EOF */ |
349 |
|
|