Xinqi Bao's Git
projects
/
slstatus.git
/ blob
summary
|
log
|
commit
|
diff
|
tree
history
|
raw
|
HEAD
user: Only declare variables in the beginning
[slstatus.git]
/
components
/
hostname.c
1
/* See LICENSE file for copyright and license details. */
2
#include <errno.h>
3
#include <stdio.h>
4
#include <string.h>
5
#include <unistd.h>
6
7
#include
"../util.h"
8
9
const char
*
10
hostname
(
void
)
11
{
12
if
(
gethostname
(
buf
,
sizeof
(
buf
)) == -
1
) {
13
fprintf
(
stderr
,
"gethostbyname: %s
\n
"
,
strerror
(
errno
));
14
return
NULL
;
15
}
16
17
return
buf
;
18
}