|
Revision 5, 0.7 KB
(checked in by nick, 3 years ago)
|
|
|
| Line | |
|---|
| 1 | #include "apachetop.h" |
|---|
| 2 | |
|---|
| 3 | Filter::Filter(void) |
|---|
| 4 | { |
|---|
| 5 | #if HAVE_PCRE_H_ |
|---|
| 6 | regexp = NULL; |
|---|
| 7 | #endif |
|---|
| 8 | filter_text = NULL; |
|---|
| 9 | } |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | Filter::~Filter(void) |
|---|
| 13 | { |
|---|
| 14 | this->empty(); |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | void Filter::store(const char *filter) |
|---|
| 19 | { |
|---|
| 20 | if (filter_text) free(filter_text); |
|---|
| 21 | filter_text = strdup(filter); |
|---|
| 22 | |
|---|
| 23 | #if HAVE_PCRE_H_ |
|---|
| 24 | if (regexp) delete regexp; |
|---|
| 25 | regexp = new RegEx(filter); |
|---|
| 26 | #endif |
|---|
| 27 | |
|---|
| 28 | return; |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | bool Filter::isactive() |
|---|
| 33 | { |
|---|
| 34 | return filter_text ? true : false; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | bool Filter::match(const char *string) |
|---|
| 39 | { |
|---|
| 40 | if (!filter_text) |
|---|
| 41 | return false; |
|---|
| 42 | |
|---|
| 43 | #if HAVE_PCRE_H_ |
|---|
| 44 | return regexp->Search(string); |
|---|
| 45 | #else |
|---|
| 46 | return strstr(string, filter_text); |
|---|
| 47 | #endif |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | void Filter::empty(void) |
|---|
| 52 | { |
|---|
| 53 | #if HAVE_PCRE_H_ |
|---|
| 54 | if (regexp) delete regexp; |
|---|
| 55 | regexp = NULL; |
|---|
| 56 | #endif |
|---|
| 57 | if (filter_text) free(filter_text); |
|---|
| 58 | filter_text = NULL; |
|---|
| 59 | } |
|---|