aboutsummaryrefslogtreecommitdiffhomepage
path: root/System/Posix/Unistd.hsc
diff options
context:
space:
mode:
authorGravatar simonmar <unknown>2002-12-19 13:52:55 +0000
committerGravatar simonmar <unknown>2002-12-19 13:52:55 +0000
commitf46082b665d7748bdec2981e21d332ee90a7c1cd (patch)
treef6f6b13fc4d7b60694430ccf8be29f97bed2e57d /System/Posix/Unistd.hsc
parent7ad2b37cfbe3977a0a5e69c85941aa84c9e57286 (diff)
[project @ 2002-12-19 13:52:55 by simonmar]
Fill in some more bits in the new Unix library: specifically the contents of PosixTTY and PosixDB (now System.Posix.Terminal and System.Posix.User respectively). We're now about 95% complete w.r.t. the old posix library. I've identified the reminaing bits to do in System/Posix.hs.
Diffstat (limited to 'System/Posix/Unistd.hsc')
-rw-r--r--System/Posix/Unistd.hsc97
1 files changed, 4 insertions, 93 deletions
diff --git a/System/Posix/Unistd.hsc b/System/Posix/Unistd.hsc
index affdc2e..4ae14d4 100644
--- a/System/Posix/Unistd.hsc
+++ b/System/Posix/Unistd.hsc
@@ -14,21 +14,6 @@
-----------------------------------------------------------------------------
module System.Posix.Unistd (
- -- * User environment
- -- * Querying user environment
- getRealUserID,
- getRealGroupID,
- getEffectiveUserID,
- getEffectiveGroupID,
-#if !defined(cygwin32_TARGET_OS)
- getGroups,
-#endif
- getLoginName,
-
- -- * Modifying the user environment
- setUserID,
- setGroupID,
-
-- * System environment
SystemID(..),
getSystemID,
@@ -49,102 +34,25 @@ module System.Posix.Unistd (
-- should be in System.Posix.Files?
pathconf, fpathconf,
- queryTerminal,
- getTerminalName,
-#if !defined(cygwin32_TARGET_OS)
- getControllingTerminalName,
-#endif
-- System.Posix.Signals
ualarm,
- -- System.Posix.Terminal
- isatty, tcgetpgrp, tcsetpgrp, ttyname(_r),
-
-- System.Posix.IO
read, write,
- -- should be in System.Posix.Time?
- epochTime,
-
-- should be in System.Posix.User?
getEffectiveUserName,
-}
) where
-#include "config.h"
+#include "HsUnix.h"
import Foreign
import Foreign.C
import System.Posix.Types
import GHC.Posix
-#include <unistd.h>
-#include <sys/utsname.h>
-
--- -----------------------------------------------------------------------------
--- user environemnt
-
-getRealUserID :: IO UserID
-getRealUserID = c_getuid
-
-foreign import ccall unsafe "getuid"
- c_getuid :: IO CUid
-
-getRealGroupID :: IO GroupID
-getRealGroupID = c_getgid
-
-foreign import ccall unsafe "getgid"
- c_getgid :: IO CGid
-
-getEffectiveUserID :: IO UserID
-getEffectiveUserID = c_geteuid
-
-foreign import ccall unsafe "geteuid"
- c_geteuid :: IO CUid
-
-getEffectiveGroupID :: IO GroupID
-getEffectiveGroupID = c_getegid
-
-foreign import ccall unsafe "getegid"
- c_getegid :: IO CGid
-
--- getgroups() is not supported in beta18 of
--- cygwin32
-#if !defined(cygwin32_TARGET_OS)
-getGroups :: IO [GroupID]
-getGroups = do
- ngroups <- c_getgroups 0 nullPtr
- allocaArray (fromIntegral ngroups) $ \arr -> do
- throwErrnoIfMinus1_ "getGroups" (c_getgroups ngroups arr)
- groups <- peekArray (fromIntegral ngroups) arr
- return groups
-
-foreign import ccall unsafe "getgroups"
- c_getgroups :: CInt -> Ptr CGid -> IO CInt
-#endif
-
--- ToDo: use getlogin_r
-getLoginName :: IO String
-getLoginName = do
- str <- throwErrnoIfNull "getLoginName" c_getlogin
- peekCString str
-
-foreign import ccall unsafe "getlogin"
- c_getlogin :: IO CString
-
-setUserID :: UserID -> IO ()
-setUserID uid = throwErrnoIfMinus1_ "setUserID" (c_setuid uid)
-
-foreign import ccall unsafe "setuid"
- c_setuid :: CUid -> IO CInt
-
-setGroupID :: GroupID -> IO ()
-setGroupID gid = throwErrnoIfMinus1_ "setGroupID" (c_setgid gid)
-
-foreign import ccall unsafe "setgid"
- c_setgid :: CGid -> IO CInt
-
-- -----------------------------------------------------------------------------
-- System environment (uname())
@@ -172,6 +80,9 @@ getSystemID = do
machine = mach
})
+foreign import ccall unsafe "uname"
+ c_uname :: Ptr CUtsname -> IO CInt
+
-- -----------------------------------------------------------------------------
-- sleeping