Haka: include/haka/regexp_module.h Source File

Haka

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

regexp_module.h
Go to the documentation of this file.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
10 #ifndef HAKA_REGEXP_MODULE_H
11 #define HAKA_REGEXP_MODULE_H
12
13 #include <haka/module.h>
14 #include <haka/thread.h>
15 #include <haka/vbuffer.h>
16
17 #define REGEXP_MATCH 1
18 #define REGEXP_NOMATCH 0
19 #define REGEXP_ERROR -1
20 #define REGEXP_PARTIAL -2
21
22 struct regexp;
23 struct regexp_sink;
24
25 struct regexp_result {
26 size_t first;
27 size_t last;
28 };
29
30 extern const struct regexp_result regexp_result_init;
31
32 #define REGEXP_CASE_INSENSITIVE (1 << 0)
33 #define REGEXP_EXTENDED (1 << 1)
34
35 struct regexp_module {
36 struct module module;
37
38 int (*match)(const char *pattern, int options, const char *buffer, int len, struct regexp_result *result);
39 int (*vbmatch)(const char *pattern, int options, struct vbuffer_sub *vbuf, struct vbuffer_sub *result);
40
41 struct regexp *(*compile)(const char *pattern, int options);
42 void (*release_regexp)(struct regexp *regexp);
43 int (*exec)(struct regexp *regexp, const char *buffer, int len, struct regexp_result *result);
44 int (*vbexec)(struct regexp *regexp, struct vbuffer_sub *vbuf, struct vbuffer_sub *result);
45
46 struct regexp_sink *(*create_sink)(struct regexp *regexp);
47 void (*free_regexp_sink)(struct regexp_sink *re_sink);
48 int (*feed)(struct regexp_sink *re_sink, const char *buffer, int len, bool eof, struct regexp_result *result);
49 int (*vbfeed)(struct regexp_sink *re_sink, struct vbuffer_sub *vbuf, bool eof,
50 struct vbuffer_iterator *begin, struct vbuffer_iterator *end);
51 };
52
53 struct regexp {
54 const struct regexp_module *module;
55 atomic_t ref_count;
56 };
57
58 struct regexp_sink {
59 struct regexp *regexp;
60 int match;
61 };
62
63 struct regexp_module *regexp_module_load(const char *module_name, struct parameters *args);
64 void regexp_module_release(struct regexp_module *module);
65
66 #endif /* HAKA_LOG_MODULE_H */
vbuffer_iterator
Definition: vbuffer.h:77
module
Definition: module.h:34
atomic_t
volatile uint32 atomic_t
Definition: thread.h:267
module.h
vbuffer_sub
Definition: vbuffer.h:91