858 |
char *name; |
char *name; |
859 |
int name_len = 256; |
int name_len = 256; |
860 |
int status; |
int status; |
861 |
|
struct hostent *hp; |
862 |
|
|
863 |
name = malloc (name_len); |
name = malloc (name_len); |
864 |
while (name |
while (name |
865 |
&& (status = gethostname (name, name_len)) == 0 |
&& (status = gethostname (name, name_len)) == 0 |
873 |
syslog (LOG_CRIT, "Can't find out my own hostname"); |
syslog (LOG_CRIT, "Can't find out my own hostname"); |
874 |
exit (1); |
exit (1); |
875 |
} |
} |
876 |
|
|
877 |
|
hp = gethostbyname (name); |
878 |
|
if (hp) |
879 |
|
{ |
880 |
|
struct in_addr inaddr; |
881 |
|
inaddr.s_addr = *(unsigned int*)hp->h_addr; |
882 |
|
hp = gethostbyaddr ((const char *)&inaddr, |
883 |
|
sizeof (struct in_addr), AF_INET); |
884 |
|
if (hp) |
885 |
|
{ |
886 |
|
free (name); |
887 |
|
name = strdup ((char *)hp->h_name); |
888 |
|
} |
889 |
|
} |
890 |
localname = name; |
localname = name; |
891 |
} |
} |
892 |
return localname; |
return localname; |