This commit is contained in:
sspitzer%netscape.com 2000-03-01 19:03:33 +00:00
Родитель c2e981fdf2
Коммит 7ecceef4b0
2 изменённых файлов: 46 добавлений и 8 удалений

Просмотреть файл

@ -91,15 +91,34 @@ nsUserInfo::GetUsername(char * *aUsername)
NS_IMETHODIMP NS_IMETHODIMP
nsUserInfo::GetDomain(char * *aDomain) nsUserInfo::GetDomain(char * *aDomain)
{ {
nsresult rv = NS_ERROR_FAILURE;
struct utsname buf; struct utsname buf;
if (uname(&buf)) { if (uname(&buf)) {
return NS_ERROR_FAILURE; return rv;
} }
*aDomain = nsCRT::strdup(buf.__domainname);
if (buf.__domainname && nsCRT::strlen(buf.__domainname)) {
return NS_OK; *aDomain = nsCRT::strdup(buf.__domainname);
rv = NS_OK;
}
else {
// try to get the hostname from the nodename
// on machines that use DHCP, domainname may not be set
// but the nodename might.
if (buf.nodename && nsCRT::strlen(buf.nodename)) {
// if the nodename is foo.bar.org, use bar.org as the domain
char *pos = strchr(buf.nodename,'.');
if (pos) {
*aDomain = nsCRT::strdup(pos+1);
rv = NS_OK;
}
}
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -91,15 +91,34 @@ nsUserInfo::GetUsername(char * *aUsername)
NS_IMETHODIMP NS_IMETHODIMP
nsUserInfo::GetDomain(char * *aDomain) nsUserInfo::GetDomain(char * *aDomain)
{ {
nsresult rv = NS_ERROR_FAILURE;
struct utsname buf; struct utsname buf;
if (uname(&buf)) { if (uname(&buf)) {
return NS_ERROR_FAILURE; return rv;
} }
*aDomain = nsCRT::strdup(buf.__domainname);
if (buf.__domainname && nsCRT::strlen(buf.__domainname)) {
return NS_OK; *aDomain = nsCRT::strdup(buf.__domainname);
rv = NS_OK;
}
else {
// try to get the hostname from the nodename
// on machines that use DHCP, domainname may not be set
// but the nodename might.
if (buf.nodename && nsCRT::strlen(buf.nodename)) {
// if the nodename is foo.bar.org, use bar.org as the domain
char *pos = strchr(buf.nodename,'.');
if (pos) {
*aDomain = nsCRT::strdup(pos+1);
rv = NS_OK;
}
}
}
return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP