{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE TemplateHaskell #-}
module Text.Regex.Pcre2.Foreign where
import Foreign
import Foreign.C.Types
import Text.Regex.Pcre2.Foreign.TH (constant, getter)
type PCRE2_UCHAR = CUShort
type PCRE2_SPTR = Ptr PCRE2_UCHAR
type PCRE2_SIZE = CSize
data Pcre2_general_context
data Pcre2_compile_context
data Pcre2_match_context
data Pcre2_callout_block
data Pcre2_substitute_callout_block
data Pcre2_code
data Pcre2_jit_stack
data Pcre2_match_data
data Pcre2_callout_enumerate_block
foreign import capi safe "pcre2.h" pcre2_general_context_create
:: FunPtr (PCRE2_SIZE -> Ptr a -> IO (Ptr b))
-> FunPtr (Ptr b -> Ptr a -> IO ())
-> Ptr a
-> IO (Ptr Pcre2_general_context)
foreign import capi safe "pcre2.h" pcre2_general_context_copy
:: Ptr Pcre2_general_context
-> IO (Ptr Pcre2_general_context)
foreign import capi safe "pcre2.h" pcre2_general_context_free
:: Ptr Pcre2_general_context
-> IO ()
foreign import capi safe "pcre2.h" pcre2_compile_context_create
:: Ptr Pcre2_general_context
-> IO (Ptr Pcre2_compile_context)
foreign import capi safe "pcre2.h" pcre2_compile_context_copy
:: Ptr Pcre2_compile_context
-> IO (Ptr Pcre2_compile_context)
foreign import capi safe "pcre2.h" pcre2_compile_context_free
:: Ptr Pcre2_compile_context
-> IO ()
constant "ERROR_BADDATA" ''CInt
foreign import capi unsafe "pcre2.h" pcre2_set_bsr
:: Ptr Pcre2_compile_context
-> CUInt
-> IO CInt
constant "BSR_ANYCRLF" ''CUInt
constant "BSR_UNICODE" ''CUInt
foreign import capi "pcre2.h" pcre2_set_character_tables
:: Ptr Pcre2_compile_context
-> Ptr CUChar
-> IO CInt
foreign import capi unsafe "pcre2.h"
:: Ptr Pcre2_compile_context
-> CUInt
-> IO CInt
foreign import capi unsafe "pcre2.h" pcre2_set_max_pattern_length
:: Ptr Pcre2_compile_context
-> PCRE2_SIZE
-> IO CInt
foreign import capi unsafe "pcre2.h" pcre2_set_newline
:: Ptr Pcre2_compile_context
-> CUInt
-> IO CInt
constant "NEWLINE_CR" ''CUInt
constant "NEWLINE_LF" ''CUInt
constant "NEWLINE_CRLF" ''CUInt
constant "NEWLINE_ANY" ''CUInt
constant "NEWLINE_ANYCRLF" ''CUInt
constant "NEWLINE_NUL" ''CUInt
foreign import capi unsafe "pcre2.h" pcre2_set_parens_nest_limit
:: Ptr Pcre2_compile_context
-> CUInt
-> IO CInt
foreign import capi unsafe "pcre2.h" pcre2_set_compile_recursion_guard
:: Ptr Pcre2_compile_context
-> FunPtr (CUInt -> Ptr a -> IO CInt)
-> Ptr a
-> IO CInt
foreign import capi safe "pcre2.h" pcre2_match_context_create
:: Ptr Pcre2_general_context
-> IO (Ptr Pcre2_match_context)
foreign import capi safe "pcre2.h" pcre2_match_context_copy
:: Ptr Pcre2_match_context
-> IO (Ptr Pcre2_match_context)
foreign import capi safe "pcre2.h" pcre2_match_context_free
:: Ptr Pcre2_match_context
-> IO ()
foreign import capi unsafe "pcre2.h" pcre2_set_callout
:: Ptr Pcre2_match_context
-> FunPtr (Ptr Pcre2_callout_block -> Ptr a -> IO CInt)
-> Ptr a
-> IO CInt
foreign import capi unsafe "pcre2.h" pcre2_set_substitute_callout
:: Ptr Pcre2_match_context
-> FunPtr (Ptr Pcre2_substitute_callout_block -> Ptr a -> IO CInt)
-> Ptr a
-> IO CInt
foreign import capi unsafe "pcre2.h" pcre2_set_offset_limit
:: Ptr Pcre2_match_context
-> PCRE2_SIZE
-> IO CInt
constant "UNSET" ''PCRE2_SIZE
foreign import capi unsafe "pcre2.h" pcre2_set_heap_limit
:: Ptr Pcre2_match_context
-> CUInt
-> IO CInt
foreign import capi unsafe "pcre2.h" pcre2_set_match_limit
:: Ptr Pcre2_match_context
-> CUInt
-> IO CInt
foreign import capi unsafe "pcre2.h" pcre2_set_depth_limit
:: Ptr Pcre2_match_context
-> CUInt
-> IO CInt
foreign import capi unsafe "pcre2.h" pcre2_config
:: CUInt
-> Ptr a
-> IO CInt
constant "CONFIG_BSR" ''CUInt
constant "CONFIG_COMPILED_WIDTHS" ''CUInt
constant "CONFIG_DEPTHLIMIT" ''CUInt
constant "CONFIG_HEAPLIMIT" ''CUInt
constant "CONFIG_JIT" ''CUInt
constant "CONFIG_JITTARGET" ''CUInt
constant "CONFIG_LINKSIZE" ''CUInt
constant "CONFIG_MATCHLIMIT" ''CUInt
constant "CONFIG_NEWLINE" ''CUInt
constant "CONFIG_NEVER_BACKSLASH_C" ''CUInt
constant "CONFIG_PARENSLIMIT" ''CUInt
constant "CONFIG_STACKRECURSE" ''CUInt
constant "CONFIG_TABLES_LENGTH" ''CUInt
constant "CONFIG_UNICODE_VERSION" ''CUInt
constant "CONFIG_UNICODE" ''CUInt
constant "CONFIG_VERSION" ''CUInt
foreign import capi safe "pcre2.h" pcre2_compile
:: PCRE2_SPTR
-> PCRE2_SIZE
-> CUInt
-> Ptr CInt
-> Ptr PCRE2_SIZE
-> Ptr Pcre2_compile_context
-> IO (Ptr Pcre2_code)
constant "ZERO_TERMINATED" ''PCRE2_SIZE
foreign import capi safe "pcre2.h" pcre2_code_free
:: Ptr Pcre2_code
-> IO ()
foreign import capi safe "pcre2.h" pcre2_code_copy
:: Ptr Pcre2_code
-> IO (Ptr Pcre2_code)
foreign import capi "pcre2.h" pcre2_code_copy_with_tables
:: Ptr Pcre2_code
-> IO (Ptr Pcre2_code)
constant "ANCHORED" ''CUInt
constant "ALLOW_EMPTY_CLASS" ''CUInt
constant "ALT_BSUX" ''CUInt
constant "ALT_CIRCUMFLEX" ''CUInt
constant "ALT_VERBNAMES" ''CUInt
constant "AUTO_CALLOUT" ''CUInt
constant "CASELESS" ''CUInt
constant "DOLLAR_ENDONLY" ''CUInt
constant "DOTALL" ''CUInt
constant "DUPNAMES" ''CUInt
constant "ENDANCHORED" ''CUInt
constant "EXTENDED" ''CUInt
constant "EXTENDED_MORE" ''CUInt
constant "FIRSTLINE" ''CUInt
constant "LITERAL" ''CUInt
constant "MATCH_INVALID_UTF" ''CUInt
constant "MATCH_UNSET_BACKREF" ''CUInt
constant "MULTILINE" ''CUInt
constant "NEVER_BACKSLASH_C" ''CUInt
constant "NEVER_UCP" ''CUInt
constant "NEVER_UTF" ''CUInt
constant "NO_AUTO_CAPTURE" ''CUInt
constant "NO_AUTO_POSSESS" ''CUInt
constant "NO_DOTSTAR_ANCHOR" ''CUInt
constant "NO_START_OPTIMIZE" ''CUInt
constant "NO_UTF_CHECK" ''CUInt
constant "UCP" ''CUInt
constant "UNGREEDY" ''CUInt
constant "USE_OFFSET_LIMIT" ''CUInt
constant "UTF" ''CUInt
foreign import capi safe "pcre2.h" pcre2_jit_compile
:: Ptr Pcre2_code
-> CUInt
-> IO CInt
constant "JIT_COMPLETE" ''CUInt
constant "JIT_PARTIAL_HARD" ''CUInt
constant "JIT_PARTIAL_SOFT" ''CUInt
constant "ERROR_JIT_BADOPTION" ''CInt
foreign import capi safe "pcre2.h" pcre2_jit_match
:: Ptr Pcre2_code
-> PCRE2_SPTR
-> PCRE2_SIZE
-> PCRE2_SIZE
-> CUInt
-> Ptr Pcre2_match_data
-> Ptr Pcre2_match_context
-> IO CInt
foreign import capi safe "pcre2.h" pcre2_jit_free_unused_memory
:: Ptr Pcre2_general_context
-> IO ()
foreign import capi safe "pcre2.h" pcre2_jit_stack_create
:: PCRE2_SIZE
-> PCRE2_SIZE
-> Ptr Pcre2_general_context
-> IO (Ptr Pcre2_jit_stack)
foreign import capi unsafe "pcre2.h" pcre2_jit_stack_assign
:: Ptr Pcre2_match_context
-> FunPtr (Ptr a -> IO (Ptr Pcre2_jit_stack))
-> Ptr a
-> IO ()
foreign import capi safe "pcre2.h" pcre2_jit_stack_free
:: Ptr Pcre2_jit_stack
-> IO ()
foreign import capi safe "pcre2.h" pcre2_maketables
:: Ptr Pcre2_general_context
-> IO (Ptr CUChar)
foreign import capi safe "pcre2.h" pcre2_maketables_free
:: Ptr Pcre2_general_context
-> Ptr CUChar
-> IO ()
foreign import capi unsafe "pcre2.h" pcre2_pattern_info
:: Ptr Pcre2_code
-> CUInt
-> Ptr a
-> IO CInt
constant "INFO_ALLOPTIONS" ''CUInt
constant "INFO_ARGOPTIONS" ''CUInt
constant "INFO_BACKREFMAX" ''CUInt
constant "INFO_BSR" ''CUInt
constant "INFO_CAPTURECOUNT" ''CUInt
constant "INFO_DEPTHLIMIT" ''CUInt
constant "INFO_FIRSTBITMAP" ''CUInt
constant "INFO_FIRSTCODETYPE" ''CUInt
constant "INFO_FIRSTCODEUNIT" ''CUInt
constant "INFO_FRAMESIZE" ''CUInt
constant "INFO_HASBACKSLASHC" ''CUInt
constant "INFO_HASCRORLF" ''CUInt
constant "INFO_HEAPLIMIT" ''CUInt
constant "INFO_JCHANGED" ''CUInt
constant "INFO_JITSIZE" ''CUInt
constant "INFO_LASTCODETYPE" ''CUInt
constant "INFO_LASTCODEUNIT" ''CUInt
constant "INFO_MATCHEMPTY" ''CUInt
constant "INFO_MATCHLIMIT" ''CUInt
constant "INFO_MAXLOOKBEHIND" ''CUInt
constant "INFO_MINLENGTH" ''CUInt
constant "INFO_NAMECOUNT" ''CUInt
constant "INFO_NAMEENTRYSIZE" ''CUInt
constant "INFO_NAMETABLE" ''CUInt
constant "INFO_NEWLINE" ''CUInt
constant "INFO_SIZE" ''CUInt
constant "ERROR_UNSET" ''CInt
foreign import capi unsafe "pcre2.h" pcre2_substring_nametable_scan
:: Ptr Pcre2_code
-> PCRE2_SPTR
-> Ptr PCRE2_SPTR
-> Ptr PCRE2_SPTR
-> IO CInt
foreign import capi safe "pcre2.h" pcre2_callout_enumerate
:: Ptr Pcre2_code
-> FunPtr (Ptr Pcre2_callout_enumerate_block -> Ptr a -> IO CInt)
-> Ptr a
-> IO CInt
getter "callout_block" "version" ''CUInt
getter "callout_block" "callout_number" ''CUInt
getter "callout_block" "capture_top" ''CUInt
getter "callout_block" "capture_last" ''CUInt
getter "callout_block" "callout_flags" ''CUInt
constant "CALLOUT_STARTMATCH" ''CUInt
constant "CALLOUT_BACKTRACK" ''CUInt
foreign import capi unsafe "getters.h" pcre2_callout_block_offset_vector
:: Ptr Pcre2_callout_block
-> IO (Ptr PCRE2_SIZE)
getter "callout_block" "mark" ''PCRE2_SPTR
getter "callout_block" "subject" ''PCRE2_SPTR
getter "callout_block" "subject_length" ''PCRE2_SIZE
getter "callout_block" "start_match" ''PCRE2_SIZE
getter "callout_block" "current_position" ''PCRE2_SIZE
getter "callout_block" "pattern_position" ''PCRE2_SIZE
getter "callout_block" "next_item_length" ''PCRE2_SIZE
getter "callout_block" "callout_string_offset" ''PCRE2_SIZE
getter "callout_block" "callout_string_length" ''PCRE2_SIZE
getter "callout_block" "callout_string" ''PCRE2_SPTR
getter "callout_enumerate_block" "version" ''CUInt
getter "callout_enumerate_block" "pattern_position" ''PCRE2_SIZE
getter "callout_enumerate_block" "next_item_length" ''PCRE2_SIZE
getter "callout_enumerate_block" "callout_number" ''CUInt
getter "callout_enumerate_block" "callout_string_offset" ''PCRE2_SIZE
getter "callout_enumerate_block" "callout_string_length" ''PCRE2_SIZE
getter "callout_enumerate_block" "callout_string" ''PCRE2_SPTR
getter "substitute_callout_block" "version" ''CUInt
getter "substitute_callout_block" "subscount" ''CUInt
getter "substitute_callout_block" "input" ''PCRE2_SPTR
getter "substitute_callout_block" "output" ''PCRE2_SPTR
foreign import capi unsafe "getters.h" pcre2_substitute_callout_block_ovector
:: Ptr Pcre2_substitute_callout_block
-> IO (Ptr PCRE2_SIZE)
getter "substitute_callout_block" "oveccount" ''CUInt
foreign import capi unsafe "getters.h"
pcre2_substitute_callout_block_output_offsets
:: Ptr Pcre2_substitute_callout_block
-> IO (Ptr PCRE2_SIZE)
foreign import capi safe "pcre2.h" pcre2_match_data_create
:: CUInt
-> Ptr Pcre2_general_context
-> IO (Ptr Pcre2_match_data)
foreign import capi safe "pcre2.h" pcre2_match_data_create_from_pattern
:: Ptr Pcre2_code
-> Ptr Pcre2_general_context
-> IO (Ptr Pcre2_match_data)
foreign import capi safe "pcre2.h" pcre2_match_data_free
:: Ptr Pcre2_match_data
-> IO ()
foreign import capi safe "pcre2.h" pcre2_match
:: Ptr Pcre2_code
-> PCRE2_SPTR
-> PCRE2_SIZE
-> PCRE2_SIZE
-> CUInt
-> Ptr Pcre2_match_data
-> Ptr Pcre2_match_context
-> IO CInt
constant "COPY_MATCHED_SUBJECT" ''CUInt
constant "NOTBOL" ''CUInt
constant "NOTEOL" ''CUInt
constant "NOTEMPTY" ''CUInt
constant "NOTEMPTY_ATSTART" ''CUInt
constant "NO_JIT" ''CUInt
constant "PARTIAL_HARD" ''CUInt
constant "PARTIAL_SOFT" ''CUInt
constant "ERROR_NOMATCH" ''CInt
constant "ERROR_PARTIAL" ''CInt
constant "ERROR_BADMAGIC" ''CInt
constant "ERROR_BADMODE" ''CInt
constant "ERROR_BADOFFSET" ''CInt
constant "ERROR_BADOPTION" ''CInt
constant "ERROR_BADUTFOFFSET" ''CInt
constant "ERROR_CALLOUT" ''CInt
constant "ERROR_DEPTHLIMIT" ''CInt
constant "ERROR_HEAPLIMIT" ''CInt
constant "ERROR_INTERNAL" ''CInt
constant "ERROR_JIT_STACKLIMIT" ''CInt
constant "ERROR_MATCHLIMIT" ''CInt
constant "ERROR_NOMEMORY" ''CInt
constant "ERROR_NULL" ''CInt
constant "ERROR_UTF16_ERR1" ''CInt
constant "ERROR_UTF16_ERR2" ''CInt
constant "ERROR_UTF16_ERR3" ''CInt
foreign import capi safe "pcre2.h" pcre2_dfa_match
:: Ptr Pcre2_code
-> PCRE2_SPTR
-> PCRE2_SIZE
-> PCRE2_SIZE
-> CUInt
-> Ptr Pcre2_match_data
-> Ptr Pcre2_match_context
-> Ptr CInt
-> PCRE2_SIZE
-> IO CInt
constant "DFA_SHORTEST" ''CUInt
constant "DFA_RESTART" ''CUInt
constant "ERROR_DFA_UFUNC" ''CInt
constant "ERROR_DFA_UITEM" ''CInt
constant "ERROR_DFA_UCOND" ''CInt
constant "ERROR_DFA_UINVALID_UTF" ''CInt
constant "ERROR_DFA_WSSIZE" ''CInt
constant "ERROR_DFA_RECURSE" ''CInt
constant "ERROR_DFA_BADRESTART" ''CInt
foreign import capi unsafe "pcre2.h" pcre2_get_ovector_count
:: Ptr Pcre2_match_data
-> IO CUInt
foreign import capi unsafe "pcre2.h" pcre2_get_ovector_pointer
:: Ptr Pcre2_match_data
-> IO (Ptr PCRE2_SIZE)
foreign import capi unsafe "pcre2.h" pcre2_substring_length_bynumber
:: Ptr Pcre2_match_data
-> CUInt
-> Ptr PCRE2_SIZE
-> IO CInt
foreign import capi safe "pcre2.h" pcre2_substring_copy_bynumber
:: Ptr Pcre2_match_data
-> CUInt
-> Ptr PCRE2_UCHAR
-> Ptr PCRE2_SIZE
-> IO CInt
foreign import capi safe "pcre2.h" pcre2_substring_get_bynumber
:: Ptr Pcre2_match_data
-> CUInt
-> Ptr (Ptr PCRE2_UCHAR)
-> Ptr PCRE2_SIZE
-> IO CInt
foreign import capi unsafe "pcre2.h" pcre2_substring_list_get
:: Ptr Pcre2_match_data
-> Ptr (Ptr (Ptr PCRE2_UCHAR))
-> Ptr (Ptr PCRE2_SIZE)
-> IO CInt
foreign import capi safe "pcre2.h" pcre2_substring_list_free
:: Ptr PCRE2_SPTR
-> IO ()
foreign import capi unsafe "pcre2.h" pcre2_substring_number_from_name
:: Ptr Pcre2_code
-> PCRE2_SPTR
-> IO CInt
foreign import capi unsafe "pcre2.h" pcre2_substring_length_byname
:: Ptr Pcre2_match_data
-> PCRE2_SPTR
-> Ptr PCRE2_SIZE
-> IO CInt
foreign import capi safe "pcre2.h" pcre2_substring_copy_byname
:: Ptr Pcre2_match_data
-> PCRE2_SPTR
-> Ptr PCRE2_UCHAR
-> Ptr PCRE2_SIZE
-> IO CInt
foreign import capi safe "pcre2.h" pcre2_substring_get_byname
:: Ptr Pcre2_match_data
-> PCRE2_SPTR
-> Ptr (Ptr PCRE2_UCHAR)
-> Ptr PCRE2_SIZE
-> IO CInt
foreign import capi safe "pcre2.h" pcre2_substring_free
:: Ptr PCRE2_UCHAR
-> IO ()
constant "ERROR_NOSUBSTRING" ''CInt
constant "ERROR_NOUNIQUESUBSTRING" ''CInt
constant "ERROR_UNAVAILABLE" ''CInt
foreign import capi safe "pcre2.h" pcre2_substitute
:: Ptr Pcre2_code
-> PCRE2_SPTR
-> PCRE2_SIZE
-> PCRE2_SIZE
-> CUInt
-> Ptr Pcre2_match_data
-> Ptr Pcre2_match_context
-> PCRE2_SPTR
-> PCRE2_SIZE
-> Ptr PCRE2_UCHAR
-> Ptr PCRE2_SIZE
-> IO CInt
constant "SUBSTITUTE_REPLACEMENT_ONLY" ''CUInt
constant "SUBSTITUTE_GLOBAL" ''CUInt
constant "SUBSTITUTE_MATCHED" ''CUInt
constant "SUBSTITUTE_OVERFLOW_LENGTH" ''CUInt
constant "SUBSTITUTE_LITERAL" ''CUInt
constant "SUBSTITUTE_UNKNOWN_UNSET" ''CUInt
constant "SUBSTITUTE_UNSET_EMPTY" ''CUInt
constant "SUBSTITUTE_EXTENDED" ''CUInt
constant "ERROR_BADREPLACEMENT" ''CInt
constant "ERROR_BADREPESCAPE" ''CInt
constant "ERROR_BADSUBSTITUTION" ''CInt
constant "ERROR_BADSUBSPATTERN" ''CInt
foreign import capi unsafe "pcre2.h" pcre2_get_mark
:: Ptr Pcre2_match_data
-> IO PCRE2_SPTR
foreign import capi unsafe "pcre2.h" pcre2_get_startchar
:: Ptr Pcre2_match_data
-> IO PCRE2_SIZE
foreign import capi safe "pcre2.h" pcre2_get_error_message
:: CInt
-> Ptr PCRE2_UCHAR
-> PCRE2_SIZE
-> IO CInt