chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
6c5062e81669fd43a0ac4432828ce8b4be2eaf34
[elogind.git]
/
gethostname.c
1
/*
2
* gethostname.c
3
*/
4
5
#include <errno.h>
6
#include <unistd.h>
7
#include <string.h>
8
#include <sys/utsname.h>
9
10
int gethostname(char *name, size_t len)
11
{
12
struct utsname un;
13
14
if ( !uname(&un) )
15
return -1;
16
17
if ( len < strlen(un.nodename)+1 ) {
18
errno = EINVAL;
19
return -1;
20
}
21
22
strcpy(name, un.nodename);
23
24
return 0;
25
}