{-# LINE 1 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
{-# LANGUAGE DeriveDataTypeable         #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiWayIf                 #-}
{-# LANGUAGE RecordWildCards            #-}

{-|
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

import Network.Telnet.LibTelnet.Iac
import Network.Telnet.LibTelnet.Options

import Control.Exception (Exception, throwIO)
import Data.Typeable (Typeable)
import Foreign
import Foreign.C
import GHC.Generics (Generic)



-- | Uninhabited type for pointer safety (@telnet_t@).
data TelnetT

-- | Exceptions thrown by the binding, for when something has gone
-- seriously wrong. Errors detected by @libtelnet@ are not thrown but
-- instead are passed to the event handler.
data TelnetException
  = NullTelnetPtr
  | UnexpectedEventType TelnetEventTypeT
  | UnexpectedEnvironCmd ECmd
  | UnexpectedEnvironVar EVar
  | UnexpectedTerminalTypeCmd TCmd
  deriving (Eq, Generic, Show, Typeable)

instance Exception TelnetException

-- | Flags for @telnet_init@.
newtype Flag = Flag { unFlag :: CUChar }
flagProxy  :: Flag
flagProxy  = Flag 1

{-# LINE 56 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

-- | Wraps @telnet_telopt_t@.
data TelnetTeloptT = TelnetTeloptT
  { _telopt :: CShort -- ^ option value
  , _us :: Iac -- ^ option supported on server
  , _him :: Iac -- ^ allow clients to use the option?
  }

instance Storable TelnetTeloptT where
  sizeOf _ = ((4))
{-# LINE 66 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
  alignment _ = (2)
{-# LINE 67 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  peek p = do
    telopt <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) p
{-# LINE 70 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    us <- ((\hsc_ptr -> peekByteOff hsc_ptr 2)) p
{-# LINE 71 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    him <- ((\hsc_ptr -> peekByteOff hsc_ptr 3)) p
{-# LINE 72 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

    pure $ TelnetTeloptT telopt us him

  poke p TelnetTeloptT{..} = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p _telopt
{-# LINE 77 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 2)) p _us
{-# LINE 78 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 3)) p _him
{-# LINE 79 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

-- | Wraps @telnet_event_t@.
data EventT
  = Data (CString, CSize) -- ^ 'eventData'
  | Send (CString, CSize) -- ^ 'eventSend'
  | Warning ErrorT -- ^ 'eventWarning'
  | Error ErrorT -- ^ 'eventError'
  | Command Iac -- ^ 'eventIac'
  | Will Option -- ^ 'eventWill'
  | Wont Option -- ^ 'eventWont'
  | Do Option -- ^ 'eventDo'
  | Dont Option -- ^ 'eventDont'
  | Subnegotiation Option (CString, CSize) -- ^ 'eventSubnegotiation'
  | Zmp (Ptr CString, CSize) -- ^ 'eventZmp'
  | TerminalType TCmd CString -- ^ 'eventTType'
  | Compress CUChar -- ^ 'eventCompress'
  | Environ ECmd (Ptr TelnetEnvironT, CSize) -- ^ 'eventEnviron'
  | Mssp (Ptr TelnetEnvironT, CSize) -- ^ 'eventMssp'

instance Storable EventT where
  sizeOf _ = ((40))
{-# LINE 100 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
  alignment _ = (8)
{-# LINE 101 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  peek p = do
    eType <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) p
{-# LINE 104 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    if | eType `elem` [eventData, eventSend] -> do
           ctor <- if | eType == eventData -> pure Data
                      | eType == eventSend -> pure Send
                      | otherwise -> throwIO $ UnexpectedEventType eType
           buffer <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p
{-# LINE 109 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           size <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) p
{-# LINE 110 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           pure $ ctor (buffer, size)

       | eType `elem` [eventWarning, eventError] -> do
           ctor <- if | eType == eventWarning -> pure Warning
                      | eType == eventError -> pure Error
                      | otherwise -> throwIO $ UnexpectedEventType eType
           file <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p
{-# LINE 117 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           func <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) p
{-# LINE 118 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           msg <- ((\hsc_ptr -> peekByteOff hsc_ptr 24)) p
{-# LINE 119 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           line <- ((\hsc_ptr -> peekByteOff hsc_ptr 32)) p
{-# LINE 120 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           errcode <- ((\hsc_ptr -> peekByteOff hsc_ptr 36)) p
{-# LINE 121 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

           pure . ctor $ ErrorT file func msg line errcode

       | eType == eventIac ->
           Command <$> ((\hsc_ptr -> peekByteOff hsc_ptr 4)) p
{-# LINE 126 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

       | eType `elem` [eventWill, eventWont, eventDo, eventDont] -> do
           ctor <- if | eType == eventWill -> pure Will
                      | eType == eventWont -> pure Wont
                      | eType == eventDo -> pure Do
                      | eType == eventDont -> pure Dont
                      | otherwise -> throwIO $ UnexpectedEventType eType
           ctor <$> ((\hsc_ptr -> peekByteOff hsc_ptr 4)) p
{-# LINE 134 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

       | eType == eventSubnegotiation -> do
           telopt <- ((\hsc_ptr -> peekByteOff hsc_ptr 24)) p
{-# LINE 137 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           buffer <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p
{-# LINE 138 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           size <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) p
{-# LINE 139 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

           pure $ Subnegotiation telopt (buffer, size)

       | eType == eventZmp -> do
           argc <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) p
{-# LINE 144 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           argv <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p
{-# LINE 145 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

           pure $ Zmp (argv, argc)

       | eType == eventTType -> do
           cmd <- ((\hsc_ptr -> peekByteOff hsc_ptr 4)) p
{-# LINE 150 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           name <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p
{-# LINE 151 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

           pure $ TerminalType cmd name

       | eType == eventCompress ->
           Compress <$> ((\hsc_ptr -> peekByteOff hsc_ptr 4)) p
{-# LINE 156 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

       | eType == eventEnviron -> do
           cmd <- ((\hsc_ptr -> peekByteOff hsc_ptr 24)) p
{-# LINE 159 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           values <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p
{-# LINE 160 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           size <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) p
{-# LINE 161 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

           pure $ Environ cmd (values, size)

       | eType == eventMssp -> do
           values <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p
{-# LINE 166 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
           size <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) p
{-# LINE 167 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

           pure $ Mssp (values, size)

       | otherwise -> throwIO $ UnexpectedEventType eType

  poke p (Data (buffer, size)) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventData
{-# LINE 174 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p buffer
{-# LINE 175 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p size
{-# LINE 176 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Send (buffer, size)) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventSend
{-# LINE 179 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p buffer
{-# LINE 180 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p size
{-# LINE 181 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Warning ErrorT{..}) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventWarning
{-# LINE 184 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p _file
{-# LINE 185 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p _func
{-# LINE 186 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 24)) p _msg
{-# LINE 187 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 32)) p _line
{-# LINE 188 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 36)) p _errcode
{-# LINE 189 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Error ErrorT{..}) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventError
{-# LINE 192 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p _file
{-# LINE 193 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p _func
{-# LINE 194 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 24)) p _msg
{-# LINE 195 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 32)) p _line
{-# LINE 196 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 36)) p _errcode
{-# LINE 197 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Command cmd) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventIac
{-# LINE 200 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) p cmd
{-# LINE 201 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Will opt) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventWill
{-# LINE 204 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) p opt
{-# LINE 205 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Wont opt) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventWont
{-# LINE 208 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) p opt
{-# LINE 209 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Do opt) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventDo
{-# LINE 212 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) p opt
{-# LINE 213 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Dont opt) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventDont
{-# LINE 216 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) p opt
{-# LINE 217 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Subnegotiation opt (buffer, size)) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventSubnegotiation
{-# LINE 220 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 24)) p opt
{-# LINE 221 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p buffer
{-# LINE 222 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p size
{-# LINE 223 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Zmp (argv, argc)) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventZmp
{-# LINE 226 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p argv
{-# LINE 227 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p argc
{-# LINE 228 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (TerminalType cmd name) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventTType
{-# LINE 231 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) p cmd
{-# LINE 232 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p name
{-# LINE 233 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Compress state) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventCompress
{-# LINE 236 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) p state
{-# LINE 237 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Environ cmd (values, size)) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventEnviron
{-# LINE 240 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 24)) p cmd
{-# LINE 241 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p values
{-# LINE 242 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p size
{-# LINE 243 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  poke p (Mssp (values, size)) = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p eventMssp
{-# LINE 246 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p values
{-# LINE 247 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p size
{-# LINE 248 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

-- | Constants from @telnet_event_type_t@.
newtype TelnetEventTypeT = TelnetEventTypeT { unTelnetEventTypeT :: CInt }
  deriving (Eq, Show, Storable)
eventData  :: TelnetEventTypeT
eventData  = TelnetEventTypeT 0
eventSend  :: TelnetEventTypeT
eventSend  = TelnetEventTypeT 1
eventIac  :: TelnetEventTypeT
eventIac  = TelnetEventTypeT 2
eventWill  :: TelnetEventTypeT
eventWill  = TelnetEventTypeT 3
eventWont  :: TelnetEventTypeT
eventWont  = TelnetEventTypeT 4
eventDo  :: TelnetEventTypeT
eventDo  = TelnetEventTypeT 5
eventDont  :: TelnetEventTypeT
eventDont  = TelnetEventTypeT 6
eventSubnegotiation  :: TelnetEventTypeT
eventSubnegotiation  = TelnetEventTypeT 7
eventCompress  :: TelnetEventTypeT
eventCompress  = TelnetEventTypeT 8
eventZmp  :: TelnetEventTypeT
eventZmp  = TelnetEventTypeT 9
eventTType  :: TelnetEventTypeT
eventTType  = TelnetEventTypeT 10
eventEnviron  :: TelnetEventTypeT
eventEnviron  = TelnetEventTypeT 11
eventMssp  :: TelnetEventTypeT
eventMssp  = TelnetEventTypeT 12
eventWarning  :: TelnetEventTypeT
eventWarning  = TelnetEventTypeT 13
eventError  :: TelnetEventTypeT
eventError  = TelnetEventTypeT 14

{-# LINE 269 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

-- | Data in 'Warning' and 'Error' events, modeled after @struct
-- error_t@ inside @telnet_event_t@.
data ErrorT = ErrorT
  { _file :: CString
  , _func :: CString
  , _msg :: CString
  , _line :: CInt
  , _errcode :: TelnetErrorT
  }

-- | Constants from @telnet_error_t@.
newtype TelnetErrorT = TelnetErrorT { unTelnetErrorT :: CInt }
  deriving (Eq, Show, Storable)
errOK  :: TelnetErrorT
errOK  = TelnetErrorT 0
errBadVal  :: TelnetErrorT
errBadVal  = TelnetErrorT 1
errNoMem  :: TelnetErrorT
errNoMem  = TelnetErrorT 2
errOverflow  :: TelnetErrorT
errOverflow  = TelnetErrorT 3
errProtocol  :: TelnetErrorT
errProtocol  = TelnetErrorT 4
errCompress  :: TelnetErrorT
errCompress  = TelnetErrorT 5

{-# LINE 291 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

-- | Constants for @TERMINAL-TYPE@ commands.
newtype TCmd = TCmd { unTCmd :: CUChar } deriving (Eq, Show, Storable)
tCmdIs  :: TCmd
tCmdIs  = TCmd 0
tCmdSend  :: TCmd
tCmdSend  = TCmd 1

{-# LINE 298 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

-- | Constants for @ENVIRON@/@NEW-ENVIRON@ commands.
newtype ECmd = ECmd { unECmd :: CUChar } deriving (Eq, Show, Storable)
eCmdIs  :: ECmd
eCmdIs  = ECmd 0
eCmdSend  :: ECmd
eCmdSend  = ECmd 1
eCmdInfo  :: ECmd
eCmdInfo  = ECmd 2

{-# LINE 306 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

-- | Constants for @ENVIRON@/@NEW-ENVIRON@ variables.
newtype EVar = EVar { unEvar :: CUChar } deriving (Eq, Show, Storable)
eVar  :: EVar
eVar  = EVar 0
eValue  :: EVar
eValue  = EVar 1
eUserVar  :: EVar
eUserVar  = EVar 3

{-# LINE 314 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

-- | Constants for MSSP.
newtype MsspVar = MsspVar { unMsspVar :: CUChar } deriving (Eq, Show, Storable)
msspVar  :: MsspVar
msspVar  = MsspVar 1
msspVal  :: MsspVar
msspVal  = MsspVar 2

{-# LINE 321 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

-- | @ENVIRONMENT@\/@NEW-ENVIRONMENT@\/@MSSP@ messages, wrapping
-- @telnet_environ_t@.
data TelnetEnvironT = TelnetEnvironT
  { _type :: EVar -- ^ @unsigned char type@
  , _var :: CString -- ^ @char *var@
  , _value :: CString -- ^ @char *value@
  }

instance Storable TelnetEnvironT where
  sizeOf _ = ((24))
{-# LINE 332 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
  alignment _ = (8)
{-# LINE 333 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

  peek p = do
    type_ <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) p
{-# LINE 336 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    var <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p
{-# LINE 337 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    value <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) p
{-# LINE 338 "src/Network/Telnet/LibTelnet/Types.hsc" #-}

    pure $ TelnetEnvironT type_ var value

  poke p TelnetEnvironT{..} = do
    ((\hsc_ptr -> pokeByteOff hsc_ptr 0)) p _type
{-# LINE 343 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) p _var
{-# LINE 344 "src/Network/Telnet/LibTelnet/Types.hsc" #-}
    ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) p _value
{-# LINE 345 "src/Network/Telnet/LibTelnet/Types.hsc" #-}