[][src]Function hyperscan_sys::hs_expression_info

pub unsafe extern "C" fn hs_expression_info(
    expression: *const c_char,
    flags: c_uint,
    info: *mut *mut hs_expr_info_t,
    error: *mut *mut hs_compile_error_t
) -> hs_error_t

Utility function providing information about a regular expression. The information provided in @ref hs_expr_info_t includes the minimum and maximum width of a pattern match.

Note: successful analysis of an expression with this function does not imply that compilation of the same expression (via @ref hs_compile(), @ref hs_compile_multi() or @ref hs_compile_ext_multi()) would succeed. This function may return @ref HS_SUCCESS for regular expressions that Hyperscan cannot compile.

Note: some per-pattern flags (such as @ref HS_FLAG_ALLOWEMPTY, @ref HS_FLAG_SOM_LEFTMOST) are accepted by this call, but as they do not affect the properties returned in the @ref hs_expr_info_t structure, they will not affect the outcome of this function.

@param expression The NULL-terminated expression to parse. Note that this string must represent ONLY the pattern to be matched, with no delimiters or flags; any global flags should be specified with the @p flags argument. For example, the expression /abc?def/i should be compiled by providing abc?def as the @p expression, and @ref HS_FLAG_CASELESS as the @a flags.

@param flags Flags which modify the behaviour of the expression. Multiple flags may be used by ORing them together. Valid values are:

  • HS_FLAG_CASELESS - Matching will be performed case-insensitively.
  • HS_FLAG_DOTALL - Matching a . will not exclude newlines.
  • HS_FLAG_MULTILINE - ^ and $ anchors match any newlines in data.
  • HS_FLAG_SINGLEMATCH - Only one match will be generated by the expression per stream.
  • HS_FLAG_ALLOWEMPTY - Allow expressions which can match against an empty string, such as .*.
  • HS_FLAG_UTF8 - Treat this pattern as a sequence of UTF-8 characters.
  • HS_FLAG_UCP - Use Unicode properties for character classes.
  • HS_FLAG_PREFILTER - Compile pattern in prefiltering mode.
  • HS_FLAG_SOM_LEFTMOST - Report the leftmost start of match offset when a match is found.

@param info On success, a pointer to the pattern information will be returned in this parameter, or NULL on failure. This structure is allocated using the allocator supplied in @ref hs_set_allocator() (or malloc() if no allocator was set) and should be freed by the caller.

@param error If the call fails, a pointer to a @ref hs_compile_error_t will be returned, providing details of the error condition. The caller is responsible for deallocating the buffer using the @ref hs_free_compile_error() function.

@return @ref HS_SUCCESS is returned on successful compilation; @ref HS_COMPILER_ERROR on failure, with details provided in the error parameter.