module Network.SSH.Client.SimpleSSH.Types
( Result(..)
, ResultExit(..)
, SimpleSSH
, SimpleSSHError(..)
, runSimpleSSH
, readError
) where
import Control.Monad.Error
import qualified Data.ByteString.Char8 as BS
import Foreign.C.Types
data ResultExit
= ExitSuccess
| ExitFailure Integer
| ExitSignal BS.ByteString
deriving (Show, Eq)
data Result = Result
{ resultOut :: BS.ByteString
, resultErr :: BS.ByteString
, resultExit :: ResultExit
} deriving (Show, Eq)
type SimpleSSH a = ErrorT SimpleSSHError IO a
runSimpleSSH :: SimpleSSH a -> IO (Either SimpleSSHError a)
runSimpleSSH = runErrorT
data SimpleSSHError
= Connect
| Init
| Handshake
| KnownhostsInit
| KnownhostsHostkey
| KnownhostsCheck
| Authentication
| ChannelOpen
| ChannelExec
| Read
| FileOpen
| Write
| Unknown
deriving (Show, Eq)
instance Error SimpleSSHError where
strMsg _ = Unknown
readError :: CInt -> SimpleSSHError
readError errNum = case errNum of
1 -> Connect
2 -> Init
3 -> Handshake
4 -> KnownhostsInit
5 -> KnownhostsHostkey
6 -> KnownhostsCheck
7 -> Authentication
8 -> ChannelOpen
9 -> ChannelExec
10 -> Read
11 -> FileOpen
12 -> Write
_ -> Unknown