module System.Proc.Bindings.Tab.Internal where
import Control.Exception
import Foreign
import GHC.Stack
import System.Proc.Bindings.C
import System.Proc.Bindings.C.Utils
import System.Proc.Bindings.Error
import System.Proc.Bindings.Tab.C
import System.Proc.Bindings.Tab.Config
data ProcTab
= UnsafeProcTab
(Ptr ProcTabC)
(Ptr Proc)
openProcTabPtr :: HasCallStack => TableConfig -> IO (Ptr ProcTabC, IO ())
openProcTabPtr :: HasCallStack => TableConfig -> IO (Ptr ProcTabC, IO ())
openProcTabPtr = forall a.
(CInt -> IO a)
-> (CInt -> Ptr CPid -> IO a)
-> (CInt -> Ptr CUid -> CInt -> IO a)
-> TableConfig
-> IO (a, IO ())
openTableConfig CInt -> IO (Ptr ProcTabC)
openProcTabSimple CInt -> Ptr CPid -> IO (Ptr ProcTabC)
openProcTabFromPids CInt -> Ptr CUid -> CInt -> IO (Ptr ProcTabC)
openProcTabFromUids
withProcTabPtr :: HasCallStack => TableConfig -> (Ptr ProcTabC -> IO a) -> IO (Either ProcError a)
withProcTabPtr :: forall a.
HasCallStack =>
TableConfig -> (Ptr ProcTabC -> IO a) -> IO (Either ProcError a)
withProcTabPtr TableConfig
cfg Ptr ProcTabC -> IO a
f =
forall a.
HasCallStack =>
(CInt -> IO a)
-> (CInt -> Ptr CPid -> IO a)
-> (CInt -> Ptr CUid -> CInt -> IO a)
-> TableConfig
-> IO a
branchTableConfig
(\CInt
flags -> IO (Ptr ProcTabC) -> IO (Either ProcError a)
bracketProcTab (CInt -> IO (Ptr ProcTabC)
openProcTabSimple CInt
flags))
(\CInt
flags Ptr CPid
pidPtr -> IO (Ptr ProcTabC) -> IO (Either ProcError a)
bracketProcTab (CInt -> Ptr CPid -> IO (Ptr ProcTabC)
openProcTabFromPids CInt
flags Ptr CPid
pidPtr))
(\CInt
flags Ptr CUid
uidPtr CInt
nuid -> IO (Ptr ProcTabC) -> IO (Either ProcError a)
bracketProcTab (CInt -> Ptr CUid -> CInt -> IO (Ptr ProcTabC)
openProcTabFromUids CInt
flags Ptr CUid
uidPtr CInt
nuid))
TableConfig
cfg
where
bracketProcTab :: IO (Ptr ProcTabC) -> IO (Either ProcError a)
bracketProcTab IO (Ptr ProcTabC)
open = forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket IO (Ptr ProcTabC)
open Ptr ProcTabC -> IO ()
closeProcTabC (forall a b.
HasCallStack =>
(Ptr a -> IO b) -> Ptr a -> IO (Either ProcError b)
eitherPeek Ptr ProcTabC -> IO a
f)