1 changed files with 14 additions and 0 deletions
@ -0,0 +1,14 @@ |
|||||||
|
{-# LANGUAGE NoImplicitPrelude #-} |
||||||
|
|
||||||
|
-- https://hackage.haskell.org/package/unix-2.7.2.2/docs/src/System.Posix.User.html#getLoginName |
||||||
|
|
||||||
|
import Prelude (IO, putStrLn) |
||||||
|
import Control.Monad ((>>=)) |
||||||
|
import Foreign.C (CString, peekCAString, throwErrnoIfNull) |
||||||
|
|
||||||
|
foreign import ccall unsafe "getlogin" |
||||||
|
c_getlogin :: IO CString |
||||||
|
|
||||||
|
main :: IO () |
||||||
|
main = throwErrnoIfNull "getLoginName" c_getlogin >>= peekCAString >>= putStrLn |
||||||
|
|
Loading…
Reference in new issue