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

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";
}