. service tells you which device it couldn't stat
[minix3.git] / lib / ip / getdomain.c
blob190d882774dde303639600c0ff31a48e4b4ed20e
1 /* getdomainname() Author: Kees J. Bot
2 * 2 Dec 1994
3 */
4 #define nil 0
5 #include <sys/types.h>
6 #include <sys/utsname.h>
7 #include <unistd.h>
8 #include <string.h>
10 int getdomainname(char *domain, size_t size)
12 char nodename[256];
13 char *dot;
15 if (gethostname(nodename, sizeof(nodename)) < 0)
16 return -1;
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;
22 return 0;