aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/sysname.c
blob: 775b609496a8bb858f6d4ea893ba807429d6a3ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <u.h>
#include <libc.h>

char*
sysname(void)
{
	char buf[300], *p, *q;

	if((q = getenv("sysname")) == nil){
		if(gethostname(buf, sizeof buf) < 0)
			goto err;
		buf[sizeof buf-1] = 0;
		q = strdup(buf);
		if(q == nil)
			goto err;
	}
	if((p = strchr(q, '.')) != nil)
		*p = 0;
	return q;

err:
	return "gnot";
}