diff options
author | joe <joe@jerkface.net> | 2016-04-24 18:43:00 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2016-04-24 18:43:00 -0400 |
commit | fbf425fbef1c1e60fcdddfbd9b25976162725f97 (patch) | |
tree | b3877b56401f22efed0486ae10950af3a5ebadf8 /DotLock.hs | |
parent | 7d8798f60b11973fd17d85caf3da2e8473842d2a (diff) |
Refactored build of executable and library.
Diffstat (limited to 'DotLock.hs')
-rw-r--r-- | DotLock.hs | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/DotLock.hs b/DotLock.hs deleted file mode 100644 index af05f5d..0000000 --- a/DotLock.hs +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | {-# LANGUAGE ForeignFunctionInterface #-} | ||
2 | module DotLock | ||
3 | ( DotLock | ||
4 | , Flags | ||
5 | , dotlock_init | ||
6 | , dotlock_create | ||
7 | , dotlock_take | ||
8 | , dotlock_release | ||
9 | , dotlock_destroy | ||
10 | , dotlock_remove_lockfiles | ||
11 | , dotlock_set_fd | ||
12 | , dotlock_get_fd | ||
13 | , dotlock_disable | ||
14 | ) where | ||
15 | |||
16 | import System.Posix.Types (Fd(..)) | ||
17 | import Foreign.C.String | ||
18 | import Foreign.C.Types | ||
19 | import Foreign.Ptr | ||
20 | |||
21 | newtype DotLock = DotLockPtr (Ptr ()) | ||
22 | type Flags = Int | ||
23 | |||
24 | foreign import ccall "dotlock_create" _dotlock_create_ptr :: Ptr Char -> Flags -> IO (Ptr ()) | ||
25 | |||
26 | foreign import ccall "dotlock_create" _dotlock_create :: CString -> Flags -> IO (Ptr ()) | ||
27 | |||
28 | dotlock_init :: IO () | ||
29 | dotlock_init = do | ||
30 | null_ptr <- _dotlock_create_ptr nullPtr 0 | ||
31 | return () | ||
32 | |||
33 | dotlock_create :: FilePath -> Flags -> IO (Maybe DotLock) | ||
34 | dotlock_create file flags = do | ||
35 | ptr <- withCString file (flip _dotlock_create flags) | ||
36 | if ptr == nullPtr then return Nothing else return (Just $ DotLockPtr ptr) | ||
37 | |||
38 | |||
39 | foreign import ccall "dotlock_take" dotlock_take :: DotLock -> CLong -> IO CInt | ||
40 | foreign import ccall "dotlock_release" dotlock_release :: DotLock -> IO CInt | ||
41 | foreign import ccall "dotlock_destroy" dotlock_destroy :: DotLock -> IO () | ||
42 | foreign import ccall "dotlock_remove_lockfiles" dotlock_remove_lockfiles ::DotLock -> IO () | ||
43 | foreign import ccall "dotlock_set_fd" dotlock_set_fd :: DotLock -> Fd -> IO () | ||
44 | foreign import ccall "dotlock_get_fd" dotlock_get_fd :: DotLock -> IO Fd | ||
45 | foreign import ccall "dotlock_disable" dotlock_disable :: IO () | ||