1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: unix alien alien.c-types kernel math sequences strings
4 io.backend.unix splitting ;
7 : (uname) ( buf -- int )
8 "int" f "uname" { "char*" } alien-invoke ;
11 65536 "char" <c-array> [ (uname) io-error ] keep
12 "\0" split harvest [ >string ] map
15 : sysname ( -- string ) uname first ;
16 : nodename ( -- string ) uname second ;
17 : release ( -- string ) uname third ;
18 : version ( -- string ) uname fourth ;
19 : machine ( -- string ) uname 4 swap nth ;
20 : domainname ( -- string ) uname 5 swap nth ;
22 : kernel-version ( -- seq )
23 release ".-" split harvest 5 "" pad-right ;