diff options
author | rsc <devnull@localhost> | 2004-04-23 03:50:19 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-04-23 03:50:19 +0000 |
commit | d72054aa270d6f3d539e830ef9892138a255872a (patch) | |
tree | 635dcd0a193a538703d7d070c73d3d5c115aaebb | |
parent | 49fda441d2d22ec646d02a5159e7f52ab457b314 (diff) | |
download | plan9port-d72054aa270d6f3d539e830ef9892138a255872a.tar.gz plan9port-d72054aa270d6f3d539e830ef9892138a255872a.tar.bz2 plan9port-d72054aa270d6f3d539e830ef9892138a255872a.zip |
add this
-rw-r--r-- | src/lib9/mkfile | 1 | ||||
-rw-r--r-- | src/lib9/sysname.c | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/lib9/mkfile b/src/lib9/mkfile index bdc8841f..6a3b1fca 100644 --- a/src/lib9/mkfile +++ b/src/lib9/mkfile @@ -139,6 +139,7 @@ LIB9OFILES=\ sleep.$O\ strecpy.$O\ sysfatal.$O\ + sysname.$O\ tas-$OBJTYPE.$O\ time.$O\ tokenize.$O\ diff --git a/src/lib9/sysname.c b/src/lib9/sysname.c new file mode 100644 index 00000000..775b6094 --- /dev/null +++ b/src/lib9/sysname.c @@ -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"; +} |