tadd this - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit d72054aa270d6f3d539e830ef9892138a255872a
 (DIR) parent 49fda441d2d22ec646d02a5159e7f52ab457b314
 (HTM) Author: rsc <devnull@localhost>
       Date:   Fri, 23 Apr 2004 03:50:19 +0000
       
       add this
       
       Diffstat:
         M src/lib9/mkfile                     |       1 +
         A src/lib9/sysname.c                  |      23 +++++++++++++++++++++++
       
       2 files changed, 24 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/lib9/mkfile b/src/lib9/mkfile
       t@@ -139,6 +139,7 @@ LIB9OFILES=\
                sleep.$O\
                strecpy.$O\
                sysfatal.$O\
       +        sysname.$O\
                tas-$OBJTYPE.$O\
                time.$O\
                tokenize.$O\
 (DIR) diff --git a/src/lib9/sysname.c b/src/lib9/sysname.c
       t@@ -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";
       +}