Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Hostname/Limbo/hostname.limbo
Normal file
31
Task/Hostname/Limbo/hostname.limbo
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
implement Hostname;
|
||||
|
||||
include "sys.m"; sys: Sys;
|
||||
include "draw.m";
|
||||
|
||||
Hostname: module {
|
||||
init: fn(nil: ref Draw->Context, nil: list of string);
|
||||
};
|
||||
|
||||
init(nil: ref Draw->Context, nil: list of string)
|
||||
{
|
||||
sys = load Sys Sys->PATH;
|
||||
buf := array[Sys->ATOMICIO] of byte;
|
||||
|
||||
fd := sys->open("/dev/sysname", Sys->OREAD);
|
||||
if(fd == nil)
|
||||
die("Couldn't open /dev/sysname");
|
||||
|
||||
n := sys->read(fd, buf, len buf - 1);
|
||||
if(n < 1)
|
||||
die("Couldn't read /dev/sysname");
|
||||
|
||||
buf[n++] = byte '\n';
|
||||
sys->write(sys->fildes(1), buf, n);
|
||||
}
|
||||
|
||||
die(s: string)
|
||||
{
|
||||
sys->fprint(sys->fildes(2), "hostname: %s: %r", s);
|
||||
raise "fail:errors";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue