| 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(-)
--- |
| t@@ -0,0 +1,23 @@
+#include
+#include
+
+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";
+} |