pub unsafe extern "C" fn hs_compile_lit(
    expression: *const c_char,
    flags: c_uint,
    len: usize,
    mode: c_uint,
    platform: *const hs_platform_info_t,
    db: *mut *mut hs_database_t,
    error: *mut *mut hs_compile_error_t
) -> hs_error_t
Expand description

The basic pure literal expression compiler.

This is the function call with which a pure literal expression (not a common regular expression) is compiled into a Hyperscan database which can be passed to the runtime functions (such as @ref hs_scan(), @ref hs_open_stream(), etc.)

@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. Meanwhile, the string content shall be fully parsed in a literal sense without any regular grammars. For example, the @p expression abc? simply means a char sequence of a, b, c, and ?. The ? here doesn’t mean 0 or 1 quantifier under regular semantics.

@param flags Flags which modify the behaviour of the expression. Multiple flags may be used by ORing them together. Compared to @ref hs_compile(), fewer valid values are provided: - HS_FLAG_CASELESS - Matching will be performed case-insensitively. - HS_FLAG_SINGLEMATCH - Only one match will be generated for the expression per stream. - HS_FLAG_SOM_LEFTMOST - Report the leftmost start of match offset when a match is found.

@param len The length of the text content of the pure literal expression. As the text content indicated by @p expression is treated as single character one by one, the special terminating character \0 should be allowed to appear in expression, and not treated as a terminator for a string. Thus, the end of a pure literal expression cannot be indicated by identifying \0, but by counting to the expression length.

@param mode Compiler mode flags that affect the database as a whole. One of @ref HS_MODE_STREAM or @ref HS_MODE_BLOCK or @ref HS_MODE_VECTORED must be supplied, to select between the generation of a streaming, block or vectored database. In addition, other flags (beginning with HS_MODE_) may be supplied to enable specific features. See @ref HS_MODE_FLAG for more details.

@param platform If not NULL, the platform structure is used to determine the target platform for the database. If NULL, a database suitable for running on the current host platform is produced.

@param db On success, a pointer to the generated database will be returned in this parameter, or NULL on failure. The caller is responsible for deallocating the buffer using the @ref hs_free_database() function.

@param error If the compile 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.