    {-# LINE 1 "src/Database/PostgreSQL/LibPQ/Notify.hsc" #-}
    module Database.PostgreSQL.LibPQ.Notify where

    import Foreign (Ptr, Storable (..))
    import Foreign.C.Types (CInt, CSize)
    import System.Posix.Types (CPid)

    import qualified Data.ByteString as B

    -------------------------------------------------------------------------------
    -- Notify
    -------------------------------------------------------------------------------

    data Notify = Notify {
          Notify -> ByteString
    notifyRelname :: {-# UNPACK #-} !B.ByteString -- ^ notification channel name
        , Notify -> CPid
    notifyBePid   :: {-# UNPACK #-} !CPid         -- ^ process ID of notifying server process
        , Notify -> ByteString
    notifyExtra   :: {-# UNPACK #-} !B.ByteString -- ^ notification payload string
        } deriving Int -> Notify -> ShowS
    [Notify] -> ShowS
    Notify -> String
    (Int -> Notify -> ShowS)
    -> (Notify -> String) -> ([Notify] -> ShowS) -> Show Notify
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Notify -> ShowS
    showsPrec :: Int -> Notify -> ShowS
    $cshow :: Notify -> String
    show :: Notify -> String
    $cshowList :: [Notify] -> ShowS
    showList :: [Notify] -> ShowS
    Show

    instance Storable Notify where
      sizeOf :: Notify -> Int
    sizeOf Notify
    _ = (Int
    32)
    {-# LINE 23 "src/Database/PostgreSQL/LibPQ/Notify.hsc" #-}

      alignment :: Notify -> Int
    alignment Notify
    _ = Int
    8
    {-# LINE 25 "src/Database/PostgreSQL/LibPQ/Notify.hsc" #-}

      peek :: Ptr Notify -> IO Notify
    peek Ptr Notify
    ptr = do
          relname <- CString -> IO ByteString
    B.packCString (CString -> IO ByteString) -> IO CString -> IO ByteString
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< (\Ptr Notify
    hsc_ptr -> Ptr Notify -> Int -> IO CString
    forall b. Ptr b -> Int -> IO CString
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr Notify
    hsc_ptr Int
    0) Ptr Notify
    ptr
    {-# LINE 28 "src/Database/PostgreSQL/LibPQ/Notify.hsc" #-}
          extra   <- B.packCString =<< (\hsc_ptr -> peekByteOff hsc_ptr 16) ptr
    {-# LINE 29 "src/Database/PostgreSQL/LibPQ/Notify.hsc" #-}
          be_pid  <- fmap f $ (\hsc_ptr -> peekByteOff hsc_ptr 8) ptr
    {-# LINE 30 "src/Database/PostgreSQL/LibPQ/Notify.hsc" #-}
          return $! Notify relname be_pid extra
          where
            f :: CInt -> CPid
            f :: CInt -> CPid
    f = CInt -> CPid
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral

      poke :: Ptr Notify -> Notify -> IO ()
    poke Ptr Notify
    ptr (Notify ByteString
    a CPid
    b ByteString
    c) =
          ByteString -> (CString -> IO ()) -> IO ()
    forall a. ByteString -> (CString -> IO a) -> IO a
    B.useAsCString ByteString
    a ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \CString
    a' ->
            ByteString -> (CString -> IO ()) -> IO ()
    forall a. ByteString -> (CString -> IO a) -> IO a
    B.useAsCString ByteString
    c ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \CString
    c' ->
                do (\Ptr Notify
    hsc_ptr -> Ptr Notify -> Int -> CString -> IO ()
    forall b. Ptr b -> Int -> CString -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr Notify
    hsc_ptr Int
    0) Ptr Notify
    ptr CString
    a'
    {-# LINE 39 "src/Database/PostgreSQL/LibPQ/Notify.hsc" #-}
                   (\Ptr Notify
    hsc_ptr -> Ptr Notify -> Int -> CInt -> IO ()
    forall b. Ptr b -> Int -> CInt -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr Notify
    hsc_ptr Int
    8)  Ptr Notify
    ptr (CPid -> CInt
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral CPid
    b :: CInt)
    {-# LINE 40 "src/Database/PostgreSQL/LibPQ/Notify.hsc" #-}
                   (\Ptr Notify
    hsc_ptr -> Ptr Notify -> Int -> CString -> IO ()
    forall b. Ptr b -> Int -> CString -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr Notify
    hsc_ptr Int
    16)   Ptr Notify
    ptr CString
    c'
    {-# LINE 41 "src/Database/PostgreSQL/LibPQ/Notify.hsc" #-}

    -------------------------------------------------------------------------------
    -- Notice
    -------------------------------------------------------------------------------

    data PGnotice

    pgNoticePeekLen :: Ptr PGnotice -> IO CSize
    pgNoticePeekLen :: Ptr PGnotice -> IO CSize
    pgNoticePeekLen = (\Ptr PGnotice
    hsc_ptr -> Ptr PGnotice -> Int -> IO CSize
    forall b. Ptr b -> Int -> IO CSize
    forall a b. Storable a => Ptr b -> Int -> IO a
    peekByteOff Ptr PGnotice
    hsc_ptr Int
    8)
    {-# LINE 50 "src/Database/PostgreSQL/LibPQ/Notify.hsc" #-}

    pgNoticeOffsetStr :: Int
    pgNoticeOffsetStr :: Int
    pgNoticeOffsetStr = (Int
    16)
    {-# LINE 53 "src/Database/PostgreSQL/LibPQ/Notify.hsc" #-}