add this
This commit is contained in:
parent
49fda441d2
commit
d72054aa27
2 changed files with 24 additions and 0 deletions
|
|
@ -139,6 +139,7 @@ LIB9OFILES=\
|
||||||
sleep.$O\
|
sleep.$O\
|
||||||
strecpy.$O\
|
strecpy.$O\
|
||||||
sysfatal.$O\
|
sysfatal.$O\
|
||||||
|
sysname.$O\
|
||||||
tas-$OBJTYPE.$O\
|
tas-$OBJTYPE.$O\
|
||||||
time.$O\
|
time.$O\
|
||||||
tokenize.$O\
|
tokenize.$O\
|
||||||
|
|
|
||||||
23
src/lib9/sysname.c
Normal file
23
src/lib9/sysname.c
Normal 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";
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue