~jack/libtelnet-haskell

6a8d7db4d1faac82a15e2d9905dd61d5f13d8471 — Jack Kelly 2 years ago 435aa32
Documentation updates
M src/Network/Telnet/LibTelnet.hs => src/Network/Telnet/LibTelnet.hs +31 -21
@@ 5,27 5,37 @@
{-# LANGUAGE RecordWildCards      #-}
{-# LANGUAGE TypeSynonymInstances #-}

-- | Getting Started:
--
-- 1. Skim
-- <https://github.com/seanmiddleditch/libtelnet the libtelnet documentation>,
-- as these bindings follow the C library's conventions quite closely.
--
-- 2. Write an event-handling function, of type 'EventHandler'.
--
-- 3. When you accept a new connection, create a 'Telnet' state
-- tracker for it using 'telnetInit'. Options and flags are defined in
-- the same way as the C library; option constants are exported from
-- "Network.Telnet.LibTelnet.Options".
--
-- 4. When you receive data (probably on a socket), tell 'Telnet'
-- about it using 'telnetRecv'.
--
-- 5. To send data, negotiate options, &c., use 'telnetSend',
-- 'telnetIac', &c.
--
-- 6. IAC (Interpret-As-Command) codes are exported from
-- "Network.Telnet.LibTelnet.Iac".
{-|
Module      : Network.Telnet.LibTelnet
Description : Bindings to C libtelnet
Copyright   : (c) 2017-2019 Jack Kelly
License     : GPL-3.0-or-later
Maintainer  : jack@jackkelly.name
Stability   : experimental
Portability : non-portable

Getting Started:

1. Skim
<https://github.com/seanmiddleditch/libtelnet the libtelnet documentation>,
as these bindings follow the C library's conventions quite closely.

2. Write an event-handling function, of type 'EventHandler'.

3. When you accept a new connection, create a 'Telnet' state
tracker for it using 'telnetInit'. Options and flags are defined in
the same way as the C library; option constants are exported from
"Network.Telnet.LibTelnet.Options".

4. When you receive data (probably on a socket), tell 'Telnet'
about it using 'telnetRecv'.

5. To send data, negotiate options, &c., use 'telnetSend',
'telnetIac', &c.

6. IAC (Interpret-As-Command) codes are exported from
"Network.Telnet.LibTelnet.Iac".
-}

module Network.Telnet.LibTelnet
  ( telnetInit

M src/Network/Telnet/LibTelnet/Ffi.hsc => src/Network/Telnet/LibTelnet/Ffi.hsc +13 -2
@@ 1,4 1,15 @@
-- | FFI binding to @libtelnet@.
{-|
Module      : Network.Telnet.LibTelnet.Ffi
Description : Low-level FFI binding
Copyright   : (c) 2017-2019 Jack Kelly
License     : GPL-3.0-or-later
Maintainer  : jack@jackkelly.name
Stability   : experimental
Portability : non-portable

FFI binding to @libtelnet@. The vast majority of these functions are
generated from @foreign import@ declarations.
-}

module Network.Telnet.LibTelnet.Ffi where



@@ 159,7 170,7 @@ foreign import ccall "libtelnet.h telnet_send_zmp"
    -> IO ()

-- | Collect '[ByteString]' into a temporary array of strings in a
-- 'Ptr CString', to passing to C functions.
-- 'Ptr CString', for passing to C functions.
useAsCStrings :: [ByteString] -> (Ptr CString -> IO a) -> IO a
useAsCStrings list f = go list [] where
  go [] css = withArray (reverse css) f

M src/Network/Telnet/LibTelnet/Iac.hsc => src/Network/Telnet/LibTelnet/Iac.hsc +12 -1
@@ 1,6 1,17 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

-- | Telnet interpret-as-command (IAC) codes.
{-|
Module      : Network.Telnet.LibTelnet.Iac
Description : Constants for interpret-as-command (IAC) codes
Copyright   : (c) 2017-2019 Jack Kelly
License     : GPL-3.0-or-later
Maintainer  : jack@jackkelly.name
Stability   : experimental
Portability : non-portable

Telnet interpret-as-command (IAC) codes. See
<http://www.faqs.org/rfcs/rfc854.html RFC 854> for the meaning of many of these.
-}

module Network.Telnet.LibTelnet.Iac
  ( Iac(..)

M src/Network/Telnet/LibTelnet/Options.hsc => src/Network/Telnet/LibTelnet/Options.hsc +13 -1
@@ 1,6 1,18 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

-- | Telnet option codes.
{-|
Module      : Network.Telnet.LibTelnet.Options
Description : Constants for option codes
Copyright   : (c) 2017-2019 Jack Kelly
License     : GPL-3.0-or-later
Maintainer  : jack@jackkelly.name
Stability   : experimental
Portability : non-portable

Telnet option codes. Many of these are defined in their own RFC.
<http://www.omnifarious.org/~hopper/technical/telnet-rfc.html> is a
good index of known options.
-}

module Network.Telnet.LibTelnet.Options
  ( Option(..)

M src/Network/Telnet/LibTelnet/Types.hsc => src/Network/Telnet/LibTelnet/Types.hsc +14 -1
@@ 4,7 4,20 @@
{-# LANGUAGE MultiWayIf                 #-}
{-# LANGUAGE RecordWildCards            #-}

-- | Wrapping of @libtelnet@ types.
{-|
Module      : Network.Telnet.LibTelnet.Types
Description : Wrappers for @libtelnet@ types
Copyright   : (c) 2017-2019 Jack Kelly
License     : GPL-3.0-or-later
Maintainer  : jack@jackkelly.name
Stability   : experimental
Portability : non-portable

Wrappers for @libtelnet@ types, where the wrapping is simple enough to
not need its own module. Interpret-as-command codes live in
"Network.Telnet.LibTelnet.Iac", and telnet option codes live in
"Network.Telnet.LibTelnet.Options".
-}

module Network.Telnet.LibTelnet.Types where