22 lines
728 B
Factor
22 lines
728 B
Factor
! Copyright (C) 2008 Doug Coleman.
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
USING: alien.c-types alien.syntax byte-arrays io
|
|
io.encodings.string io.encodings.utf8 io.streams.byte-array
|
|
kernel sequences splitting strings system system-info unix ;
|
|
IN: system-info.linux
|
|
|
|
FUNCTION-ALIAS: (uname)
|
|
int uname ( c-string buf ) ;
|
|
|
|
: uname ( -- seq )
|
|
65536 <byte-array> [ (uname) io-error ] keep >string
|
|
"\0" split harvest dup length 6 assert= ;
|
|
|
|
: sysname ( -- string ) 0 uname nth ;
|
|
: nodename ( -- string ) 1 uname nth ;
|
|
: release ( -- string ) 2 uname nth ;
|
|
: version ( -- string ) 3 uname nth ;
|
|
: machine ( -- string ) 4 uname nth ;
|
|
: domainname ( -- string ) 5 uname nth ;
|
|
|
|
M: linux os-version release ; |