]> gitweb @ CieloNegro.org - bindings-uname.git/blob - Bindings/Uname.hsc
Doc fix
[bindings-uname.git] / Bindings / Uname.hsc
1 module Bindings.Uname
2     ( Utsname
3     , uname
4
5     , sysname
6     , nodename
7     , release
8     , version
9     , machine
10     )
11     where
12
13 #include <sys/utsname.h>
14
15 import Foreign
16 import Foreign.C
17
18 -- | @'uname' name@ stores nul-terminated strings of information
19 --   identifying the current system info to the structure referenced
20 --   by name.
21 --
22 --   > import Foreign.C
23 --   > import Foreign.Marshal
24 --   >
25 --   > sysName :: IO String
26 --   > sysName = alloca $ \ ptr ->
27 --   >           do throwErrnoIfMinus1_ "uname" $ uname ptr
28 --   >              peekCString $ sysname ptr
29 --
30 foreign import ccall unsafe "sys/utsname.h uname"
31         uname :: Ptr Utsname -> IO CInt
32
33 data Utsname
34
35 instance Storable Utsname where
36     sizeOf    = const #size struct utsname
37     alignment = sizeOf
38     poke      = error "Storable Utsname: peek: unsupported operation"
39     peek      = error "Storable Utsname: poke: unsupported operation"
40
41 sysname :: Ptr Utsname -> CString
42 sysname = (#ptr struct utsname, sysname)
43
44 nodename :: Ptr Utsname -> CString
45 nodename = (#ptr struct utsname, nodename)
46
47 release :: Ptr Utsname -> CString
48 release = (#ptr struct utsname, release)
49
50 version :: Ptr Utsname -> CString
51 version = (#ptr struct utsname, version)
52
53 machine :: Ptr Utsname -> CString
54 machine = (#ptr struct utsname, machine)