Commit 5eb4267e authored by Camil Staps's avatar Camil Staps 🐧

80 chars

parent e4669d78
......@@ -15,8 +15,11 @@ from Data.Maybe import ::Maybe
inotify_init :: st -> Maybe *(Inotify st)
inotify_close :: *(Inotify st) -> st
inotify_add_watch :: (INCallback st) !Int !String !*(Inotify st) -> *(Either Int INWatch, *Inotify st)
inotify_add_watch :: (INCallback st) !Int !String !*(Inotify st)
-> *(Either Int INWatch, *Inotify st)
inotify_rm_watch :: !INWatch !*(Inotify st) -> *(Bool, *Inotify st)
inotify_poll :: *(Inotify st) -> *Inotify st
inotify_check :: *(Inotify st) *World -> *(*Inotify st, *World)
......
......@@ -26,7 +26,7 @@ import code from "inotify_c.o"
inotify_init :: st -> Maybe *(Inotify st)
inotify_init st
= let fd = c_init 0 in if (fd < 0) Nothing (Just {fd=fd, watches=[], state=st})
= let fd=c_init 0 in if (fd<0) Nothing (Just {fd=fd, watches=[], state=st})
where
c_init :: !Int -> *Int
c_init i = code {
......@@ -41,7 +41,8 @@ where
ccall close "I:V:A"
}
inotify_add_watch :: (INCallback st) !Int !String !*(Inotify st) -> *(Either Int INWatch, *Inotify st)
inotify_add_watch :: (INCallback st) !Int !String !*(Inotify st)
-> *(Either Int INWatch, *Inotify st)
inotify_add_watch f mask fname inot=:{fd,watches}
= let (w, fd`) = c_add_watch fd fname mask in
( if (w == -1) (Left errno) (Right w)
......@@ -83,9 +84,11 @@ inotify_check inot=:{fd,watches,state} w
# (fd,st,w`) = seq (map (check wdsmasks) watches) (inot.fd, state, w)
= ({ inot & fd=fd, state=st }, w`)
where
check :: [(Int,Int)] (INWatch, INCallback st) *(*Int, st, *World) -> *(*Int, st, *World)
check :: [(Int,Int)] (INWatch, INCallback st) *(*Int, st, *World)
-> *(*Int, st, *World)
check wdsmasks (watch,f) (fd,st,w)
# (st,w) = seq [\(st,w) -> f mask st w \\ (wd,mask) <- wdsmasks | wd == watch] (st,w)
# (st,w) = seq [\(st,w) -> f mask st w
\\ (wd,mask) <- wdsmasks | wd == watch] (st,w)
= (fd,st,w)
bytesToInt :: {#Char} -> Int
......
......@@ -33,7 +33,8 @@ int clean_inotify_init(int ignored) {
return fd;
}
void clean_inotify_add_watch(int fd, CleanString* fname_, int mask, int *re_watch, int *re_fd) {
void clean_inotify_add_watch(int fd, CleanString* fname_, int mask,
int *re_watch, int *re_fd) {
char* fname = clstocs(fname_);
*re_watch = inotify_add_watch(fd, fname, mask);
free(fname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment