This commit is contained in:
rsc 2004-04-23 03:50:19 +00:00
parent 49fda441d2
commit d72054aa27
2 changed files with 24 additions and 0 deletions

View file

@ -139,6 +139,7 @@ LIB9OFILES=\
sleep.$O\
strecpy.$O\
sysfatal.$O\
sysname.$O\
tas-$OBJTYPE.$O\
time.$O\
tokenize.$O\

23
src/lib9/sysname.c Normal file
View file

@ -0,0 +1,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";
}