2008-12-06 23:58:19 -05:00
|
|
|
! Copyright (C) 2008 Doug Coleman.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-05-22 04:42:44 -04:00
|
|
|
USING: unix alien alien.c-types kernel math sequences strings
|
2009-08-31 10:54:35 -04:00
|
|
|
io.backend.unix splitting io.encodings.utf8 io.encodings.string
|
2009-09-09 23:33:34 -04:00
|
|
|
specialized-arrays ;
|
|
|
|
SPECIALIZED-ARRAY: char
|
2008-12-06 23:58:19 -05:00
|
|
|
IN: system-info.linux
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: (uname) ( buf -- int )
|
2009-10-21 19:44:00 -04:00
|
|
|
int f "uname" { char* } alien-invoke ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: uname ( -- seq )
|
2009-08-31 10:54:35 -04:00
|
|
|
65536 <char-array> [ (uname) io-error ] keep
|
2009-02-13 16:52:17 -05:00
|
|
|
"\0" split harvest [ utf8 decode ] map
|
2009-01-29 23:19:07 -05:00
|
|
|
6 "" pad-tail ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: sysname ( -- string ) uname first ;
|
|
|
|
: nodename ( -- string ) uname second ;
|
|
|
|
: release ( -- string ) uname third ;
|
|
|
|
: version ( -- string ) uname fourth ;
|
|
|
|
: machine ( -- string ) uname 4 swap nth ;
|
|
|
|
: domainname ( -- string ) uname 5 swap nth ;
|
|
|
|
|
|
|
|
: kernel-version ( -- seq )
|
2009-01-29 23:19:07 -05:00
|
|
|
release ".-" split harvest 5 "" pad-tail ;
|