diff options
Diffstat (limited to 'libc-top-half/musl/src/misc/getdomainname.c')
-rw-r--r-- | libc-top-half/musl/src/misc/getdomainname.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/misc/getdomainname.c b/libc-top-half/musl/src/misc/getdomainname.c new file mode 100644 index 0000000..59df566 --- /dev/null +++ b/libc-top-half/musl/src/misc/getdomainname.c @@ -0,0 +1,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; +} |