projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
implement hcreate_r, hdestroy_r and hsearch_r
[oweals/musl.git]
/
src
/
unistd
/
gethostname.c
1
#include <unistd.h>
2
#include <sys/utsname.h>
3
4
int gethostname(char *name, size_t len)
5
{
6
size_t i;
7
struct utsname uts;
8
if (uname(&uts)) return -1;
9
if (len > sizeof uts.nodename) len = sizeof uts.nodename;
10
for (i=0; i<len && (name[i] = uts.nodename[i]); i++);
11
if (i==len) name[i-1] = 0;
12
return 0;
13
}