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
import Bindings.Posix.Sys.Types
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 ()
type C'regoff_t = CInt
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 ()
c'REG_EXTENDED = 1
c'REG_EXTENDED :: (Num a) => a
c'REG_ICASE = 2
c'REG_ICASE :: (Num a) => a
c'REG_NOSUB = 8
c'REG_NOSUB :: (Num a) => a
c'REG_NEWLINE = 4
c'REG_NEWLINE :: (Num a) => a
c'REG_NOTBOL = 1
c'REG_NOTBOL :: (Num a) => a
c'REG_NOTEOL = 2
c'REG_NOTEOL :: (Num a) => a
c'REG_NOMATCH = 1
c'REG_NOMATCH :: (Num a) => a
c'REG_BADPAT = 2
c'REG_BADPAT :: (Num a) => a
c'REG_ECOLLATE = 3
c'REG_ECOLLATE :: (Num a) => a
c'REG_ECTYPE = 4
c'REG_ECTYPE :: (Num a) => a
c'REG_EESCAPE = 5
c'REG_EESCAPE :: (Num a) => a
c'REG_ESUBREG = 6
c'REG_ESUBREG :: (Num a) => a
c'REG_EBRACK = 7
c'REG_EBRACK :: (Num a) => a
c'REG_EPAREN = 8
c'REG_EPAREN :: (Num a) => a
c'REG_EBRACE = 9
c'REG_EBRACE :: (Num a) => a
c'REG_BADBR = 10
c'REG_BADBR :: (Num a) => a
c'REG_ERANGE = 11
c'REG_ERANGE :: (Num a) => a
c'REG_ESPACE = 12
c'REG_ESPACE :: (Num a) => a
c'REG_BADRPT = 13
c'REG_BADRPT :: (Num a) => a
foreign import ccall "regcomp" c'regcomp
:: Ptr C'regex_t -> CString -> CInt -> IO CInt
foreign import ccall "®comp" p'regcomp
:: FunPtr (Ptr C'regex_t -> CString -> CInt -> IO CInt)
foreign import ccall "regerror" c'regerror
:: CInt -> Ptr C'regex_t -> CString -> CSize -> IO CSize
foreign import ccall "®error" p'regerror
:: FunPtr (CInt -> Ptr C'regex_t -> CString -> CSize -> IO CSize)
foreign import ccall "regexec" c'regexec
:: Ptr C'regex_t -> CString -> CSize -> Ptr C'regmatch_t -> CInt -> IO CInt
foreign import ccall "®exec" p'regexec
:: FunPtr (Ptr C'regex_t -> CString -> CSize -> Ptr C'regmatch_t -> CInt -> IO CInt)
foreign import ccall "regfree" c'regfree
:: Ptr C'regex_t -> IO ()
foreign import ccall "®free" p'regfree
:: FunPtr (Ptr C'regex_t -> IO ())