unix net_info.host_name

This commit is contained in:
Doug MacEachern 2005-07-11 22:45:50 +00:00
parent 006d84e029
commit b3ca673da2
1 changed files with 8 additions and 0 deletions

View File

@ -875,6 +875,14 @@ int sigar_net_info_get(sigar_t *sigar,
fclose(fp); fclose(fp);
size = sizeof(netinfo->host_name)-1;
if (gethostname(netinfo->host_name, size) == 0) {
netinfo->host_name[size] = '\0';
}
else {
netinfo->host_name[0] = '\0';
}
size = sizeof(netinfo->domain_name)-1; size = sizeof(netinfo->domain_name)-1;
if (getdomainname(netinfo->domain_name, size) == 0) { if (getdomainname(netinfo->domain_name, size) == 0) {
netinfo->domain_name[size] = '\0'; netinfo->domain_name[size] = '\0';