{-# LINE 1 "libraries/unix/System/Posix/Env/Internal.hsc" #-}
module System.Posix.Env.Internal where
import Foreign
import Foreign.C
getEnvironmentPrim :: IO [Ptr CChar]
getEnvironmentPrim :: IO [CString]
getEnvironmentPrim = do
Ptr CString
c_environ <- IO (Ptr CString)
getCEnviron
if Ptr CString
c_environ Ptr CString -> Ptr CString -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr CString
forall a. Ptr a
nullPtr
then [CString] -> IO [CString]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return []
else do
CString -> Ptr CString -> IO [CString]
forall a. (Storable a, Eq a) => a -> Ptr a -> IO [a]
peekArray0 CString
forall a. Ptr a
nullPtr Ptr CString
c_environ
getCEnviron :: IO (Ptr CString)
{-# LINE 18 "libraries/unix/System/Posix/Env/Internal.hsc" #-}
getCEnviron :: IO (Ptr CString)
getCEnviron = IO (Ptr (Ptr CString))
nsGetEnviron IO (Ptr (Ptr CString))
-> (Ptr (Ptr CString) -> IO (Ptr CString)) -> IO (Ptr CString)
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr (Ptr CString) -> IO (Ptr CString)
forall a. Storable a => Ptr a -> IO a
peek
foreign import ccall unsafe "_NSGetEnviron"
nsGetEnviron :: IO (Ptr (Ptr CString))
{-# LINE 33 "libraries/unix/System/Posix/Env/Internal.hsc" #-}