diff --git a/System/Expect/ExpectBindings.hsc b/System/Expect/ExpectBindings.hsc index 5367fea..57066fc 100644 --- a/System/Expect/ExpectBindings.hsc +++ b/System/Expect/ExpectBindings.hsc @@ -43,3 +43,9 @@ foreign import ccall "&" exp_loguser :: Ptr CInt foreign import ccall exp_popen :: CString -> IO (Ptr CFile) foreign import ccall exp_fexpectv :: Ptr CFile -> Ptr ExpCase -> IO CInt + +data TCL_Interp = TCL_Interp + +foreign import ccall "Tcl_Init" tcl_Init :: Ptr TCL_Interp -> IO () +foreign import ccall "Expect_Init" expect_Init :: Ptr TCL_Interp -> IO () +foreign import ccall "Tcl_CreateInterp" tcl_CreateInterp :: IO (Ptr TCL_Interp) diff --git a/System/Expect/ExpectInterface.hs b/System/Expect/ExpectInterface.hs index 39ee878..1b29c47 100644 --- a/System/Expect/ExpectInterface.hs +++ b/System/Expect/ExpectInterface.hs @@ -5,6 +5,7 @@ module System.Expect.ExpectInterface ({-- The contents of the binding that are to be further exposed --} ExpectType(ExpExact,ExpRegex,ExpGlob,ExpNull) {-- The custom interface --} + ,initExpect ,ExpectCase(ExpectCase,expectPattern,expectType,expectValue) ,ExpectProc(ExpectProc,expectHandle,expectFilePtr) ,muteExpect,unmuteExpect @@ -40,6 +41,13 @@ data ExpectCase = ExpectCase { -- | Pattern to match against. , expectValue :: Int } +-- | tcl and expect initialization. +initExpect :: IO () +initExpect = do + interp <- tcl_CreateInterp + tcl_Init interp + expect_Init interp + -- | Proc created by spawnExpect. Contains both the -- CFile pointer and a Haskell handle, so the -- translation needs only be done once.