Unixutils 1.47.1 → 1.48.1
raw patch · 3 files changed
+7/−117 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- System.Unix.QIO: v1 :: MonadIO m => m a -> m a
- System.Unix.QIO: v2 :: MonadIO m => m a -> m a
- System.Unix.QIO: v3 :: MonadIO m => m a -> m a
- System.Unix.Shadow: SUserEntry :: String -> String -> SUserEntry
- System.Unix.Shadow: data SUserEntry
- System.Unix.Shadow: getSUserEntryForName :: String -> IO SUserEntry
- System.Unix.Shadow: instance Eq SUserEntry
- System.Unix.Shadow: instance Read SUserEntry
- System.Unix.Shadow: instance Show SUserEntry
- System.Unix.Shadow: sUserName :: SUserEntry -> String
- System.Unix.Shadow: sUserPassword :: SUserEntry -> String
+ System.Unix.QIO: v1, v3, v2 :: MonadIO m => m a -> m a
Files
- System/Unix/QIO.hs +4/−3
- System/Unix/Shadow.hsc +0/−108
- Unixutils.cabal +3/−6
System/Unix/QIO.hs view
@@ -59,11 +59,11 @@ -- options on the command line. initialQuietness :: MonadIO m => m Int initialQuietness = liftIO $- do v1 <- try (getEnv "VERBOSITY" >>= return . read) >>= either (\ (_ :: SomeException) -> return 0) return- v2 <- getArgs >>= return . length . filter (== "-v")+ do v1' <- try (getEnv "VERBOSITY" >>= return . read) >>= either (\ (_ :: SomeException) -> return 0) return+ v2' <- getArgs >>= return . length . filter (== "-v") q1 <- try (getEnv "QUIETNESS" >>= return . read) >>= either (\ (_ :: SomeException) -> return 0) return q2 <- getArgs >>= return . length . filter (== "-q")- return $ q1 - v1 + q2 - v2+ return $ q1 - v1' + q2 - v2' -- |Get the current quietness level from the QUIETNESS environment variable. quietness :: MonadIO m => m Int@@ -123,6 +123,7 @@ q02 :: MonadIO m => String -> m a -> m a q02 s a = qPutStrLn s >> quieter (+ 2) a +v1, v2, v3 :: (MonadIO m) => m a -> m a v1 a = quieter (\x->x-1) a v2 a = quieter (\x->x-2) a v3 a = quieter (\x->x-3) a
− System/Unix/Shadow.hsc
@@ -1,108 +0,0 @@-{-# LANGUAGE ForeignFunctionInterface #-}--------------------------------------------------------------------------------- |--- Module : System.Unix.Shadow--- Copyright : (c) 2010 Jeremy Shaw, The University of Glasgow--- License : BSD3--- --- Maintainer : jeremy@seereason.com--- Stability : provisional--- Portability : non-portable (requires POSIX)------ support for /etc/shadow------ TODO: This module is modelled after System.Posix.User but lacks many --- of the #ifdefs. Those are probably important.-------------------------------------------------------------------------------module System.Unix.Shadow - ( SUserEntry(..)- , getSUserEntryForName- ) where--import Control.Exception-import Control.Monad-import Foreign-import Foreign.C-import System.Posix.Types-import System.IO.Error--#include "shadow.h"--type CSpwd = ()---- | Entry returned by 'getSUserEntryForName'------ TODO: add other fields-data SUserEntry =- SUserEntry {- sUserName :: String, -- ^ Textual name of this user (pw_name)- sUserPassword :: String -- ^ Password -- may be empty or fake if shadow is in use (pw_passwd)- } deriving (Show, Read, Eq)------ | @getSUserEntryForName name@ calls @getspnam@ to obtain--- the @SUserEntry@ information associated with the user login--- @name@.p-getSUserEntryForName :: String -> IO SUserEntry--- #if HAVE_GETPWNAM_R-getSUserEntryForName name = do- allocaBytes (#const sizeof(struct spwd)) $ \ppw ->- alloca $ \ pppw ->- withCString name $ \ pstr -> do- throwErrorIfNonZero_ "getsUserEntryForName" $- doubleAllocWhile isERANGE pwBufSize $ \s b ->- c_getspnam_r pstr ppw b (fromIntegral s) pppw- r <- peekElemOff pppw 0- when (r == nullPtr) $- ioError $ flip ioeSetErrorString "no user name"- $ mkIOError doesNotExistErrorType- "getUserEntryForName"- Nothing- (Just name)- unpackSUserEntry ppw--foreign import ccall unsafe "getspnam_r"- c_getspnam_r :: CString -> Ptr CSpwd- -> CString -> CSize -> Ptr (Ptr CSpwd) -> IO CInt-{--#elif HAVE_GETPWNAM-getUserEntryForName name = do- withCString name $ \ pstr -> do- withMVar lock $ \_ -> do- ppw <- throwErrnoIfNull "getUserEntryForName" $ c_getpwnam pstr- unpackUserEntry ppw--foreign import ccall unsafe "getpwnam" - c_getpwnam :: CString -> IO (Ptr CPasswd)-#else-getUserEntryForName = error "System.Posix.User.getUserEntryForName: not supported"-#endif--}--unpackSUserEntry :: Ptr CSpwd -> IO SUserEntry-unpackSUserEntry ptr = do- name <- (#peek struct spwd, sp_namp) ptr >>= peekCString- passwd <- (#peek struct spwd, sp_pwdp) ptr >>= peekCString- return (SUserEntry name passwd)--isERANGE :: Integral a => a -> Bool-isERANGE = (== eRANGE) . Errno . fromIntegral--doubleAllocWhile :: (a -> Bool) -> Int -> (Int -> Ptr b -> IO a) -> IO a-doubleAllocWhile p s m = do- r <- allocaBytes s (m s)- if p r then doubleAllocWhile p (2 * s) m else return r---pwBufSize :: Int-pwBufSize = 1024---- Used when calling re-entrant system calls that signal their 'errno' --- directly through the return value.-throwErrorIfNonZero_ :: String -> IO CInt -> IO ()-throwErrorIfNonZero_ loc act = do- rc <- act- if (rc == 0) - then return ()- else ioError (errnoToIOError loc (Errno (fromIntegral rc)) Nothing Nothing)
Unixutils.cabal view
@@ -1,5 +1,5 @@ Name: Unixutils-Version: 1.47.1+Version: 1.48.1 License: BSD3 License-File: COPYING Author: Jeremy Shaw, David Fox@@ -29,14 +29,11 @@ System.Unix.Progress, System.Unix.OldProgress, System.Unix.QIO,- System.Unix.Shadow, System.Unix.SpecialDevice, System.Unix.Files- Extra-libraries: crypt+ if !os(darwin)+ Extra-libraries: crypt Executable unixtutils-test Main-is: Tests.hs Buildable: False---- For more complex build options see:--- http://www.haskell.org/ghc/docs/latest/html/Cabal/