Mercurial > hg > th-libs
view th_regex.h @ 617:a3d5ddbb6f16
Add some extra () protection in the th_is* macro wrapper arguments.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 17 Jan 2020 03:21:05 +0200 |
parents | a0e8d9c6300b |
children | d191ded8a790 |
line wrap: on
line source
/* * Simple regular expression matching functionality * Programmed and designed by Matti 'ccr' Hamalainen * (C) Copyright 2020 Tecnic Software productions (TNSP) * * Please read file 'COPYING' for information on license and distribution. */ #ifdef TH_EXPERIMENTAL_REGEX #ifndef TH_REGEX_H #define TH_REGEX_H #include "th_types.h" #include "th_datastruct.h" #ifdef __cplusplus extern "C" { #endif // // Definitions // // Character type typedef char th_regex_char; enum { TH_REF_CASEFOLD = 0x0001, TH_REF_ANCHORED = 0x0002, }; struct th_regex_ctx; typedef struct { int mode, type; ssize_t repeatMin, repeatMax; union { th_regex_char chr; struct { size_t nchars; th_regex_char *chars; } list; struct th_regex_ctx *expr; } match; } th_regex_node; typedef struct th_regex_ctx { size_t nnodes, nodessize; th_regex_node *nodes; } th_regex_ctx; typedef struct { th_llist_t node; size_t start, len; } th_regex_match_node; // // Functions // int th_regex_compile(th_regex_ctx **pexpr, const th_regex_char *pattern); void th_regex_free(th_regex_ctx *expr); int th_regex_match(const th_regex_ctx *expr, const th_regex_char *haystack, size_t *pnmatches, th_regex_match_node **pmatches, const size_t maxmatches, const int flags); void th_regex_free_matches(th_regex_match_node *matches); #ifdef __cplusplus } #endif #endif // TH_REGEX_H #endif // TH_EXPERIMENTAL_REGEX