diff options
Diffstat (limited to 'Inotify.dcl')
-rw-r--r-- | Inotify.dcl | 71 |
1 files changed, 65 insertions, 6 deletions
diff --git a/Inotify.dcl b/Inotify.dcl index 3811abc..c3a3e05 100644 --- a/Inotify.dcl +++ b/Inotify.dcl @@ -3,27 +3,84 @@ definition module Inotify from Data.Either import ::Either from Data.Maybe import ::Maybe +// Inotify file descriptor :: *Inotify st +// Inotify watch descriptor :: INWatch +// Inotify event mask :: INMask :== Int +// Inotify event :: INEvent :== Int + +// Inotify callback: event, maybe filename, state, world -> state, world :: INCallback st :== INEvent (Maybe String) st *World -> *(st, *World) (|-) infixl 6 :: (INMask INMask -> INMask) +/* Initialise an inotify file descriptor with some state */ inotify_init :: st -> Maybe *(Inotify st) + +/* Close an inotify file descriptor and get back the state */ inotify_close :: *(Inotify st) -> st -inotify_add_watch :: (INCallback st) !Int !String !*(Inotify st) - -> *(Either Int INWatch, *Inotify st) -inotify_rm_watch :: !INWatch !*(Inotify st) -> *(Bool, *Inotify st) +/** + * Add a watch on some file + * + * INCallback st: the callback for events + * INMask: a mask of events to watch for + * String: the filename + * Inotify st: the inotify file descriptor + * + * Either Int INWatch: either an error code or a watch descriptor + * Inotify st: the new file descriptor + */ +inotify_add_watch :: (INCallback st) !INMask !String !*(Inotify st) + -> *(!Either Int INWatch, !*Inotify st) + +/** + * Remove a watch + * + * INWatch: the watch to remove + * Inotify st: the inotify file descriptor + * + * Bool: success + * Inotify st: the new file descriptor + */ +inotify_rm_watch :: !INWatch !*(Inotify st) -> *(!Bool, !*Inotify st) + +/** + * Poll an inotify file descriptor; i.e. wait for new events + * + * Maybe Int timeout in milliseconds (Nothing for no timeout) + * + * Int the number of events + */ +inotify_poll :: !(Maybe Int) !*(Inotify st) -> *(!Int, !*Inotify st) -inotify_poll :: *(Inotify st) -> *Inotify st -inotify_check :: *(Inotify st) *World -> *(*Inotify st, *World) +/** + * Check for new events and call callbacks + */ +inotify_check :: !*(Inotify st) !*World -> *(!*Inotify st, !*World) -inotify_loop_forever :: *(Inotify st) *World -> *(*Inotify st, *World) +/** + * Check if an event matches a mask + */ +inotify_is_event :: INMask INEvent -> Bool + +/** + * Combination of inotify_poll and inotify_check that will return only if no + * events were given when a timeout occurred. + */ +inotify_loop_with_timeout :: !(Maybe Int) !*(Inotify st) !*World -> *(!*Inotify st, !*World) + +/** + * inotify_loop_with_timeout with Nothing as timeout (will never return) + */ +inotify_loop_forever :: !*(Inotify st) !*World -> *(!*Inotify st, !*World) + +/*** Begin inotify.h ***/ IN_ACCESS :== 0x00000001 // File was accessed IN_MODIFY :== 0x00000002 // File was modified @@ -52,3 +109,5 @@ IN_ALL_EVENTS :== (IN_ACCESS |- IN_MODIFY |- IN_ATTRIB |- IN_CLOSE_WRITE |- IN_CLOSE_NOWRITE |- IN_OPEN |- IN_MOVED_FROM |- IN_MOVED_TO |- IN_DELETE |- IN_CREATE |- IN_DELETE_SELF |- IN_MOVE_SELF) + +/*** End inotify.h ***/ |