Thu, 09 Feb 2012 15:56:18 +0100
allow parallel use of -s and -S
27
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1 | /* |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
2 | * regex_parser.h |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
3 | * |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
4 | * Created on: 26.01.2012 |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
5 | * Author: Mike |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
6 | */ |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
7 | |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
8 | #ifndef REGEX_PARSER_H_ |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
9 | #define REGEX_PARSER_H_ |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
10 | |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
11 | #define REGEX_MAX_LINELENGTH 2048 |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
12 | |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
13 | #include <sys/types.h> |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
14 | #include <stdbool.h> |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
15 | #include <regex.h> |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
16 | #include "string_list.h" |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
17 | |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
18 | typedef struct { |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
19 | string_list_t* pattern_list; /* even entries: start ; odd entries: end */ |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
20 | regex_t** compiled_patterns; |
28 | 21 | size_t compiled_pattern_count; |
27
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
22 | unsigned int pattern_match; /* save position of end pattern to match - |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
23 | NULL when a start pattern shall match first */ |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
24 | unsigned int matched_lines; |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
25 | } regex_parser_t; |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
26 | |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
27 | #ifdef _cplusplus |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
28 | extern "C" { |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
29 | #endif |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
30 | |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
31 | regex_parser_t* new_regex_parser_t(); |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
32 | void destroy_regex_parser_t(regex_parser_t*); |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
33 | |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
34 | bool regex_parser_matching(regex_parser_t*); |
28 | 35 | bool regex_compile_all(regex_parser_t*); |
36 | int regex_parser_do(regex_parser_t*, char*); | |
27
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
37 | |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
38 | #ifdef _cplusplus |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
39 | } |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
40 | #endif |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
41 | |
95a958e3de88
added regexp_parser struct and compile function
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
42 | #endif /* REGEX_PARSER_H_ */ |