Mercurial > hg > th-libs
view th_regex.h @ 640:9e1f9e1d1487
Aaand some more work. Still just a broken concept.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 24 Jan 2020 09:13:24 +0200 |
parents | 8c957ad9d4c3 |
children | b897995101b7 |
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_t; // Structure containing the compiled regular expression struct th_regex_t; typedef struct th_regex_t th_regex_t; // Linked list structure for returned match sequences typedef struct { th_llist_t node; size_t start, len; } th_regex_match_t; // Flags for th_regex_match() // (not actually used or supported yet :D) enum { TH_REF_CASEFOLD = 0x0001, TH_REF_ANCHORED = 0x0002, }; #ifdef TH_EXPERIMENTAL_REGEX_DEBUG enum { TH_DBG_RE_COMPILE = 0x0001, TH_DBG_RE_FREE = 0x0002, TH_DBG_RE_MATCH = 0x0004, }; extern int th_dbg_re_flags; #endif // // Functions // int th_regex_compile(th_regex_t **pexpr, const th_regex_char_t *pattern); void th_regex_free(th_regex_t *expr); int th_regex_match(const th_regex_t *expr, const th_regex_char_t *haystack, size_t *pnmatches, th_regex_match_t **pmatches, const size_t maxmatches, const int flags); void th_regex_free_matches(th_regex_match_t *matches); #ifdef __cplusplus } #endif #endif // TH_REGEX_H #endif // TH_EXPERIMENTAL_REGEX