1 /* getdomainname() Author: Kees J. Bot
6 #include <sys/utsname.h>
10 int getdomainname(char *domain
, size_t size
)
15 if (gethostname(nodename
, sizeof(nodename
)) < 0)
17 nodename
[sizeof(nodename
)-1]= 0;
18 if ((dot
= strchr(nodename
, '.')) == nil
) dot
= ".";
20 strncpy(domain
, dot
+1, size
);
21 if (size
> 0) domain
[size
-1]= 0;