blob: 59df566d9465625f28f47dcdaf979cf44c5681a7 (
plain) (
blame)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 | #define _GNU_SOURCE
#include <unistd.h>
#include <sys/utsname.h>
#include <string.h>
#include <errno.h>
int getdomainname(char *name, size_t len)
{
	struct utsname temp;
	uname(&temp);
	if (!len || strlen(temp.domainname) >= len) {
		errno = EINVAL;
		return -1;
	}
	strcpy(name, temp.domainname);
	return 0;
}
 |