module System.FAM
(
open
, open2
, close
, monitorDirectory
, monitorFile
, monitorCollection
, suspendMonitor
, resumeMonitor
, cancelMonitor
, nextEvent
, pending
, Connection(..)
, Request(..)
, Event(..)
, changed
, deleted
, startexecuting
, stopexecuting
, created
, moved
, acknowledge
, exists
, endexist
)
where
import Foreign
import Foreign.C
data Void
type VoidPtr = Ptr Void
data Connection = Connection { fd :: CInt }
type ConnectionPtr = Ptr Connection
data Request = Request { reqnum :: CInt }
type RequestPtr = Ptr Request
type FamCodes = CInt
changed :: FamCodes
changed = 1
deleted :: FamCodes
deleted = 2
startexecuting :: FamCodes
startexecuting = 3
stopexecuting :: FamCodes
stopexecuting = 4
created :: FamCodes
created = 5
moved :: FamCodes
moved = 6
acknowledge :: FamCodes
acknowledge = 7
exists :: FamCodes
exists = 8
endexist :: FamCodes
endexist = 9
data Event = Event { connection :: ConnectionPtr
, request :: Request
, hostname :: Ptr CString
, filename :: CString
, userdata :: VoidPtr
, code :: FamCodes
}
type EventPtr = Ptr Event
instance Storable Connection where
sizeOf _ = ((8))
alignment _ = alignment (undefined :: CInt)
peek ptr = do
fd' <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) ptr
return Connection { fd = fd' }
poke ptr (Connection fd') = do
((\hsc_ptr -> pokeByteOff hsc_ptr 0)) ptr fd'
instance Storable Request where
sizeOf _ = ((4))
alignment _ = alignment (undefined :: CInt)
peek ptr = do
rn' <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) ptr
return Request { reqnum = rn' }
poke ptr (Request rn') = do
((\hsc_ptr -> pokeByteOff hsc_ptr 0)) ptr rn'
instance Storable Event where
sizeOf _ = ((4116))
alignment _ = alignment (undefined :: CInt)
peek ptr = do
connection' <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) ptr
request' <- ((\hsc_ptr -> peekByteOff hsc_ptr 4)) ptr
hostname' <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) ptr
filename' <- ((\hsc_ptr -> peekByteOff hsc_ptr 12)) ptr
userdata' <- ((\hsc_ptr -> peekByteOff hsc_ptr 4108)) ptr
code' <- ((\hsc_ptr -> peekByteOff hsc_ptr 4112)) ptr
return Event { connection = connection'
, request = request'
, hostname = hostname'
, filename = filename'
, userdata = userdata'
, code = code'
}
foreign import ccall unsafe "fam.h FAMOpen" open :: ConnectionPtr -> IO CInt
foreign import ccall unsafe "fam.h FAMOpen2" open2 :: ConnectionPtr -> CString -> IO CInt
foreign import ccall unsafe "fam.h FAMClose" close :: ConnectionPtr -> IO CInt
foreign import ccall unsafe "fam.h FAMMonitorDirectory" monitorDirectory :: ConnectionPtr -> Ptr CString -> RequestPtr -> VoidPtr -> IO CInt
foreign import ccall unsafe "fam.h FAMMonitorFile" monitorFile :: ConnectionPtr -> Ptr CString -> RequestPtr -> VoidPtr -> IO CInt
foreign import ccall unsafe "fam.h FAMMonitorCollection" monitorCollection :: ConnectionPtr -> Ptr CString -> RequestPtr -> VoidPtr -> CInt -> Ptr String -> IO CInt
foreign import ccall unsafe "fam.h FAMSuspendMonitor" suspendMonitor :: ConnectionPtr -> RequestPtr -> IO CInt
foreign import ccall unsafe "fam.h FAMResumeMonitor" resumeMonitor :: ConnectionPtr -> RequestPtr -> IO CInt
foreign import ccall unsafe "fam.h FAMCancelMonitor" cancelMonitor :: ConnectionPtr -> RequestPtr -> IO CInt
foreign import ccall unsafe "fam.h FAMNextEvent" nextEvent :: ConnectionPtr -> EventPtr -> IO CInt
foreign import ccall unsafe "fam.h FAMPending" pending :: ConnectionPtr -> IO CInt