diff options
Diffstat (limited to 'libc-top-half/musl/src/unistd/gethostname.c')
-rw-r--r-- | libc-top-half/musl/src/unistd/gethostname.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/unistd/gethostname.c b/libc-top-half/musl/src/unistd/gethostname.c new file mode 100644 index 0000000..633ef57 --- /dev/null +++ b/libc-top-half/musl/src/unistd/gethostname.c @@ -0,0 +1,13 @@ +#include <unistd.h> +#include <sys/utsname.h> + +int gethostname(char *name, size_t len) +{ + size_t i; + struct utsname uts; + if (uname(&uts)) return -1; + if (len > sizeof uts.nodename) len = sizeof uts.nodename; + for (i=0; i<len && (name[i] = uts.nodename[i]); i++); + if (i && i==len) name[i-1] = 0; + return 0; +} |