{-# LINE 1 "src/Bindings/Posix/Regex.hsc" #-}

{-# LINE 2 "src/Bindings/Posix/Regex.hsc" #-}

{-# LINE 3 "src/Bindings/Posix/Regex.hsc" #-}

-- | <http://www.opengroup.org/onlinepubs/9699919799/basedefs/regex.h.html>

module Bindings.Posix.Regex where
import Foreign.Ptr (Ptr,FunPtr,plusPtr)
import Foreign.Ptr (wordPtrToPtr,castPtrToFunPtr)
import Foreign.Storable
import Foreign.C.Types
import Foreign.C.String (CString,CStringLen,CWString,CWStringLen)
import Foreign.Marshal.Alloc (alloca)
import Foreign.Marshal.Array (peekArray,pokeArray)
import Data.Int
import Data.Word

{-# LINE 8 "src/Bindings/Posix/Regex.hsc" #-}
import Bindings.Posix.Sys.Types


{-# LINE 11 "src/Bindings/Posix/Regex.hsc" #-}

{-# LINE 12 "src/Bindings/Posix/Regex.hsc" #-}
data C'regex_t = C'regex_t{
  c'regex_t're_nsub :: CSize
} deriving (Eq,Show)
p'regex_t're_nsub p = plusPtr p 24
p'regex_t're_nsub :: Ptr (C'regex_t) -> Ptr (CSize)
instance Storable C'regex_t where
  sizeOf _ = 32
  alignment _ = 4
  peek p = do
    v0 <- peekByteOff p 24
    return $ C'regex_t v0
  poke p (C'regex_t v0) = do
    pokeByteOff p 24 v0
    return ()

{-# LINE 13 "src/Bindings/Posix/Regex.hsc" #-}

type C'regoff_t = CInt

{-# LINE 15 "src/Bindings/Posix/Regex.hsc" #-}


{-# LINE 17 "src/Bindings/Posix/Regex.hsc" #-}

{-# LINE 18 "src/Bindings/Posix/Regex.hsc" #-}

{-# LINE 19 "src/Bindings/Posix/Regex.hsc" #-}
data C'regmatch_t = C'regmatch_t{
  c'regmatch_t'rm_so :: C'regoff_t,
  c'regmatch_t'rm_eo :: C'regoff_t
} deriving (Eq,Show)
p'regmatch_t'rm_so p = plusPtr p 0
p'regmatch_t'rm_so :: Ptr (C'regmatch_t) -> Ptr (C'regoff_t)
p'regmatch_t'rm_eo p = plusPtr p 4
p'regmatch_t'rm_eo :: Ptr (C'regmatch_t) -> Ptr (C'regoff_t)
instance Storable C'regmatch_t where
  sizeOf _ = 8
  alignment _ = 4
  peek p = do
    v0 <- peekByteOff p 0
    v1 <- peekByteOff p 4
    return $ C'regmatch_t v0 v1
  poke p (C'regmatch_t v0 v1) = do
    pokeByteOff p 0 v0
    pokeByteOff p 4 v1
    return ()

{-# LINE 20 "src/Bindings/Posix/Regex.hsc" #-}

c'REG_EXTENDED = 1
c'REG_EXTENDED :: (Num a) => a

{-# LINE 22 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_ICASE = 2
c'REG_ICASE :: (Num a) => a

{-# LINE 23 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_NOSUB = 8
c'REG_NOSUB :: (Num a) => a

{-# LINE 24 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_NEWLINE = 4
c'REG_NEWLINE :: (Num a) => a

{-# LINE 25 "src/Bindings/Posix/Regex.hsc" #-}

c'REG_NOTBOL = 1
c'REG_NOTBOL :: (Num a) => a

{-# LINE 27 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_NOTEOL = 2
c'REG_NOTEOL :: (Num a) => a

{-# LINE 28 "src/Bindings/Posix/Regex.hsc" #-}

c'REG_NOMATCH = 1
c'REG_NOMATCH :: (Num a) => a

{-# LINE 30 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_BADPAT = 2
c'REG_BADPAT :: (Num a) => a

{-# LINE 31 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_ECOLLATE = 3
c'REG_ECOLLATE :: (Num a) => a

{-# LINE 32 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_ECTYPE = 4
c'REG_ECTYPE :: (Num a) => a

{-# LINE 33 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_EESCAPE = 5
c'REG_EESCAPE :: (Num a) => a

{-# LINE 34 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_ESUBREG = 6
c'REG_ESUBREG :: (Num a) => a

{-# LINE 35 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_EBRACK = 7
c'REG_EBRACK :: (Num a) => a

{-# LINE 36 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_EPAREN = 8
c'REG_EPAREN :: (Num a) => a

{-# LINE 37 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_EBRACE = 9
c'REG_EBRACE :: (Num a) => a

{-# LINE 38 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_BADBR = 10
c'REG_BADBR :: (Num a) => a

{-# LINE 39 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_ERANGE = 11
c'REG_ERANGE :: (Num a) => a

{-# LINE 40 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_ESPACE = 12
c'REG_ESPACE :: (Num a) => a

{-# LINE 41 "src/Bindings/Posix/Regex.hsc" #-}
c'REG_BADRPT = 13
c'REG_BADRPT :: (Num a) => a

{-# LINE 42 "src/Bindings/Posix/Regex.hsc" #-}

foreign import ccall "regcomp" c'regcomp
  :: Ptr C'regex_t -> CString -> CInt -> IO CInt
foreign import ccall "&regcomp" p'regcomp
  :: FunPtr (Ptr C'regex_t -> CString -> CInt -> IO CInt)

{-# LINE 44 "src/Bindings/Posix/Regex.hsc" #-}
foreign import ccall "regerror" c'regerror
  :: CInt -> Ptr C'regex_t -> CString -> CSize -> IO CSize
foreign import ccall "&regerror" p'regerror
  :: FunPtr (CInt -> Ptr C'regex_t -> CString -> CSize -> IO CSize)

{-# LINE 45 "src/Bindings/Posix/Regex.hsc" #-}
foreign import ccall "regexec" c'regexec
  :: Ptr C'regex_t -> CString -> CSize -> Ptr C'regmatch_t -> CInt -> IO CInt
foreign import ccall "&regexec" p'regexec
  :: FunPtr (Ptr C'regex_t -> CString -> CSize -> Ptr C'regmatch_t -> CInt -> IO CInt)

{-# LINE 46 "src/Bindings/Posix/Regex.hsc" #-}
foreign import ccall "regfree" c'regfree
  :: Ptr C'regex_t -> IO ()
foreign import ccall "&regfree" p'regfree
  :: FunPtr (Ptr C'regex_t -> IO ())

{-# LINE 47 "src/Bindings/Posix/Regex.hsc" #-}