aboutsummaryrefslogtreecommitdiffhomepage
path: root/System/Posix/Terminal/Common.hsc
diff options
context:
space:
mode:
authorGravatar Simon Marlow <marlowsd@gmail.com>2011-11-23 09:35:29 +0000
committerGravatar Simon Marlow <marlowsd@gmail.com>2011-11-23 09:43:41 +0000
commitc8fada0d863085b8ac10f4d1f578e6428215ac28 (patch)
tree83c43e7b6d1a17bb7c180d2b24dae2ffa7fe233f /System/Posix/Terminal/Common.hsc
parent604d4df05a17de7e029710fec8246a210f920add (diff)
Move openPseudoTerminal into System.Posix.Terminal{.ByteString}
It may depend on getSlaveTerminalName if !defined(HAVE_OPENPTY)
Diffstat (limited to 'System/Posix/Terminal/Common.hsc')
-rw-r--r--System/Posix/Terminal/Common.hsc61
1 files changed, 1 insertions, 60 deletions
diff --git a/System/Posix/Terminal/Common.hsc b/System/Posix/Terminal/Common.hsc
index 39a2e30..3a6254d 100644
--- a/System/Posix/Terminal/Common.hsc
+++ b/System/Posix/Terminal/Common.hsc
@@ -26,6 +26,7 @@ module System.Posix.Terminal.Common (
TerminalState(..),
setTerminalAttributes,
+ CTermios,
TerminalMode(..),
withoutMode,
withMode,
@@ -63,9 +64,6 @@ module System.Posix.Terminal.Common (
-- ** Testing a file descriptor
queryTerminal,
-
- -- ** Pseudoterminal operations
- openPseudoTerminal,
) where
#include "HsUnix.h"
@@ -504,63 +502,6 @@ queryTerminal (Fd fd) = do
foreign import ccall unsafe "isatty"
c_isatty :: CInt -> IO CInt
--- | @openPseudoTerminal@ creates a pseudoterminal (pty) pair, and
--- returns the newly created pair as a (@master@, @slave@) tuple.
-openPseudoTerminal :: IO (Fd, Fd)
-
-#ifdef HAVE_OPENPTY
-openPseudoTerminal =
- alloca $ \p_master ->
- alloca $ \p_slave -> do
- throwErrnoIfMinus1_ "openPty"
- (c_openpty p_master p_slave nullPtr nullPtr nullPtr)
- master <- peek p_master
- slave <- peek p_slave
- return (Fd master, Fd slave)
-
-foreign import ccall unsafe "openpty"
- c_openpty :: Ptr CInt -> Ptr CInt -> CString -> Ptr CTermios -> Ptr a
- -> IO CInt
-#else
-openPseudoTerminal = do
- (Fd master) <- openFd "/dev/ptmx" ReadWrite Nothing
- defaultFileFlags{noctty=True}
- throwErrnoIfMinus1_ "openPseudoTerminal" (c_grantpt master)
- throwErrnoIfMinus1_ "openPseudoTerminal" (c_unlockpt master)
- slaveName <- getSlaveTerminalName (Fd master)
- slave <- openFd slaveName ReadWrite Nothing defaultFileFlags{noctty=True}
- pushModule slave "ptem"
- pushModule slave "ldterm"
-# ifndef __hpux
- pushModule slave "ttcompat"
-# endif /* __hpux */
- return (Fd master, slave)
-
--- Push a STREAMS module, for System V systems.
-pushModule :: Fd -> String -> IO ()
-pushModule (Fd fd) name =
- withCString name $ \p_name ->
- throwErrnoIfMinus1_ "openPseudoTerminal"
- (c_push_module fd p_name)
-
-foreign import ccall unsafe "__hsunix_push_module"
- c_push_module :: CInt -> CString -> IO CInt
-
-#ifdef HAVE_PTSNAME
-foreign import ccall unsafe "__hsunix_grantpt"
- c_grantpt :: CInt -> IO CInt
-
-foreign import ccall unsafe "__hsunix_unlockpt"
- c_unlockpt :: CInt -> IO CInt
-#else
-c_grantpt :: CInt -> IO CInt
-c_grantpt _ = return (fromIntegral 0)
-
-c_unlockpt :: CInt -> IO CInt
-c_unlockpt _ = return (fromIntegral 0)
-#endif /* HAVE_PTSNAME */
-#endif /* !HAVE_OPENPTY */
-
-- -----------------------------------------------------------------------------
-- Local utility functions