From 078666f4399f368e2f3dd82b5081dc1ad9b9fdc2 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Sat, 6 Dec 2014 17:08:06 +0100 Subject: `M-x untabify` && `M-x delete-trailing-whitespace` --- System/Posix/ByteString/FilePath.hsc | 2 +- System/Posix/Directory.hsc | 60 ++++----- System/Posix/Directory/ByteString.hsc | 54 ++++----- System/Posix/Directory/Common.hsc | 4 +- System/Posix/DynamicLinker.hsc | 14 +-- System/Posix/DynamicLinker/ByteString.hsc | 14 +-- System/Posix/DynamicLinker/Common.hsc | 14 +-- System/Posix/DynamicLinker/Module.hsc | 58 ++++----- System/Posix/DynamicLinker/Module/ByteString.hsc | 28 ++--- System/Posix/DynamicLinker/Prim.hsc | 12 +- System/Posix/Env/ByteString.hsc | 14 +-- System/Posix/Error.hs | 16 +-- System/Posix/Files/ByteString.hsc | 30 ++--- System/Posix/Files/Common.hsc | 66 +++++----- System/Posix/Process.hsc | 34 +++--- System/Posix/Process/Internals.hs | 24 ++-- System/Posix/Resource.hsc | 26 ++-- System/Posix/Semaphore.hsc | 14 +-- System/Posix/Terminal/ByteString.hsc | 2 +- System/Posix/Terminal/Common.hsc | 148 +++++++++++------------ System/Posix/Time.hsc | 10 +- System/Posix/Unistd.hsc | 34 +++--- System/Posix/User.hsc | 30 ++--- 23 files changed, 354 insertions(+), 354 deletions(-) (limited to 'System') diff --git a/System/Posix/ByteString/FilePath.hsc b/System/Posix/ByteString/FilePath.hsc index 318cf14..2b1382d 100644 --- a/System/Posix/ByteString/FilePath.hsc +++ b/System/Posix/ByteString/FilePath.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.ByteString.FilePath -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) diff --git a/System/Posix/Directory.hsc b/System/Posix/Directory.hsc index a615f6f..9dbecb7 100644 --- a/System/Posix/Directory.hsc +++ b/System/Posix/Directory.hsc @@ -8,7 +8,7 @@ -- Module : System.Posix.Directory -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -27,7 +27,7 @@ module System.Posix.Directory ( DirStream, openDirStream, readDirStream, - rewindDirStream, + rewindDirStream, closeDirStream, DirStreamOffset, #ifdef HAVE_TELLDIR @@ -52,13 +52,13 @@ import Foreign.C import System.Posix.Directory.Common import System.Posix.Internals (withFilePath, peekFilePath) --- | @createDirectory dir mode@ calls @mkdir@ to +-- | @createDirectory dir mode@ calls @mkdir@ to -- create a new directory, @dir@, with permissions based on -- @mode@. createDirectory :: FilePath -> FileMode -> IO () createDirectory name mode = - withFilePath name $ \s -> - throwErrnoPathIfMinus1Retry_ "createDirectory" name (c_mkdir s mode) + withFilePath name $ \s -> + throwErrnoPathIfMinus1Retry_ "createDirectory" name (c_mkdir s mode) -- POSIX doesn't allow mkdir() to return EINTR, but it does on -- OS X (#5184), so we need the Retry variant here. @@ -88,19 +88,19 @@ readDirStream (DirStream dirp) = resetErrno r <- c_readdir dirp ptr_dEnt if (r == 0) - then do dEnt <- peek ptr_dEnt - if (dEnt == nullPtr) - then return [] - else do - entry <- (d_name dEnt >>= peekFilePath) - c_freeDirEnt dEnt - return entry - else do errno <- getErrno - if (errno == eINTR) then loop ptr_dEnt else do - let (Errno eo) = errno - if (eo == 0) - then return [] - else throwErrno "readDirStream" + then do dEnt <- peek ptr_dEnt + if (dEnt == nullPtr) + then return [] + else do + entry <- (d_name dEnt >>= peekFilePath) + c_freeDirEnt dEnt + return entry + else do errno <- getErrno + if (errno == eINTR) then loop ptr_dEnt else do + let (Errno eo) = errno + if (eo == 0) + then return [] + else throwErrno "readDirStream" -- traversing directories foreign import ccall unsafe "__hscore_readdir" @@ -120,17 +120,17 @@ getWorkingDirectory = do p <- mallocBytes long_path_size go p long_path_size where go p bytes = do - p' <- c_getcwd p (fromIntegral bytes) - if p' /= nullPtr - then do s <- peekFilePath p' - free p' - return s - else do errno <- getErrno - if errno == eRANGE - then do let bytes' = bytes * 2 - p'' <- reallocBytes p bytes' - go p'' bytes' - else throwErrno "getCurrentDirectory" + p' <- c_getcwd p (fromIntegral bytes) + if p' /= nullPtr + then do s <- peekFilePath p' + free p' + return s + else do errno <- getErrno + if errno == eRANGE + then do let bytes' = bytes * 2 + p'' <- reallocBytes p bytes' + go p'' bytes' + else throwErrno "getCurrentDirectory" foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar) @@ -143,7 +143,7 @@ foreign import ccall unsafe "__hsunix_long_path_size" changeWorkingDirectory :: FilePath -> IO () changeWorkingDirectory path = modifyIOError (`ioeSetFileName` path) $ - withFilePath path $ \s -> + withFilePath path $ \s -> throwErrnoIfMinus1Retry_ "changeWorkingDirectory" (c_chdir s) foreign import ccall unsafe "chdir" diff --git a/System/Posix/Directory/ByteString.hsc b/System/Posix/Directory/ByteString.hsc index 28edd35..232427c 100644 --- a/System/Posix/Directory/ByteString.hsc +++ b/System/Posix/Directory/ByteString.hsc @@ -8,7 +8,7 @@ -- Module : System.Posix.Directory.ByteString -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -27,7 +27,7 @@ module System.Posix.Directory.ByteString ( DirStream, openDirStream, readDirStream, - rewindDirStream, + rewindDirStream, closeDirStream, DirStreamOffset, #ifdef HAVE_TELLDIR @@ -58,8 +58,8 @@ import System.Posix.ByteString.FilePath -- @mode@. createDirectory :: RawFilePath -> FileMode -> IO () createDirectory name mode = - withFilePath name $ \s -> - throwErrnoPathIfMinus1Retry_ "createDirectory" name (c_mkdir s mode) + withFilePath name $ \s -> + throwErrnoPathIfMinus1Retry_ "createDirectory" name (c_mkdir s mode) -- POSIX doesn't allow mkdir() to return EINTR, but it does on -- OS X (#5184), so we need the Retry variant here. @@ -89,19 +89,19 @@ readDirStream (DirStream dirp) = resetErrno r <- c_readdir dirp ptr_dEnt if (r == 0) - then do dEnt <- peek ptr_dEnt - if (dEnt == nullPtr) + then do dEnt <- peek ptr_dEnt + if (dEnt == nullPtr) then return BC.empty - else do - entry <- (d_name dEnt >>= peekFilePath) - c_freeDirEnt dEnt - return entry - else do errno <- getErrno - if (errno == eINTR) then loop ptr_dEnt else do - let (Errno eo) = errno - if (eo == 0) + else do + entry <- (d_name dEnt >>= peekFilePath) + c_freeDirEnt dEnt + return entry + else do errno <- getErrno + if (errno == eINTR) then loop ptr_dEnt else do + let (Errno eo) = errno + if (eo == 0) then return BC.empty - else throwErrno "readDirStream" + else throwErrno "readDirStream" -- traversing directories foreign import ccall unsafe "__hscore_readdir" @@ -121,17 +121,17 @@ getWorkingDirectory = do p <- mallocBytes long_path_size go p long_path_size where go p bytes = do - p' <- c_getcwd p (fromIntegral bytes) - if p' /= nullPtr - then do s <- peekFilePath p' - free p' - return s - else do errno <- getErrno - if errno == eRANGE - then do let bytes' = bytes * 2 - p'' <- reallocBytes p bytes' - go p'' bytes' - else throwErrno "getCurrentDirectory" + p' <- c_getcwd p (fromIntegral bytes) + if p' /= nullPtr + then do s <- peekFilePath p' + free p' + return s + else do errno <- getErrno + if errno == eRANGE + then do let bytes' = bytes * 2 + p'' <- reallocBytes p bytes' + go p'' bytes' + else throwErrno "getCurrentDirectory" foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar) @@ -144,7 +144,7 @@ foreign import ccall unsafe "__hsunix_long_path_size" changeWorkingDirectory :: RawFilePath -> IO () changeWorkingDirectory path = modifyIOError (`ioeSetFileName` (BC.unpack path)) $ - withFilePath path $ \s -> + withFilePath path $ \s -> throwErrnoIfMinus1Retry_ "changeWorkingDirectory" (c_chdir s) foreign import ccall unsafe "chdir" diff --git a/System/Posix/Directory/Common.hsc b/System/Posix/Directory/Common.hsc index 7cc61af..ea43c5c 100644 --- a/System/Posix/Directory/Common.hsc +++ b/System/Posix/Directory/Common.hsc @@ -7,7 +7,7 @@ -- Module : System.Posix.Directory.Common -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -79,7 +79,7 @@ foreign import ccall unsafe "telldir" #endif changeWorkingDirectoryFd :: Fd -> IO () -changeWorkingDirectoryFd (Fd fd) = +changeWorkingDirectoryFd (Fd fd) = throwErrnoIfMinus1Retry_ "changeWorkingDirectoryFd" (c_fchdir fd) foreign import ccall unsafe "fchdir" diff --git a/System/Posix/DynamicLinker.hsc b/System/Posix/DynamicLinker.hsc index 5398f03..b15f507 100644 --- a/System/Posix/DynamicLinker.hsc +++ b/System/Posix/DynamicLinker.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.DynamicLinker -- Copyright : (c) Volker Stolz 2003 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -27,16 +27,16 @@ module System.Posix.DynamicLinker ( -- Usage: -- ****** --- +-- -- Let's assume you want to open a local shared library \'foo\' (.\/libfoo.so) -- offering a function -- @char \* mogrify (char\*,int)@ -- and invoke @str = mogrify("test",1)@: --- --- +-- +-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun --- +-- -- withDL "libfoo.so" [RTLD_NOW] \$ \\ mod -> do -- funptr <- dlsym mod "mogrify" -- let fun = fun__ funptr @@ -44,7 +44,7 @@ module System.Posix.DynamicLinker ( -- strptr <- fun str 1 -- strstr <- peekCString strptr -- ... --- +-- where @@ -54,7 +54,7 @@ import System.Posix.DynamicLinker.Prim #include "HsUnix.h" import Control.Exception ( bracket ) -import Control.Monad ( liftM ) +import Control.Monad ( liftM ) import Foreign import System.Posix.Internals ( withFilePath ) diff --git a/System/Posix/DynamicLinker/ByteString.hsc b/System/Posix/DynamicLinker/ByteString.hsc index 2e9a6b0..b13c808 100644 --- a/System/Posix/DynamicLinker/ByteString.hsc +++ b/System/Posix/DynamicLinker/ByteString.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.DynamicLinker.ByteString -- Copyright : (c) Volker Stolz 2003 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -27,16 +27,16 @@ module System.Posix.DynamicLinker.ByteString ( -- Usage: -- ****** --- +-- -- Let's assume you want to open a local shared library \'foo\' (.\/libfoo.so) -- offering a function -- @char \* mogrify (char\*,int)@ -- and invoke @str = mogrify("test",1)@: --- --- +-- +-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun --- +-- -- withDL "libfoo.so" [RTLD_NOW] \$ \\ mod -> do -- funptr <- dlsym mod "mogrify" -- let fun = fun__ funptr @@ -44,7 +44,7 @@ module System.Posix.DynamicLinker.ByteString ( -- strptr <- fun str 1 -- strstr <- peekCString strptr -- ... --- +-- where @@ -54,7 +54,7 @@ import System.Posix.DynamicLinker.Prim #include "HsUnix.h" import Control.Exception ( bracket ) -import Control.Monad ( liftM ) +import Control.Monad ( liftM ) import Foreign import System.Posix.ByteString.FilePath diff --git a/System/Posix/DynamicLinker/Common.hsc b/System/Posix/DynamicLinker/Common.hsc index 8e1321d..ff36a28 100644 --- a/System/Posix/DynamicLinker/Common.hsc +++ b/System/Posix/DynamicLinker/Common.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.DynamicLinker.Common -- Copyright : (c) Volker Stolz 2003 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -27,16 +27,16 @@ module System.Posix.DynamicLinker.Common ( -- Usage: -- ****** --- +-- -- Let's assume you want to open a local shared library \'foo\' (.\/libfoo.so) -- offering a function -- @char \* mogrify (char\*,int)@ -- and invoke @str = mogrify("test",1)@: --- --- +-- +-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun --- +-- -- withDL "libfoo.so" [RTLD_NOW] \$ \\ mod -> do -- funptr <- dlsym mod "mogrify" -- let fun = fun__ funptr @@ -44,7 +44,7 @@ module System.Posix.DynamicLinker.Common ( -- strptr <- fun str 1 -- strstr <- peekCString strptr -- ... --- +-- where @@ -59,7 +59,7 @@ dlclose (DLHandle h) = throwDLErrorIf_ "dlclose" (/= 0) $ c_dlclose h dlclose h = error $ "dlclose: invalid argument" ++ (show h) dlerror :: IO String -dlerror = c_dlerror >>= peekCString +dlerror = c_dlerror >>= peekCString -- |'dlsym' returns the address binding of the symbol described in @symbol@, -- as it occurs in the shared object identified by @source@. diff --git a/System/Posix/DynamicLinker/Module.hsc b/System/Posix/DynamicLinker/Module.hsc index aa18d83..d971fa7 100644 --- a/System/Posix/DynamicLinker/Module.hsc +++ b/System/Posix/DynamicLinker/Module.hsc @@ -8,7 +8,7 @@ -- Module : System.Posix.DynamicLinker.Module -- Copyright : (c) Volker Stolz 2003 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -23,15 +23,15 @@ module System.Posix.DynamicLinker.Module ( -- Usage: -- ****** --- +-- -- Let's assume you want to open a local shared library 'foo' (./libfoo.so) -- offering a function -- char * mogrify (char*,int) -- and invoke str = mogrify("test",1): --- +-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun --- +-- -- withModule (Just ".") ("libfoo.so") [RTLD_NOW] $ \ mod -> do -- funptr <- moduleSymbol mod "mogrify" -- let fun = fun__ funptr @@ -45,16 +45,16 @@ module System.Posix.DynamicLinker.Module ( , moduleSymbol -- :: Source -> String -> IO (FunPtr a) , moduleClose -- :: Module -> IO Bool , moduleError -- :: IO String - , withModule -- :: Maybe String - -- -> String - -- -> [ModuleFlags ] - -- -> (Module -> IO a) - -- -> IO a - , withModule_ -- :: Maybe String - -- -> String - -- -> [ModuleFlags] - -- -> (Module -> IO a) - -- -> IO () + , withModule -- :: Maybe String + -- -> String + -- -> [ModuleFlags ] + -- -> (Module -> IO a) + -- -> IO a + , withModule_ -- :: Maybe String + -- -> String + -- -> [ModuleFlags] + -- -> (Module -> IO a) + -- -> IO () ) where @@ -84,38 +84,38 @@ moduleSymbol :: Module -> String -> IO (FunPtr a) moduleSymbol file sym = dlsym (DLHandle (unModule file)) sym -- Closes a module (EXPORTED) --- +-- moduleClose :: Module -> IO () moduleClose file = dlclose (DLHandle (unModule file)) -- Gets a string describing the last module error (EXPORTED) --- +-- moduleError :: IO String moduleError = dlerror -- Convenience function, cares for module open- & closing -- additionally returns status of `moduleClose' (EXPORTED) --- -withModule :: Maybe String - -> String - -> [RTLDFlags] - -> (Module -> IO a) - -> IO a +-- +withModule :: Maybe String + -> String + -> [RTLDFlags] + -> (Module -> IO a) + -> IO a withModule mdir file flags p = do let modPath = case mdir of Nothing -> file - Just dir -> dir ++ if ((head (reverse dir)) == '/') + Just dir -> dir ++ if ((head (reverse dir)) == '/') then file - else ('/':file) + else ('/':file) modu <- moduleOpen modPath flags result <- p modu moduleClose modu return result -withModule_ :: Maybe String - -> String - -> [RTLDFlags] - -> (Module -> IO a) - -> IO () +withModule_ :: Maybe String + -> String + -> [RTLDFlags] + -> (Module -> IO a) + -> IO () withModule_ dir file flags p = withModule dir file flags p >>= \ _ -> return () diff --git a/System/Posix/DynamicLinker/Module/ByteString.hsc b/System/Posix/DynamicLinker/Module/ByteString.hsc index dc0832a..325dae3 100644 --- a/System/Posix/DynamicLinker/Module/ByteString.hsc +++ b/System/Posix/DynamicLinker/Module/ByteString.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.DynamicLinker.Module.ByteString -- Copyright : (c) Volker Stolz 2003 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -21,15 +21,15 @@ module System.Posix.DynamicLinker.Module.ByteString ( -- Usage: -- ****** --- +-- -- Let's assume you want to open a local shared library 'foo' (./libfoo.so) -- offering a function -- char * mogrify (char*,int) -- and invoke str = mogrify("test",1): --- +-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun --- +-- -- withModule (Just ".") ("libfoo.so") [RTLD_NOW] $ \ mod -> do -- funptr <- moduleSymbol mod "mogrify" -- let fun = fun__ funptr @@ -43,16 +43,16 @@ module System.Posix.DynamicLinker.Module.ByteString ( , moduleSymbol -- :: Source -> String -> IO (FunPtr a) , moduleClose -- :: Module -> IO Bool , moduleError -- :: IO String - , withModule -- :: Maybe String - -- -> String - -- -> [ModuleFlags ] - -- -> (Module -> IO a) - -- -> IO a - , withModule_ -- :: Maybe String - -- -> String - -- -> [ModuleFlags] - -- -> (Module -> IO a) - -- -> IO () + , withModule -- :: Maybe String + -- -> String + -- -> [ModuleFlags ] + -- -> (Module -> IO a) + -- -> IO a + , withModule_ -- :: Maybe String + -- -> String + -- -> [ModuleFlags] + -- -> (Module -> IO a) + -- -> IO () ) where diff --git a/System/Posix/DynamicLinker/Prim.hsc b/System/Posix/DynamicLinker/Prim.hsc index 9e4dde7..e737918 100644 --- a/System/Posix/DynamicLinker/Prim.hsc +++ b/System/Posix/DynamicLinker/Prim.hsc @@ -9,7 +9,7 @@ -- Module : System.Posix.DynamicLinker.Prim -- Copyright : (c) Volker Stolz 2003 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -39,10 +39,10 @@ where #include "HsUnix.h" -import Data.Bits ( (.|.) ) -import Foreign.Ptr ( Ptr, FunPtr, nullPtr ) +import Data.Bits ( (.|.) ) +import Foreign.Ptr ( Ptr, FunPtr, nullPtr ) import Foreign.C.Types -import Foreign.C.String ( CString ) +import Foreign.C.String ( CString ) -- |On some hosts (e.g. SuSe and Ubuntu Linux) 'RTLD_NEXT' (and @@ -75,10 +75,10 @@ haveRtldLocal = True -- |Flags for 'System.Posix.DynamicLinker.dlopen'. -data RTLDFlags +data RTLDFlags = RTLD_LAZY | RTLD_NOW - | RTLD_GLOBAL + | RTLD_GLOBAL | RTLD_LOCAL deriving (Show, Read) diff --git a/System/Posix/Env/ByteString.hsc b/System/Posix/Env/ByteString.hsc index 1346a77..9f69c4c 100644 --- a/System/Posix/Env/ByteString.hsc +++ b/System/Posix/Env/ByteString.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.Env.ByteString -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -18,10 +18,10 @@ module System.Posix.Env.ByteString ( -- * Environment Variables getEnv - , getEnvDefault - , getEnvironmentPrim - , getEnvironment - , putEnv + , getEnvDefault + , getEnvironmentPrim + , getEnvironment + , putEnv , setEnv , unsetEnv @@ -34,7 +34,7 @@ module System.Posix.Env.ByteString ( import Foreign import Foreign.C import Control.Monad ( liftM ) -import Data.Maybe ( fromMaybe ) +import Data.Maybe ( fromMaybe ) import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as BC @@ -130,7 +130,7 @@ setEnv key value ovrwrt = do B.useAsCString key $ \ keyP -> B.useAsCString value $ \ valueP -> throwErrnoIfMinus1_ "setenv" $ - c_setenv keyP valueP (fromIntegral (fromEnum ovrwrt)) + c_setenv keyP valueP (fromIntegral (fromEnum ovrwrt)) foreign import ccall unsafe "setenv" c_setenv :: CString -> CString -> CInt -> IO CInt diff --git a/System/Posix/Error.hs b/System/Posix/Error.hs index 0a25777..db4b5a9 100644 --- a/System/Posix/Error.hs +++ b/System/Posix/Error.hs @@ -7,7 +7,7 @@ -- Module : System.Posix.Error -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -17,14 +17,14 @@ ----------------------------------------------------------------------------- module System.Posix.Error ( - throwErrnoPath, - throwErrnoPathIf, - throwErrnoPathIf_, + throwErrnoPath, + throwErrnoPathIf, + throwErrnoPathIf_, throwErrnoPathIfRetry, - throwErrnoPathIfNull, - throwErrnoPathIfNullRetry, - throwErrnoPathIfMinus1, - throwErrnoPathIfMinus1_, + throwErrnoPathIfNull, + throwErrnoPathIfNullRetry, + throwErrnoPathIfMinus1, + throwErrnoPathIfMinus1_, throwErrnoPathIfMinus1Retry, throwErrnoPathIfMinus1Retry_ ) where diff --git a/System/Posix/Files/ByteString.hsc b/System/Posix/Files/ByteString.hsc index ec58cb1..0d19ae8 100644 --- a/System/Posix/Files/ByteString.hsc +++ b/System/Posix/Files/ByteString.hsc @@ -8,7 +8,7 @@ -- Module : System.Posix.Files.ByteString -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -62,7 +62,7 @@ module System.Posix.Files.ByteString ( isDirectory, isSymbolicLink, isSocket, -- * Creation - createNamedPipe, + createNamedPipe, createDevice, -- * Hard links @@ -143,7 +143,7 @@ fileAccess name readOK writeOK execOK = access name flags -- -- Note: calls @access@. fileExist :: RawFilePath -> IO Bool -fileExist name = +fileExist name = withFilePath name $ \s -> do r <- c_access s (#const F_OK) if (r == 0) @@ -154,7 +154,7 @@ fileExist name = else throwErrnoPath "fileExist" name access :: RawFilePath -> CMode -> IO Bool -access name flags = +access name flags = withFilePath name $ \s -> do r <- c_access s (fromIntegral flags) if (r == 0) @@ -172,9 +172,9 @@ access name flags = -- Note: calls @stat@. getFileStatus :: RawFilePath -> IO FileStatus getFileStatus path = do - fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) + fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) withForeignPtr fp $ \p -> - withFilePath path $ \s -> + withFilePath path $ \s -> throwErrnoPathIfMinus1Retry_ "getFileStatus" path (c_stat s p) return (FileStatus fp) @@ -185,9 +185,9 @@ getFileStatus path = do -- Note: calls @lstat@. getSymbolicLinkStatus :: RawFilePath -> IO FileStatus getSymbolicLinkStatus path = do - fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) + fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) withForeignPtr fp $ \p -> - withFilePath path $ \s -> + withFilePath path $ \s -> throwErrnoPathIfMinus1_ "getSymbolicLinkStatus" path (c_lstat s p) return (FileStatus fp) @@ -203,7 +203,7 @@ foreign import ccall unsafe "__hsunix_lstat" -- Note: calls @mkfifo@. createNamedPipe :: RawFilePath -> FileMode -> IO () createNamedPipe name mode = do - withFilePath name $ \s -> + withFilePath name $ \s -> throwErrnoPathIfMinus1_ "createNamedPipe" name (c_mkfifo s mode) -- | @createDevice path mode dev@ creates either a regular or a special file @@ -219,7 +219,7 @@ createDevice path mode dev = withFilePath path $ \s -> throwErrnoPathIfMinus1_ "createDevice" path (c_mknod s mode dev) -foreign import ccall unsafe "__hsunix_mknod" +foreign import ccall unsafe "__hsunix_mknod" c_mknod :: CString -> CMode -> CDev -> IO CInt -- ----------------------------------------------------------------------------- @@ -278,7 +278,7 @@ readSymbolicLink :: RawFilePath -> IO RawFilePath readSymbolicLink file = allocaArray0 (#const PATH_MAX) $ \buf -> do withFilePath file $ \s -> do - len <- throwErrnoPathIfMinus1 "readSymbolicLink" file $ + len <- throwErrnoPathIfMinus1 "readSymbolicLink" file $ c_readlink s buf (#const PATH_MAX) peekFilePathLen (buf,fromIntegral len) @@ -419,7 +419,7 @@ touchSymbolicLink = -- -- Note: calls @truncate@. setFileSize :: RawFilePath -> FileOffset -> IO () -setFileSize file off = +setFileSize file off = withFilePath file $ \s -> throwErrnoPathIfMinus1_ "setFileSize" file (c_truncate s off) @@ -438,9 +438,9 @@ foreign import capi unsafe "HsUnix.h truncate" -- Note: calls @pathconf@. getPathVar :: RawFilePath -> PathVar -> IO Limit getPathVar name v = do - withFilePath name $ \ nameP -> - throwErrnoPathIfMinus1 "getPathVar" name $ + withFilePath name $ \ nameP -> + throwErrnoPathIfMinus1 "getPathVar" name $ c_pathconf nameP (pathVarConst v) -foreign import ccall unsafe "pathconf" +foreign import ccall unsafe "pathconf" c_pathconf :: CString -> CInt -> IO CLong diff --git a/System/Posix/Files/Common.hsc b/System/Posix/Files/Common.hsc index 62fff6b..586b417 100644 --- a/System/Posix/Files/Common.hsc +++ b/System/Posix/Files/Common.hsc @@ -159,8 +159,8 @@ setGroupIDMode = (#const S_ISGID) -- | Owner, group and others have read and write permission. stdFileMode :: FileMode stdFileMode = ownerReadMode .|. ownerWriteMode .|. - groupReadMode .|. groupWriteMode .|. - otherReadMode .|. otherWriteMode + groupReadMode .|. groupWriteMode .|. + otherReadMode .|. otherWriteMode -- | Owner has read, write and execute permission. ownerModes :: FileMode @@ -534,67 +534,67 @@ setFdSize (Fd fd) off = -- pathconf()/fpathconf() support data PathVar - = FileSizeBits {- _PC_FILESIZEBITS -} + = FileSizeBits {- _PC_FILESIZEBITS -} | LinkLimit {- _PC_LINK_MAX -} | InputLineLimit {- _PC_MAX_CANON -} | InputQueueLimit {- _PC_MAX_INPUT -} | FileNameLimit {- _PC_NAME_MAX -} | PathNameLimit {- _PC_PATH_MAX -} | PipeBufferLimit {- _PC_PIPE_BUF -} - -- These are described as optional in POSIX: - {- _PC_ALLOC_SIZE_MIN -} - {- _PC_REC_INCR_XFER_SIZE -} - {- _PC_REC_MAX_XFER_SIZE -} - {- _PC_REC_MIN_XFER_SIZE -} - {- _PC_REC_XFER_ALIGN -} - | SymbolicLinkLimit {- _PC_SYMLINK_MAX -} + -- These are described as optional in POSIX: + {- _PC_ALLOC_SIZE_MIN -} + {- _PC_REC_INCR_XFER_SIZE -} + {- _PC_REC_MAX_XFER_SIZE -} + {- _PC_REC_MIN_XFER_SIZE -} + {- _PC_REC_XFER_ALIGN -} + | SymbolicLinkLimit {- _PC_SYMLINK_MAX -} | SetOwnerAndGroupIsRestricted {- _PC_CHOWN_RESTRICTED -} | FileNamesAreNotTruncated {- _PC_NO_TRUNC -} - | VDisableChar {- _PC_VDISABLE -} - | AsyncIOAvailable {- _PC_ASYNC_IO -} - | PrioIOAvailable {- _PC_PRIO_IO -} - | SyncIOAvailable {- _PC_SYNC_IO -} + | VDisableChar {- _PC_VDISABLE -} + | AsyncIOAvailable {- _PC_ASYNC_IO -} + | PrioIOAvailable {- _PC_PRIO_IO -} + | SyncIOAvailable {- _PC_SYNC_IO -} pathVarConst :: PathVar -> CInt pathVarConst v = case v of - LinkLimit -> (#const _PC_LINK_MAX) - InputLineLimit -> (#const _PC_MAX_CANON) - InputQueueLimit -> (#const _PC_MAX_INPUT) - FileNameLimit -> (#const _PC_NAME_MAX) - PathNameLimit -> (#const _PC_PATH_MAX) - PipeBufferLimit -> (#const _PC_PIPE_BUF) - SetOwnerAndGroupIsRestricted -> (#const _PC_CHOWN_RESTRICTED) - FileNamesAreNotTruncated -> (#const _PC_NO_TRUNC) - VDisableChar -> (#const _PC_VDISABLE) + LinkLimit -> (#const _PC_LINK_MAX) + InputLineLimit -> (#const _PC_MAX_CANON) + InputQueueLimit -> (#const _PC_MAX_INPUT) + FileNameLimit -> (#const _PC_NAME_MAX) + PathNameLimit -> (#const _PC_PATH_MAX) + PipeBufferLimit -> (#const _PC_PIPE_BUF) + SetOwnerAndGroupIsRestricted -> (#const _PC_CHOWN_RESTRICTED) + FileNamesAreNotTruncated -> (#const _PC_NO_TRUNC) + VDisableChar -> (#const _PC_VDISABLE) #ifdef _PC_SYNC_IO - SyncIOAvailable -> (#const _PC_SYNC_IO) + SyncIOAvailable -> (#const _PC_SYNC_IO) #else - SyncIOAvailable -> error "_PC_SYNC_IO not available" + SyncIOAvailable -> error "_PC_SYNC_IO not available" #endif #ifdef _PC_ASYNC_IO - AsyncIOAvailable -> (#const _PC_ASYNC_IO) + AsyncIOAvailable -> (#const _PC_ASYNC_IO) #else - AsyncIOAvailable -> error "_PC_ASYNC_IO not available" + AsyncIOAvailable -> error "_PC_ASYNC_IO not available" #endif #ifdef _PC_PRIO_IO - PrioIOAvailable -> (#const _PC_PRIO_IO) + PrioIOAvailable -> (#const _PC_PRIO_IO) #else - PrioIOAvailable -> error "_PC_PRIO_IO not available" + PrioIOAvailable -> error "_PC_PRIO_IO not available" #endif #if _PC_FILESIZEBITS - FileSizeBits -> (#const _PC_FILESIZEBITS) + FileSizeBits -> (#const _PC_FILESIZEBITS) #else - FileSizeBits -> error "_PC_FILESIZEBITS not available" + FileSizeBits -> error "_PC_FILESIZEBITS not available" #endif #if _PC_SYMLINK_MAX - SymbolicLinkLimit -> (#const _PC_SYMLINK_MAX) + SymbolicLinkLimit -> (#const _PC_SYMLINK_MAX) #else - SymbolicLinkLimit -> error "_PC_SYMLINK_MAX not available" + SymbolicLinkLimit -> error "_PC_SYMLINK_MAX not available" #endif -- | @getFdPathVar var fd@ obtains the dynamic value of the requested diff --git a/System/Posix/Process.hsc b/System/Posix/Process.hsc index 2acb57e..7d356c1 100644 --- a/System/Posix/Process.hsc +++ b/System/Posix/Process.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.Process -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -25,7 +25,7 @@ module System.Posix.Process ( forkProcessWithUnmask, #endif executeFile, - + -- ** Exiting exitImmediately, @@ -86,21 +86,21 @@ import System.Posix.Internals ( withFilePath ) -- environment is provided to supersede the process's current -- environment. The basename (leading directory names suppressed) of -- the command is passed to @execv*@ as @arg[0]@; --- the argument list passed to 'executeFile' therefore +-- the argument list passed to 'executeFile' therefore -- begins with @arg[1]@. -executeFile :: FilePath -- ^ Command - -> Bool -- ^ Search PATH? - -> [String] -- ^ Arguments - -> Maybe [(String, String)] -- ^ Environment +executeFile :: FilePath -- ^ Command + -> Bool -- ^ Search PATH? + -> [String] -- ^ Arguments + -> Maybe [(String, String)] -- ^ Environment -> IO a executeFile path search args Nothing = do withFilePath path $ \s -> withMany withFilePath (path:args) $ \cstrs -> withArray0 nullPtr cstrs $ \arr -> do - pPrPr_disableITimers - if search - then throwErrnoPathIfMinus1_ "executeFile" path (c_execvp s arr) - else throwErrnoPathIfMinus1_ "executeFile" path (c_execv s arr) + pPrPr_disableITimers + if search + then throwErrnoPathIfMinus1_ "executeFile" path (c_execvp s arr) + else throwErrnoPathIfMinus1_ "executeFile" path (c_execv s arr) return undefined -- never reached executeFile path search args (Just env) = do @@ -110,12 +110,12 @@ executeFile path search args (Just env) = do let env' = map (\ (name, val) -> name ++ ('=' : val)) env in withMany withFilePath env' $ \cenv -> withArray0 nullPtr cenv $ \env_arr -> do - pPrPr_disableITimers - if search - then throwErrnoPathIfMinus1_ "executeFile" path - (c_execvpe s arg_arr env_arr) - else throwErrnoPathIfMinus1_ "executeFile" path - (c_execve s arg_arr env_arr) + pPrPr_disableITimers + if search + then throwErrnoPathIfMinus1_ "executeFile" path + (c_execvpe s arg_arr env_arr) + else throwErrnoPathIfMinus1_ "executeFile" path + (c_execve s arg_arr env_arr) return undefined -- never reached foreign import ccall unsafe "execvp" diff --git a/System/Posix/Process/Internals.hs b/System/Posix/Process/Internals.hs index b320dc7..19dc1c1 100644 --- a/System/Posix/Process/Internals.hs +++ b/System/Posix/Process/Internals.hs @@ -39,25 +39,25 @@ decipherWaitStatus wstat = then do let exitstatus = c_WEXITSTATUS wstat if exitstatus == 0 - then return (Exited ExitSuccess) - else return (Exited (ExitFailure (fromIntegral exitstatus))) + then return (Exited ExitSuccess) + else return (Exited (ExitFailure (fromIntegral exitstatus))) else do if c_WIFSIGNALED wstat /= 0 - then do + then do let termsig = c_WTERMSIG wstat let coredumped = c_WCOREDUMP wstat /= 0 return (Terminated termsig coredumped) - else do - if c_WIFSTOPPED wstat /= 0 - then do - let stopsig = c_WSTOPSIG wstat + else do + if c_WIFSTOPPED wstat /= 0 + then do + let stopsig = c_WSTOPSIG wstat return (Stopped stopsig) - else do - ioError (mkIOError illegalOperationErrorType - "waitStatus" Nothing Nothing) + else do + ioError (mkIOError illegalOperationErrorType + "waitStatus" Nothing Nothing) foreign import ccall unsafe "__hsunix_wifexited" - c_WIFEXITED :: CInt -> CInt + c_WIFEXITED :: CInt -> CInt foreign import ccall unsafe "__hsunix_wexitstatus" c_WEXITSTATUS :: CInt -> CInt @@ -66,7 +66,7 @@ foreign import ccall unsafe "__hsunix_wifsignaled" c_WIFSIGNALED :: CInt -> CInt foreign import ccall unsafe "__hsunix_wtermsig" - c_WTERMSIG :: CInt -> CInt + c_WTERMSIG :: CInt -> CInt foreign import ccall unsafe "__hsunix_wifstopped" c_WIFSTOPPED :: CInt -> CInt diff --git a/System/Posix/Resource.hsc b/System/Posix/Resource.hsc index 23d2ad4..b610f5b 100644 --- a/System/Posix/Resource.hsc +++ b/System/Posix/Resource.hsc @@ -69,9 +69,9 @@ getResourceLimit res = do soft <- (#peek struct rlimit, rlim_cur) p_rlimit hard <- (#peek struct rlimit, rlim_max) p_rlimit return (ResourceLimits { - softLimit = unpackRLimit soft, - hardLimit = unpackRLimit hard - }) + softLimit = unpackRLimit soft, + hardLimit = unpackRLimit hard + }) setResourceLimit :: Resource -> ResourceLimits -> IO () setResourceLimit res ResourceLimits{softLimit=soft,hardLimit=hard} = do @@ -79,7 +79,7 @@ setResourceLimit res ResourceLimits{softLimit=soft,hardLimit=hard} = do (#poke struct rlimit, rlim_cur) p_rlimit (packRLimit soft True) (#poke struct rlimit, rlim_max) p_rlimit (packRLimit hard False) throwErrnoIfMinus1_ "setResourceLimit" $ - c_setrlimit (packResource res) p_rlimit + c_setrlimit (packResource res) p_rlimit return () packResource :: Resource -> CInt @@ -126,14 +126,14 @@ import Control.Monad main = do zipWithM_ (\r n -> setResourceLimit r ResourceLimits{ - hardLimit = ResourceLimit n, - softLimit = ResourceLimit n }) - allResources [1..] + hardLimit = ResourceLimit n, + softLimit = ResourceLimit n }) + allResources [1..] showAll mapM_ (\r -> setResourceLimit r ResourceLimits{ - hardLimit = ResourceLimit 1, - softLimit = ResourceLimitInfinity }) - allResources + hardLimit = ResourceLimit 1, + softLimit = ResourceLimitInfinity }) + allResources -- should fail @@ -142,11 +142,11 @@ showAll = allResources = [ResourceCoreFileSize, ResourceCPUTime, ResourceDataSize, - ResourceFileSize, ResourceOpenFiles, ResourceStackSize + ResourceFileSize, ResourceOpenFiles, ResourceStackSize #ifdef RLIMIT_AS - , ResourceTotalMemory + , ResourceTotalMemory #endif - ] + ] showRLims ResourceLimits{hardLimit=h,softLimit=s} = "hard: " ++ showRLim h ++ ", soft: " ++ showRLim s diff --git a/System/Posix/Semaphore.hsc b/System/Posix/Semaphore.hsc index cef2f36..541bbdb 100644 --- a/System/Posix/Semaphore.hsc +++ b/System/Posix/Semaphore.hsc @@ -16,8 +16,8 @@ ----------------------------------------------------------------------------- module System.Posix.Semaphore - (OpenSemFlags(..), Semaphore(), - semOpen, semUnlink, semWait, semTryWait, semThreadWait, + (OpenSemFlags(..), Semaphore(), + semOpen, semUnlink, semWait, semTryWait, semThreadWait, semPost, semGetValue) where @@ -44,14 +44,14 @@ data OpenSemFlags = OpenSemFlags { semCreate :: Bool, newtype Semaphore = Semaphore (ForeignPtr ()) --- | Open a named semaphore with the given name, flags, mode, and initial +-- | Open a named semaphore with the given name, flags, mode, and initial -- value. semOpen :: String -> OpenSemFlags -> FileMode -> Int -> IO Semaphore semOpen name flags mode value = let cflags = (if semCreate flags then #{const O_CREAT} else 0) .|. (if semExclusive flags then #{const O_EXCL} else 0) semOpen' cname = - do sem <- throwErrnoPathIfNull "semOpen" name $ + do sem <- throwErrnoPathIfNull "semOpen" name $ sem_open cname (toEnum cflags) mode (toEnum value) fptr <- newForeignPtr sem (finalize sem) return $ Semaphore fptr @@ -68,7 +68,7 @@ semUnlink name = withCAString name semUnlink' -- | Lock the semaphore, blocking until it becomes available. Since this -- is done through a system call, this will block the *entire runtime*, -- not just the current thread. If this is not the behaviour you want, --- use semThreadWait instead. +-- use semThreadWait instead. semWait :: Semaphore -> IO () semWait (Semaphore fptr) = withForeignPtr fptr semWait' where semWait' sem = throwErrnoIfMinus1Retry_ "semWait" $ @@ -81,13 +81,13 @@ semTryWait (Semaphore fptr) = withForeignPtr fptr semTrywait' where semTrywait' sem = do res <- sem_trywait sem (if res == 0 then return True else do errno <- getErrno - (if errno == eINTR + (if errno == eINTR then semTrywait' sem else if errno == eAGAIN then return False else throwErrno "semTrywait")) --- | Poll the semaphore until it is available, then lock it. Unlike +-- | Poll the semaphore until it is available, then lock it. Unlike -- semWait, this will block only the current thread rather than the -- entire process. semThreadWait :: Semaphore -> IO () diff --git a/System/Posix/Terminal/ByteString.hsc b/System/Posix/Terminal/ByteString.hsc index ad2dd26..df851f5 100644 --- a/System/Posix/Terminal/ByteString.hsc +++ b/System/Posix/Terminal/ByteString.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.Terminal.ByteString -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) diff --git a/System/Posix/Terminal/Common.hsc b/System/Posix/Terminal/Common.hsc index e43a59a..2f6327a 100644 --- a/System/Posix/Terminal/Common.hsc +++ b/System/Posix/Terminal/Common.hsc @@ -7,7 +7,7 @@ -- Module : System.Posix.Terminal.Common -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -92,44 +92,44 @@ withTerminalAttributes (TerminalAttributes termios) = withForeignPtr termios data TerminalMode - -- input flags - = InterruptOnBreak -- BRKINT - | MapCRtoLF -- ICRNL - | IgnoreBreak -- IGNBRK - | IgnoreCR -- IGNCR - | IgnoreParityErrors -- IGNPAR - | MapLFtoCR -- INLCR - | CheckParity -- INPCK - | StripHighBit -- ISTRIP - | StartStopInput -- IXOFF - | StartStopOutput -- IXON - | MarkParityErrors -- PARMRK - - -- output flags - | ProcessOutput -- OPOST - -- ToDo: ONLCR, OCRNL, ONOCR, ONLRET, OFILL, - -- NLDLY(NL0,NL1), CRDLY(CR0,CR1,CR2,CR2) - -- TABDLY(TAB0,TAB1,TAB2,TAB3) - -- BSDLY(BS0,BS1), VTDLY(VT0,VT1), FFDLY(FF0,FF1) - - -- control flags - | LocalMode -- CLOCAL - | ReadEnable -- CREAD - | TwoStopBits -- CSTOPB - | HangupOnClose -- HUPCL - | EnableParity -- PARENB - | OddParity -- PARODD - - -- local modes - | EnableEcho -- ECHO - | EchoErase -- ECHOE - | EchoKill -- ECHOK - | EchoLF -- ECHONL - | ProcessInput -- ICANON - | ExtendedFunctions -- IEXTEN - | KeyboardInterrupts -- ISIG - | NoFlushOnInterrupt -- NOFLSH - | BackgroundWriteInterrupt -- TOSTOP + -- input flags + = InterruptOnBreak -- BRKINT + | MapCRtoLF -- ICRNL + | IgnoreBreak -- IGNBRK + | IgnoreCR -- IGNCR + | IgnoreParityErrors -- IGNPAR + | MapLFtoCR -- INLCR + | CheckParity -- INPCK + | StripHighBit -- ISTRIP + | StartStopInput -- IXOFF + | StartStopOutput -- IXON + | MarkParityErrors -- PARMRK + + -- output flags + | ProcessOutput -- OPOST + -- ToDo: ONLCR, OCRNL, ONOCR, ONLRET, OFILL, + -- NLDLY(NL0,NL1), CRDLY(CR0,CR1,CR2,CR2) + -- TABDLY(TAB0,TAB1,TAB2,TAB3) + -- BSDLY(BS0,BS1), VTDLY(VT0,VT1), FFDLY(FF0,FF1) + + -- control flags + | LocalMode -- CLOCAL + | ReadEnable -- CREAD + | TwoStopBits -- CSTOPB + | HangupOnClose -- HUPCL + | EnableParity -- PARENB + | OddParity -- PARODD + + -- local modes + | EnableEcho -- ECHO + | EchoErase -- ECHOE + | EchoKill -- ECHOK + | EchoLF -- ECHONL + | ProcessInput -- ICANON + | ExtendedFunctions -- IEXTEN + | KeyboardInterrupts -- ISIG + | NoFlushOnInterrupt -- NOFLSH + | BackgroundWriteInterrupt -- TOSTOP withoutMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes withoutMode termios InterruptOnBreak = clearInputFlag (#const BRKINT) termios @@ -226,11 +226,11 @@ bitsPerByte termios = unsafePerformIO $ do where word2Bits :: CTcflag -> Int word2Bits x = - if x == (#const CS5) then 5 - else if x == (#const CS6) then 6 - else if x == (#const CS7) then 7 - else if x == (#const CS8) then 8 - else 0 + if x == (#const CS5) then 5 + else if x == (#const CS6) then 6 + else if x == (#const CS7) then 7 + else if x == (#const CS8) then 8 + else 0 withBits :: TerminalAttributes -> Int -> TerminalAttributes withBits termios bits = unsafePerformIO $ do @@ -247,15 +247,15 @@ withBits termios bits = unsafePerformIO $ do mask _ = error "withBits bit value out of range [5..8]" data ControlCharacter - = EndOfFile -- VEOF - | EndOfLine -- VEOL - | Erase -- VERASE - | Interrupt -- VINTR - | Kill -- VKILL - | Quit -- VQUIT - | Start -- VSTART - | Stop -- VSTOP - | Suspend -- VSUSP + = EndOfFile -- VEOF + | EndOfLine -- VEOL + | Erase -- VERASE + | Interrupt -- VINTR + | Kill -- VKILL + | Quit -- VQUIT + | Start -- VSTART + | Stop -- VSTOP + | Suspend -- VSUSP controlChar :: TerminalAttributes -> ControlCharacter -> Maybe Char controlChar termios cc = unsafePerformIO $ do @@ -265,7 +265,7 @@ controlChar termios cc = unsafePerformIO $ do if val == ((#const _POSIX_VDISABLE)::CCc) then return Nothing else return (Just (chr (fromEnum val))) - + withCC :: TerminalAttributes -> (ControlCharacter, Char) -> TerminalAttributes @@ -416,9 +416,9 @@ foreign import capi unsafe "termios.h tcdrain" data QueueSelector - = InputQueue -- TCIFLUSH - | OutputQueue -- TCOFLUSH - | BothQueues -- TCIOFLUSH + = InputQueue -- TCIFLUSH + | OutputQueue -- TCOFLUSH + | BothQueues -- TCIOFLUSH -- | @discardData fd queues@ calls @tcflush@ to discard -- pending input and\/or output for @Fd@ @fd@, @@ -436,12 +436,12 @@ foreign import capi unsafe "termios.h tcflush" c_tcflush :: CInt -> CInt -> IO CInt data FlowAction - = SuspendOutput -- ^ TCOOFF - | RestartOutput -- ^ TCOON - | TransmitStop -- ^ TCIOFF - | TransmitStart -- ^ TCION + = SuspendOutput -- ^ TCOOFF + | RestartOutput -- ^ TCOON + | TransmitStop -- ^ TCIOFF + | TransmitStart -- ^ TCION --- | @controlFlow fd action@ calls @tcflow@ to control the +-- | @controlFlow fd action@ calls @tcflow@ to control the -- flow of data on @Fd@ @fd@, as indicated by -- @action@. controlFlow :: Fd -> FlowAction -> IO () @@ -458,7 +458,7 @@ foreign import capi unsafe "termios.h tcflow" c_tcflow :: CInt -> CInt -> IO CInt -- | @getTerminalProcessGroupID fd@ calls @tcgetpgrp@ to --- obtain the @ProcessGroupID@ of the foreground process group +-- obtain the @ProcessGroupID@ of the foreground process group -- associated with the terminal attached to @Fd@ @fd@. getTerminalProcessGroupID :: Fd -> IO ProcessGroupID getTerminalProcessGroupID (Fd fd) = do @@ -468,8 +468,8 @@ foreign import ccall unsafe "tcgetpgrp" c_tcgetpgrp :: CInt -> IO CPid -- | @setTerminalProcessGroupID fd pgid@ calls @tcsetpgrp@ to --- set the @ProcessGroupID@ of the foreground process group --- associated with the terminal attached to @Fd@ +-- set the @ProcessGroupID@ of the foreground process group +-- associated with the terminal attached to @Fd@ -- @fd@ to @pgid@. setTerminalProcessGroupID :: Fd -> ProcessGroupID -> IO () setTerminalProcessGroupID (Fd fd) pgid = @@ -562,7 +562,7 @@ clearInputFlag flag termios = unsafePerformIO $ do fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do - copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) iflag <- (#peek struct termios, c_iflag) p2 (#poke struct termios, c_iflag) p1 (iflag .&. complement flag) return $ makeTerminalAttributes fp @@ -574,7 +574,7 @@ setInputFlag flag termios = unsafePerformIO $ do fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do - copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) iflag <- (#peek struct termios, c_iflag) p2 (#poke struct termios, c_iflag) p1 (iflag .|. flag) return $ makeTerminalAttributes fp @@ -594,7 +594,7 @@ clearControlFlag flag termios = unsafePerformIO $ do fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do - copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) cflag <- (#peek struct termios, c_cflag) p2 (#poke struct termios, c_cflag) p1 (cflag .&. complement flag) return $ makeTerminalAttributes fp @@ -606,7 +606,7 @@ setControlFlag flag termios = unsafePerformIO $ do fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do - copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) cflag <- (#peek struct termios, c_cflag) p2 (#poke struct termios, c_cflag) p1 (cflag .|. flag) return $ makeTerminalAttributes fp @@ -626,7 +626,7 @@ clearLocalFlag flag termios = unsafePerformIO $ do fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do - copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) lflag <- (#peek struct termios, c_lflag) p2 (#poke struct termios, c_lflag) p1 (lflag .&. complement flag) return $ makeTerminalAttributes fp @@ -638,7 +638,7 @@ setLocalFlag flag termios = unsafePerformIO $ do fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do - copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) lflag <- (#peek struct termios, c_lflag) p2 (#poke struct termios, c_lflag) p1 (lflag .|. flag) return $ makeTerminalAttributes fp @@ -658,7 +658,7 @@ clearOutputFlag flag termios = unsafePerformIO $ do fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do - copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) oflag <- (#peek struct termios, c_oflag) p2 (#poke struct termios, c_oflag) p1 (oflag .&. complement flag) return $ makeTerminalAttributes fp @@ -670,7 +670,7 @@ setOutputFlag flag termios = unsafePerformIO $ do fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do - copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) oflag <- (#peek struct termios, c_oflag) p2 (#poke struct termios, c_oflag) p1 (oflag .|. flag) return $ makeTerminalAttributes fp @@ -683,7 +683,7 @@ testOutputFlag flag termios = unsafePerformIO $ oflag <- (#peek struct termios, c_oflag) p return $! ((oflag .&. flag) /= 0) -withNewTermios :: TerminalAttributes -> (Ptr CTermios -> IO a) +withNewTermios :: TerminalAttributes -> (Ptr CTermios -> IO a) -> IO TerminalAttributes withNewTermios termios action = do fp1 <- mallocForeignPtrBytes (#const sizeof(struct termios)) diff --git a/System/Posix/Time.hsc b/System/Posix/Time.hsc index 4ebc8ac..91b8fad 100644 --- a/System/Posix/Time.hsc +++ b/System/Posix/Time.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.Time -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -16,9 +16,9 @@ ----------------------------------------------------------------------------- module System.Posix.Time ( - epochTime, - -- ToDo: lots more from sys/time.h - -- how much already supported by System.Time? + epochTime, + -- ToDo: lots more from sys/time.h + -- how much already supported by System.Time? ) where #include "HsUnix.h" @@ -30,7 +30,7 @@ import Foreign.C -- ----------------------------------------------------------------------------- -- epochTime --- | @epochTime@ calls @time@ to obtain the number of +-- | @epochTime@ calls @time@ to obtain the number of -- seconds that have elapsed since the epoch (Jan 01 00:00:00 GMT 1970). epochTime :: IO EpochTime epochTime = throwErrnoIfMinus1 "epochTime" (c_time nullPtr) diff --git a/System/Posix/Unistd.hsc b/System/Posix/Unistd.hsc index db69bc2..0a13d6d 100644 --- a/System/Posix/Unistd.hsc +++ b/System/Posix/Unistd.hsc @@ -7,7 +7,7 @@ -- Module : System.Posix.Unistd -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -29,7 +29,7 @@ module System.Posix.Unistd ( {- ToDo from unistd.h: - confstr, + confstr, lots of sysconf variables -- use Network.BSD @@ -62,11 +62,11 @@ import System.Posix.Internals data SystemID = SystemID { systemName :: String - , nodeName :: String - , release :: String - , version :: String - , machine :: String - } + , nodeName :: String + , release :: String + , version :: String + , machine :: String + } getSystemID :: IO SystemID getSystemID = do @@ -78,11 +78,11 @@ getSystemID = do ver <- peekCString ((#ptr struct utsname, version) p_sid) mach <- peekCString ((#ptr struct utsname, machine) p_sid) return (SystemID { systemName = sysN, - nodeName = node, - release = rel, - version = ver, - machine = mach - }) + nodeName = node, + release = rel, + version = ver, + machine = mach + }) foreign import ccall unsafe "uname" c_uname :: Ptr CUtsname -> IO CInt @@ -152,7 +152,7 @@ nanosleep nsecs = do allocaBytes (#const sizeof(struct timespec)) $ \pts1 -> do allocaBytes (#const sizeof(struct timespec)) $ \pts2 -> do let (tv_sec0, tv_nsec0) = nsecs `divMod` 1000000000 - let + let loop tv_sec tv_nsec = do (#poke struct timespec, tv_sec) pts1 tv_sec (#poke struct timespec, tv_nsec) pts1 tv_nsec @@ -170,7 +170,7 @@ nanosleep nsecs = do data CTimeSpec -foreign import ccall safe "__hsunix_nanosleep" +foreign import ccall safe "__hsunix_nanosleep" c_nanosleep :: Ptr CTimeSpec -> Ptr CTimeSpec -> IO CInt #endif @@ -185,14 +185,14 @@ data SysVar = ArgumentLimit | PosixVersion | HasSavedIDs | HasJobControl - -- ToDo: lots more + -- ToDo: lots more getSysVar :: SysVar -> IO Integer getSysVar v = case v of ArgumentLimit -> sysconf (#const _SC_ARG_MAX) ChildLimit -> sysconf (#const _SC_CHILD_MAX) - ClockTick -> sysconf (#const _SC_CLK_TCK) + ClockTick -> sysconf (#const _SC_CLK_TCK) GroupLimit -> sysconf (#const _SC_NGROUPS_MAX) OpenFileLimit -> sysconf (#const _SC_OPEN_MAX) PosixVersion -> sysconf (#const _SC_VERSION) @@ -200,7 +200,7 @@ getSysVar v = HasJobControl -> sysconf (#const _SC_JOB_CONTROL) sysconf :: CInt -> IO Integer -sysconf n = do +sysconf n = do r <- throwErrnoIfMinus1 "getSysVar" (c_sysconf n) return (fromIntegral r) diff --git a/System/Posix/User.hsc b/System/Posix/User.hsc index 50c9f41..d1a794a 100644 --- a/System/Posix/User.hsc +++ b/System/Posix/User.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.User -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -55,7 +55,7 @@ import Foreign.C import Foreign.Ptr import Foreign.Marshal import Foreign.Storable -import System.Posix.Internals ( CGroup, CPasswd ) +import System.Posix.Internals ( CGroup, CPasswd ) #if !defined(HAVE_GETPWNAM_R) || !defined(HAVE_GETPWUID_R) || defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT) import Control.Concurrent.MVar ( MVar, newMVar, withMVar ) @@ -209,7 +209,7 @@ getGroupEntryForID gid = foreign import capi unsafe "HsUnix.h getgrgid_r" c_getgrgid_r :: CGid -> Ptr CGroup -> CString - -> CSize -> Ptr (Ptr CGroup) -> IO CInt + -> CSize -> Ptr (Ptr CGroup) -> IO CInt #else getGroupEntryForID = error "System.Posix.User.getGroupEntryForID: not supported" #endif @@ -228,7 +228,7 @@ getGroupEntryForName name = foreign import capi unsafe "HsUnix.h getgrnam_r" c_getgrnam_r :: CString -> Ptr CGroup -> CString - -> CSize -> Ptr (Ptr CGroup) -> IO CInt + -> CSize -> Ptr (Ptr CGroup) -> IO CInt #else getGroupEntryForName = error "System.Posix.User.getGroupEntryForName: not supported" #endif @@ -247,7 +247,7 @@ getAllGroupEntries = withMVar lock $ \_ -> bracket_ c_setgrent c_endgrent $ worker [] where worker accum = do resetErrno - ppw <- throwErrnoIfNullAndError "getAllGroupEntries" $ + ppw <- throwErrnoIfNullAndError "getAllGroupEntries" $ c_getgrent if ppw == nullPtr then return (reverse accum) @@ -321,15 +321,15 @@ getUserEntryForID uid = c_getpwuid_r uid ppw foreign import ccall unsafe "__hsunix_getpwuid_r" - c_getpwuid_r :: CUid -> Ptr CPasswd -> - CString -> CSize -> Ptr (Ptr CPasswd) -> IO CInt + c_getpwuid_r :: CUid -> Ptr CPasswd -> + CString -> CSize -> Ptr (Ptr CPasswd) -> IO CInt #elif HAVE_GETPWUID getUserEntryForID uid = do withMVar lock $ \_ -> do ppw <- throwErrnoIfNull "getUserEntryForID" $ c_getpwuid uid unpackUserEntry ppw -foreign import ccall unsafe "getpwuid" +foreign import ccall unsafe "getpwuid" c_getpwuid :: CUid -> IO (Ptr CPasswd) #else getUserEntryForID = error "System.Posix.User.getUserEntryForID: not supported" @@ -357,21 +357,21 @@ getUserEntryForName name = do ppw <- throwErrnoIfNull "getUserEntryForName" $ c_getpwnam pstr unpackUserEntry ppw -foreign import ccall unsafe "getpwnam" +foreign import ccall unsafe "getpwnam" c_getpwnam :: CString -> IO (Ptr CPasswd) #else getUserEntryForName = error "System.Posix.User.getUserEntryForName: not supported" #endif --- | @getAllUserEntries@ returns all user entries on the system by +-- | @getAllUserEntries@ returns all user entries on the system by -- repeatedly calling @getpwent@ getAllUserEntries :: IO [UserEntry] #ifdef HAVE_GETPWENT -getAllUserEntries = +getAllUserEntries = withMVar lock $ \_ -> bracket_ c_setpwent c_endpwent $ worker [] - where worker accum = + where worker accum = do resetErrno - ppw <- throwErrnoIfNullAndError "getAllUserEntries" $ + ppw <- throwErrnoIfNullAndError "getAllUserEntries" $ c_getpwent if ppw == nullPtr then return (reverse accum) @@ -403,10 +403,10 @@ foreign import ccall unsafe "sysconf" -- We need a default value since sysconf can fail and return -1 -- even when the parameter name is defined in unistd.h. --- One example of this is _SC_GETPW_R_SIZE_MAX under +-- One example of this is _SC_GETPW_R_SIZE_MAX under -- Mac OS X 10.4.9 on i386. sysconfWithDefault :: Int -> CInt -> Int -sysconfWithDefault def sc = +sysconfWithDefault def sc = unsafePerformIO $ do v <- fmap fromIntegral $ c_sysconf sc return $ if v == (-1) then def else v #endif -- cgit v1.2.3