packages feed

ngx-export 0.2.4.2 → 0.2.5.0

raw patch · 2 files changed

+28/−9 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ NgxExport: ngxExportIOYY :: Name -> Q [Dec]

Files

NgxExport.hs view
@@ -25,6 +25,7 @@                  ,ngxExportBLS                  ,ngxExportYY                  ,ngxExportBY+                 ,ngxExportIOYY                  ,ngxExportAsyncIOYY                  ,ngxExportServiceIOYY                  ,ngxExportHandler@@ -50,6 +51,7 @@ import qualified Data.ByteString as B import qualified Data.ByteString.Unsafe as B import qualified Data.ByteString.Lazy as L+import qualified Data.ByteString.Lazy.Char8 as C8L  pattern I l <- (fromIntegral -> l) pattern PtrLen s l <- (s, I l)@@ -156,9 +158,16 @@  -- | Exports a function of type -- /'B.ByteString' -> 'IO' 'L.ByteString'/+-- for using in directive /haskell_run/.+ngxExportIOYY =+    ngxExportC 'IOYY 'ioyY+    [t|CString -> CInt -> Ptr CString -> IO CInt|]++-- | Exports a function of type+-- /'B.ByteString' -> 'IO' 'L.ByteString'/ -- for using in directive /haskell_run_async/. ngxExportAsyncIOYY =-    ngxExportC 'IOYY 'ioyY+    ngxExportC 'IOYY 'asyncIOYY     [t|CString -> CInt ->        CInt -> CUInt -> Ptr CString -> Ptr CSize -> Ptr CUInt -> IO ()|] @@ -169,7 +178,7 @@ -- The boolean argument of the exported function marks that the service is -- being run for the first time. ngxExportServiceIOYY =-    ngxExport 'IOYY 'ioyY+    ngxExport 'IOYY 'asyncIOYY     [t|CString -> CInt ->        CInt -> CUInt -> Ptr CString -> Ptr CSize -> Ptr CUInt -> IO ()|] @@ -234,6 +243,12 @@ pokeCStringLen :: CString -> CSize -> Ptr CString -> Ptr CSize -> IO () pokeCStringLen x n p s = poke p x >> poke s n +pokeLazyByteString :: L.ByteString -> Ptr CString -> IO CInt+pokeLazyByteString s p = do+    PtrLenFromMaybe t l <- toSingleBuffer s+    poke p t+    return l+ toSingleBuffer :: L.ByteString -> IO (Maybe (CString, Int)) toSingleBuffer EmptyLBS =     return $ Just (nullPtr, 0)@@ -308,13 +323,17 @@ yY :: NgxExport -> CString -> CInt -> Ptr CString -> IO CInt yY (YY f) x (I n) p = do     s <- f <$> B.unsafePackCStringLen (x, n)-    PtrLenFromMaybe t l <- toSingleBuffer s-    poke p t-    return l+    pokeLazyByteString s p -ioyY :: NgxExport -> CString -> CInt ->+ioyY :: NgxExport -> CString -> CInt -> Ptr CString -> IO CInt+ioyY (IOYY f) x (I n) p = do+    s <- (B.unsafePackCStringLen (x, n) >>= flip f False)+        `catch` \e -> return $ C8L.pack $ show (e :: SomeException)+    pokeLazyByteString s p++asyncIOYY :: NgxExport -> CString -> CInt ->     CInt -> CUInt -> Ptr CString -> Ptr CSize -> Ptr CUInt -> IO ()-ioyY (IOYY f) x (I n) (I fd) ((/= 0) -> fstRun) p pl r =+asyncIOYY (IOYY f) x (I n) (I fd) ((/= 0) -> fstRun) p pl r =     void . async $     (do     s <- (Right <$> (B.unsafePackCStringLen (x, n) >>= flip f fstRun))
ngx-export.cabal view
@@ -1,5 +1,5 @@ name:                ngx-export-version:             0.2.4.2+version:             0.2.5.0 synopsis:            Helper module for Nginx haskell module description:         Helper module for         <http://github.com/lyokha/nginx-haskell-module Nginx haskell module>@@ -10,7 +10,7 @@ maintainer:          Alexey Radkov <alexey.radkov@gmail.com> stability:           experimental copyright:           2016 Alexey Radkov-category:            Unclassified+category:            Network build-type:          Simple cabal-version:       >= 1.8