You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
312 B

#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;
}