[Pkg-haskell-commits] darcs: haskell-hinotify: Initial Check-In

bailey-guest at alioth.debian.org bailey-guest at alioth.debian.org
Tue Dec 21 01:09:28 UTC 2010


Mon Dec 20 12:31:44 UTC 2010  bailey-guest at alioth.debian.org
  * Initial Check-In
  Ignore-this: 8badf836ac352a7ac0d08bc581d56bbd

    A ./LICENSE
    A ./README
    A ./Setup.lhs
    A ./debian/
    A ./debian/changelog
    A ./debian/compat
    A ./debian/control
    A ./debian/copyright
    A ./debian/rules
    A ./debian/watch
    A ./hinotify.cabal
    A ./src/
    A ./src/System/
    A ./src/System/INotify/
    A ./src/System/INotify.hsc
    A ./src/System/INotify/Masks.hsc

Mon Dec 20 12:31:44 UTC 2010  bailey-guest at alioth.debian.org
  * Initial Check-In
  Ignore-this: 8badf836ac352a7ac0d08bc581d56bbd
diff -rN -u old-haskell-hinotify/debian/changelog new-haskell-hinotify/debian/changelog
--- old-haskell-hinotify/debian/changelog	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/debian/changelog	2010-12-21 01:09:28.385298172 +0000
@@ -0,0 +1,5 @@
+haskell-hinotify (0.3.1-1) UNRELEASED; urgency=low
+
+  * initial version
+
+ -- Andy Bailey <bailey at akamai.com>  Wed, 15 Dec 2010 13:33:43 -0500
diff -rN -u old-haskell-hinotify/debian/compat new-haskell-hinotify/debian/compat
--- old-haskell-hinotify/debian/compat	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/debian/compat	2010-12-21 01:09:28.385298172 +0000
@@ -0,0 +1 @@
+7
diff -rN -u old-haskell-hinotify/debian/control new-haskell-hinotify/debian/control
--- old-haskell-hinotify/debian/control	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/debian/control	2010-12-21 01:09:28.385298172 +0000
@@ -0,0 +1,68 @@
+Source: haskell-hinotify
+Section: haskell
+Priority: extra
+Maintainer: Debian Haskell Group <pkg-haskell-maintainers at lists.alioth.debian.org>
+Uploaders: Andy Bailey <bailey at akamai.com>
+Standards-Version: 3.8.6
+Build-Depends: debhelper (>= 7)
+  , haskell-devscripts (>= 0.7)
+  , cdbs
+  , ghc6 
+  , ghc6-prof
+  , ghc6-doc
+Homepage: http://hackage.haskell.org/package/hinotify
+Vcs-Darcs: http://darcs.debian.org/pkg-haskell/haskell-hinotify
+Vcs-Browser: http://darcs.debian.org/cgi-bin/darcsweb.cgi?r=pkg-haskell/haskell-hinotify
+
+Package: libghc6-hinotify-dev
+Architecture: any
+Depends: ${haskell:Depends}
+  , ${shlibs:Depends}
+  , ${misc:Depends}
+Suggests: ${haskell:Suggests}
+Provides: ${haskell:Provides}
+Description: Haskell inotify library for GHC
+ This package provides a library for the Haskell programming language.
+ See http://www.haskell.org/ for more information on Haskell.
+ .
+ Hinotify is a Haskell library for inotify, a part of the Linux kernel
+ . 
+ Hinotify uses inotify to provide file system event notification, 
+ simply add a watcher to a file or directory and get an event when it 
+ is accessed or modified.
+
+
+Package: libghc6-hinotify-prof
+Architecture: any
+Depends: ${haskell:Depends}
+  , ${misc:Depends}
+Provides: ${haskell:Provides}
+Description: Haskell inotify library for GHC; profiling libraries
+ This package provides a library for the Haskell programming language,
+ compiled for profiling.
+ See http://www.haskell.org/ for more information on Haskell.
+ .
+ Hinotify is a Haskell library for inotify, a part of the Linux kernel
+ . 
+ Hinotify uses inotify to provide file system event notification, 
+ simply add a watcher to a file or directory and get an event when it 
+ is accessed or modified.
+
+Package: libghc6-hinotify-doc
+Section: doc
+Architecture: all
+Depends: ${haskell:Depends}
+  , ${misc:Depends}
+Recommends: ${haskell:Recommends}
+Suggests: ${haskell:Suggests}
+Description: Haskell inotify library for GHC; documentation
+ This package provides the documentation for a library for the Haskell
+ programming language.
+ See http://www.haskell.org/ for more information on Haskell.
+ .
+ Hinotify is a Haskell library for inotify, a part of the Linux kernel
+ . 
+ Hinotify uses inotify to provide file system event notification, 
+ simply add a watcher to a file or directory and get an event when it 
+ is accessed or modified.
+
diff -rN -u old-haskell-hinotify/debian/copyright new-haskell-hinotify/debian/copyright
--- old-haskell-hinotify/debian/copyright	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/debian/copyright	2010-12-21 01:09:28.385298172 +0000
@@ -0,0 +1,13 @@
+This package was debianised by R. Andrew Bailey <bailey at akamai.com> on
+Thu, 16 Feb 2010 20:13:22 +0500
+All of the Debian packaging scripts are released into the public domain.
+
+It was downloaded from
+http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hinotify
+
+Upstream Author: Lennart Kolmodin
+
+Copyright © 2009 Lennart Kolmodin <kolmodin at gentoo.org>
+
+BSD licenced. The complete text of the BSD license can be found in
+/usr/share/common-licenses/BSD on Debian systems.
diff -rN -u old-haskell-hinotify/debian/rules new-haskell-hinotify/debian/rules
--- old-haskell-hinotify/debian/rules	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/debian/rules	2010-12-21 01:09:28.385298172 +0000
@@ -0,0 +1,4 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/hlibrary.mk
diff -rN -u old-haskell-hinotify/debian/watch new-haskell-hinotify/debian/watch
--- old-haskell-hinotify/debian/watch	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/debian/watch	2010-12-21 01:09:28.385298172 +0000
@@ -0,0 +1,6 @@
+version=3
+opts="downloadurlmangle=s|archive/([\w\d_-]+)/([\d\.]+)/|archive/$1/$2/$1-$2.tar.gz|,\
+filenamemangle=s|(.*)/$|hinotify-$1.tar.gz|" \
+    http://hackage.haskell.org/packages/archive/hinotify \
+    ([\d\.]*\d)/
+
diff -rN -u old-haskell-hinotify/hinotify.cabal new-haskell-hinotify/hinotify.cabal
--- old-haskell-hinotify/hinotify.cabal	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/hinotify.cabal	2010-12-21 01:09:28.381297960 +0000
@@ -0,0 +1,38 @@
+name:               hinotify
+version:            0.3.1
+build-type:         Simple
+synopsis:           Haskell binding to INotify
+description:
+    .
+    This library provides a wrapper to the Linux Kernel's inotify feature,
+    allowing applications to subscribe to notifications when a file is
+    accessed or modified.
+    .
+category:           System
+homepage:           http://haskell.org/~kolmodin/code/hinotify/README.html
+license:            BSD3
+license-file:       LICENSE
+author:             Lennart Kolmodin
+maintainer:         Lennart Kolmodin <kolmodin at gentoo.org>
+extra-source-files: README
+cabal-version:      >= 1.2
+
+flag split-base
+    description: Choose the new smaller, split-up base package.
+
+library
+    build-depends:  unix
+    if flag(split-base)
+        build-depends:  base >= 3 && < 5, containers, directory
+    else
+        build-depends:  base < 3
+    extensions:     ForeignFunctionInterface
+
+    exposed-modules:
+        System.INotify
+    other-modules:
+        System.INotify.Masks
+
+    ghc-options:    -fvia-C -Wall
+
+    hs-source-dirs: src
diff -rN -u old-haskell-hinotify/LICENSE new-haskell-hinotify/LICENSE
--- old-haskell-hinotify/LICENSE	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/LICENSE	2010-12-21 01:09:28.385298172 +0000
@@ -0,0 +1,30 @@
+Copyright (c) Lennart Kolmodin
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the author nor the names of his contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
+OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff -rN -u old-haskell-hinotify/README new-haskell-hinotify/README
--- old-haskell-hinotify/README	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/README	2010-12-21 01:09:28.385298172 +0000
@@ -0,0 +1,107 @@
+% hinotify: inotify for Haskell
+% Lennart Kolmodin <kolmodin at gentoo.org>
+% December 26, 2007-2009
+
+About
+-----
+
+hinotify, a library to [inotify] which has been part of the Linux kernel
+since 2.6.13.
+
+inotify provides file system event notification, simply add a watcher to
+a file or directory and get an event when it is accessed or modified.
+
+This module is named `hinotify`.
+
+See example code in the `examples` directory, distributed with the source
+code.
+
+[inotify]: http://www.kernel.org/pub/linux/kernel/people/rml/inotify/
+
+News
+----
+
+**hinotify 0.3.1**
+:   * Use `inotify.h` from `glibc` rather than from the linux headers, as
+      recommended upstream.
+
+**hinotify 0.3**
+:   * Compiles with GHC 6.12, GHC 6.10.4, GHC 6.8.2 and GHC 6.6.1
+
+**hinotify 0.2**
+:   * Updates to the API
+        - Function names is now in semiCamelCase
+        - Restructure event parameters to make it more consistent
+    * Small test suit in `tests/`
+    * Compiles with GHC 6.8.2 and GHC 6.6.1
+    * Requires Cabal 1.2
+
+**hinotify 0.1**
+:   Initial release
+
+API
+---
+
+The API basically consists of:
+
+    initINotify :: IO INotify
+    addWatch :: INotify
+             -> [EventVariety]   -- different events to listen on
+             -> FilePath         -- file/directory to watch
+             -> (Event -> IO ()) -- event handler
+             -> IO WatchDescriptor
+    removeWatch :: INotify -> WatchDescriptor -> IO ()
+
+A sample program:
+
+    import System.Directory
+    import System.IO
+
+    import System.INotify
+
+    main :: IO ()
+    main = do
+        inotify <- initINotify
+        print inotify
+        home <- getHomeDirectory
+        wd <- addWatch
+                inotify
+                [Open,Close,Access,Modify,Move]
+                home
+                print
+        print wd
+        putStrLn "Listens to your home directory. Hit enter to terminate."
+        getLine
+        removeWatch inotify wd
+
+
+Download
+--------
+
+The code is available via the [homepage], and via darcs:
+
+    darcs get --partial http://haskell.org/~kolmodin/code/hinotify/
+
+The [API] is available online.
+
+I'm most grateful for feedback on the API, and what else you might have to
+suggest.
+
+Author
+------
+
+Lennart Kolmodin
+
+`kolmodin at gentoo.org`
+
+Legal
+-----
+
+This software is released under a BSD-style license. See LICENSE for
+more details.
+
+Copyright &copy; 2007 Lennart Kolmodin
+
+[homepage]: http://haskell.org/~kolmodin/code/hinotify/
+
+[API]: http://hackage.haskell.org/packages/archive/hinotify/latest/doc/html/System-INotify.html
diff -rN -u old-haskell-hinotify/Setup.lhs new-haskell-hinotify/Setup.lhs
--- old-haskell-hinotify/Setup.lhs	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/Setup.lhs	2010-12-21 01:09:28.385298172 +0000
@@ -0,0 +1,3 @@
+#!/usr/bin/runhaskell
+> import Distribution.Simple
+> main = defaultMain
diff -rN -u old-haskell-hinotify/src/System/INotify/Masks.hsc new-haskell-hinotify/src/System/INotify/Masks.hsc
--- old-haskell-hinotify/src/System/INotify/Masks.hsc	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/src/System/INotify/Masks.hsc	2010-12-21 01:09:28.381297960 +0000
@@ -0,0 +1,93 @@
+module System.INotify.Masks
+    ( inAccess
+    , inModify
+    , inAttrib
+    , inCloseWrite
+    , inCloseNowrite
+    , inOpen
+    , inMovedFrom
+    , inMovedTo
+    , inMoveSelf
+    , inCreate
+    , inDelete
+    , inDeleteSelf
+    , inUnmount
+    , inQOverflow
+    , inIgnored
+    , inClose
+    , inMove
+    , inOnlydir
+    , inDontFollow
+    , inMaskAdd
+    , inIsdir
+    , inOneshot
+    , inAllEvents
+    , maskIsSet
+    , joinMasks
+    , Mask
+    ) where
+
+import Data.Bits
+import Data.Maybe
+import Foreign.C.Types
+
+#include "sys/inotify.h"
+
+data Mask
+    = UserSpace CUInt
+    | Extra     CUInt
+    | Helper    CUInt
+    | Special   CUInt
+    | All       CUInt
+    deriving (Eq,Ord)
+
+maskIsSet :: Mask -> CUInt -> Bool
+maskIsSet mask cuint =
+    value mask .&. cuint > 0
+    
+value :: Mask -> CUInt
+value (UserSpace i) = i
+value (Extra i) = i
+value (Helper i) = i
+value (Special i) = i
+value (All i) = i
+
+instance Show Mask where
+    show mask =
+        fromJust $ lookup mask [ 
+            (inAccess, "IN_ACCESS"),
+            (inModify, "IN_MODIFY"),
+            (inAttrib, "IN_ATTRIB"),
+            (inClose,  "IN_CLOSE"),
+            (inCloseWrite, "IN_CLOSE_WRITE"),
+            (inCloseNowrite, "IN_CLOSE_NOWRITE"),
+            (inOpen, "IN_OPEN"),
+            (inMove, "IN_MOVE"),
+            (inMovedFrom, "IN_MOVED_FROM"),
+            (inMovedTo, "IN_MOVED_TO"),
+            (inMoveSelf, "IN_MOVE_SELF"),
+            (inCreate, "IN_CREATE"),
+            (inDelete, "IN_DELETE"),
+            (inDeleteSelf, "IN_DELETE_SELF"),
+            (inUnmount, "IN_UNMOUNT"),
+            (inQOverflow, "IN_Q_OVERFLOW"),
+            (inIgnored, "IN_IGNORED"),
+            (inClose, "IN_CLOSE"),
+            (inIsdir, "IN_ISDIR"),
+            (inOneshot, "IN_ONESHOT")]
+
+joinMasks :: [Mask] -> CUInt
+joinMasks = foldr (.|.) 0 . map value
+
+#enum Mask, UserSpace, IN_ACCESS, IN_MODIFY, IN_ATTRIB, IN_CLOSE_WRITE
+#enum Mask, UserSpace, IN_CLOSE_NOWRITE, IN_OPEN, IN_MOVED_FROM, IN_MOVED_TO
+#enum Mask, UserSpace, IN_CREATE, IN_DELETE, IN_DELETE_SELF, IN_MOVE_SELF
+
+#enum Mask, Extra, IN_UNMOUNT, IN_Q_OVERFLOW, IN_IGNORED
+
+#enum Mask, Helper, IN_CLOSE, IN_MOVE
+
+#enum Mask, Special, IN_ONLYDIR, IN_DONT_FOLLOW, IN_MASK_ADD, IN_ISDIR
+#enum Mask, Special, IN_ONESHOT
+
+#enum Mask, All, IN_ALL_EVENTS
diff -rN -u old-haskell-hinotify/src/System/INotify.hsc new-haskell-hinotify/src/System/INotify.hsc
--- old-haskell-hinotify/src/System/INotify.hsc	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-hinotify/src/System/INotify.hsc	2010-12-21 01:09:28.381297960 +0000
@@ -0,0 +1,333 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  System.INotify
+-- Copyright   :  (c) Lennart Kolmodin 2006
+-- License     :  BSD3
+-- Maintainer  :  kolmodin at dtek.chalmers.se
+-- Stability   :  experimental
+-- Portability :  hc portable, linux only
+--
+-- A Haskell binding to INotify.
+-- See <http://www.kernel.org/pub/linux/kernel/people/rml/inotify/> and @man
+-- inotify at .
+--
+-- Use 'initINotify' to get a 'INotify', then use 'addWatch' to
+-- add a watch on a file or directory. Select which events you're interested
+-- in with 'EventVariety', which corresponds to the 'Event' events.
+-- 
+-- Use 'removeWatch' once you don't want to watch a file any more.
+--
+-----------------------------------------------------------------------------
+
+module System.INotify
+    ( initINotify
+    , killINotify
+    , withINotify
+    , addWatch
+    , removeWatch
+    , INotify
+    , WatchDescriptor
+    , Event(..)
+    , EventVariety(..)
+    , Cookie
+    ) where
+
+#include "sys/inotify.h"
+
+import Prelude hiding (init)
+import Control.Monad
+import Control.Concurrent
+import Control.Concurrent.MVar
+import Control.Exception (bracket)
+import Data.Maybe
+import Data.Map (Map)
+import qualified Data.Map as Map
+import Foreign.C
+import Foreign.Marshal
+import Foreign.Ptr
+import Foreign.Storable
+import System.Directory
+import System.IO
+import System.IO.Error
+#if __GLASGOW_HASKELL__ >= 612
+import GHC.IO.Handle.FD (fdToHandle')
+import GHC.IO.Device (IODeviceType(Stream))
+#else
+import GHC.Handle
+import System.Posix.Internals
+#endif
+
+import System.INotify.Masks
+
+type FD = CInt
+type WD = CInt
+type Masks = CUInt
+
+type EventMap = Map WD (Event -> IO ())
+type WDEvent = (WD, Event)
+
+data INotify = INotify Handle FD (MVar EventMap) ThreadId ThreadId
+data WatchDescriptor = WatchDescriptor Handle WD deriving Eq
+
+newtype Cookie = Cookie CUInt deriving (Eq,Ord)
+
+data FDEvent = FDEvent WD Masks CUInt{-Cookie-} (Maybe String) deriving (Eq, Show)
+
+data Event =
+    -- | A file was accessed. @Accessed isDirectory file@
+      Accessed
+        { isDirectory :: Bool
+        , maybeFilePath :: Maybe FilePath
+        }
+    -- | A file was modified. @Modified isDiroctory file@
+    | Modified
+        { isDirectory :: Bool
+        , maybeFilePath :: Maybe FilePath
+        }
+    -- | A files attributes where changed. @Attributes isDirectory file@
+    | Attributes
+        { isDirectory :: Bool
+        , maybeFilePath :: Maybe FilePath
+        }
+    -- | A file was closed. @Closed isDirectory file wasWriteable@
+    | Closed
+        { isDirectory :: Bool
+        , maybeFilePath :: Maybe FilePath
+        , wasWriteable :: Bool
+        }
+    -- | A file was opened. @Opened isDirectory maybeFilePath@
+    | Opened
+        { isDirectory :: Bool
+        , maybeFilePath :: Maybe FilePath
+        }
+    -- | A file was moved away from the watched dir. @MovedFrom isDirectory from cookie@
+    | MovedOut
+        { isDirectory :: Bool
+        , filePath :: FilePath
+        , moveCookie :: Cookie
+        }
+    -- | A file was moved into the watched dir. @MovedTo isDirectory to cookie@
+    | MovedIn
+        { isDirectory :: Bool
+        , filePath :: FilePath
+        , moveCookie :: Cookie
+        }
+    -- | The watched file was moved. @MovedSelf isDirectory@
+    | MovedSelf
+        { isDirectory :: Bool
+        }
+    -- | A file was created. @Created isDirectory file@
+    | Created
+        { isDirectory :: Bool
+        , filePath :: FilePath
+        }
+    -- | A file was deleted. @Deleted isDirectory file@
+    | Deleted
+        { isDirecotry :: Bool
+        , filePath :: FilePath
+        }
+    -- | The file watched was deleted.
+    | DeletedSelf
+    -- | The file watched was unmounted.
+    | Unmounted
+    -- | The queue overflowed.
+    | QOverflow
+    | Ignored
+    | Unknown FDEvent
+    deriving (Eq, Show)
+
+data EventVariety
+    = Access
+    | Modify
+    | Attrib
+    | Close
+    | CloseWrite
+    | CloseNoWrite
+    | Open
+    | Move
+    | MoveIn
+    | MoveOut
+    | MoveSelf
+    | Create
+    | Delete
+    | DeleteSelf
+    | OnlyDir
+    | NoSymlink
+    | MaskAdd
+    | OneShot
+    | AllEvents
+    deriving Eq
+
+instance Show INotify where
+    show (INotify _ fd _ _ _) =
+        showString "<inotify fd=" . 
+        shows fd $ ">"
+
+instance Show WatchDescriptor where
+    show (WatchDescriptor _ wd) = showString "<wd=" . shows wd $ ">"
+
+instance Show Cookie where
+    show (Cookie c) = showString "<cookie " . shows c $ ">"
+
+initINotify :: IO INotify
+initINotify = do
+    fd <- throwErrnoIfMinus1 "initINotify" c_inotify_init
+    let desc = showString "<inotify handle, fd=" . shows fd $ ">"
+#if __GLASGOW_HASKELL__ < 608
+    h <-  openFd (fromIntegral fd) (Just Stream) False{-is_socket-} desc ReadMode True{-binary-}
+#else
+    h <-  fdToHandle' (fromIntegral fd) (Just Stream) False{-is_socket-} desc ReadMode True{-binary-}
+#endif
+    em <- newMVar Map.empty
+    (tid1, tid2) <- inotify_start_thread h em
+    return (INotify h fd em tid1 tid2)
+
+addWatch :: INotify -> [EventVariety] -> FilePath -> (Event -> IO ()) -> IO WatchDescriptor
+addWatch inotify@(INotify h fd em _ _) masks fp cb = do
+    is_dir <- doesDirectoryExist fp
+    when (not is_dir) $ do
+        file_exist <- doesFileExist fp
+        when (not file_exist) $ do
+            -- it's not a directory, and not a file...
+            -- it doesn't exist
+            ioError $ mkIOError doesNotExistErrorType
+                                "can't watch what isn't there"
+                                Nothing 
+                                (Just fp)
[...incomplete...]



More information about the Pkg-haskell-commits mailing list