Introduction
Introduction Statistics Contact Development Disclaimer Help
sysname.c - 9base - revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log
Files
Refs
README
LICENSE
---
sysname.c (420B)
---
1 #include <u.h>
2 #include <libc.h>
3
4 char*
5 sysname(void)
6 {
7 static char buf[512];
8 char *p, *q;
9
10 if(buf[0])
11 return buf;
12
13 if((q = getenv("sysname")) != nil && q[0] != 0){
14 utfecpy(buf, buf+sizeof buf, q);
15 free(q);
16 return buf;
17 }
18 if(q)
19 free(q);
20
21 if(gethostname(buf, sizeof buf) >= 0){
22 buf[sizeof buf-1] = 0;
23 if((p = strchr(buf, '.')) != nil)
24 *p = 0;
25 return buf;
26 }
27
28 strcpy(buf, "gnot");
29 return buf;
30 }
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.