annotate th_regex.h @ 651:18fe45e61b2b

Moar re-work.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 25 Jan 2020 13:13:37 +0200
parents b897995101b7
children 38a9302962f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
605
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Simple regular expression matching functionality
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Programmed and designed by Matti 'ccr' Hamalainen
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * (C) Copyright 2020 Tecnic Software productions (TNSP)
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 *
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * Please read file 'COPYING' for information on license and distribution.
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 */
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #ifdef TH_EXPERIMENTAL_REGEX
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 #ifndef TH_REGEX_H
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #define TH_REGEX_H
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
610
a0e8d9c6300b A bit more work on the regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
13 #include "th_types.h"
a0e8d9c6300b A bit more work on the regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
14 #include "th_datastruct.h"
651
18fe45e61b2b Moar re-work.
Matti Hamalainen <ccr@tnsp.org>
parents: 645
diff changeset
15 #include "th_ioctx.h"
610
a0e8d9c6300b A bit more work on the regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
16
605
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 #ifdef __cplusplus
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 extern "C" {
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 #endif
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21
639
8c957ad9d4c3 Some more work on regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 635
diff changeset
22
605
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 //
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 // Definitions
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 //
640
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
26
605
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 // Character type
640
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
28 typedef char th_regex_char_t;
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
29
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
30
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
31 // Structure containing the compiled regular expression
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
32 struct th_regex_t;
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
33 typedef struct th_regex_t th_regex_t;
605
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
640
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
36 // Linked list structure for returned match sequences
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
37 typedef struct
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
38 {
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
39 th_llist_t node;
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
40 size_t start, len;
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
41 } th_regex_match_t;
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
42
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
43
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
44 // Flags for th_regex_match()
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
45 // (not actually used or supported yet :D)
610
a0e8d9c6300b A bit more work on the regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
46 enum
a0e8d9c6300b A bit more work on the regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
47 {
a0e8d9c6300b A bit more work on the regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
48 TH_REF_CASEFOLD = 0x0001,
a0e8d9c6300b A bit more work on the regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
49 TH_REF_ANCHORED = 0x0002,
a0e8d9c6300b A bit more work on the regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
50 };
a0e8d9c6300b A bit more work on the regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
51
a0e8d9c6300b A bit more work on the regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
52
635
d191ded8a790 Improve the experimental regex matching debugging macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
53 #ifdef TH_EXPERIMENTAL_REGEX_DEBUG
651
18fe45e61b2b Moar re-work.
Matti Hamalainen <ccr@tnsp.org>
parents: 645
diff changeset
54 extern th_ioctx *th_dbg_fh;
635
d191ded8a790 Improve the experimental regex matching debugging macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
55 #endif
d191ded8a790 Improve the experimental regex matching debugging macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
56
d191ded8a790 Improve the experimental regex matching debugging macros.
Matti Hamalainen <ccr@tnsp.org>
parents: 610
diff changeset
57
605
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 //
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 // Functions
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 //
640
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
61 int th_regex_compile(th_regex_t **pexpr, const th_regex_char_t *pattern);
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
62 void th_regex_free(th_regex_t *expr);
651
18fe45e61b2b Moar re-work.
Matti Hamalainen <ccr@tnsp.org>
parents: 645
diff changeset
63 void th_regex_dump(th_ioctx *fh, const int level, const th_regex_t *expr);
605
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64
640
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
65 int th_regex_match(const th_regex_t *expr, const th_regex_char_t *haystack,
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
66 size_t *pnmatches, th_regex_match_t **pmatches, const size_t maxmatches,
610
a0e8d9c6300b A bit more work on the regex stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 605
diff changeset
67 const int flags);
640
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
68
9e1f9e1d1487 Aaand some more work. Still just a broken concept.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
69 void th_regex_free_matches(th_regex_match_t *matches);
605
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 #ifdef __cplusplus
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 }
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 #endif
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 #endif // TH_REGEX_H
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76
566e6ef41f9d Initial commit of the highly experimental and unfinished regular expression
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 #endif // TH_EXPERIMENTAL_REGEX