mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
binpac: Initial import of Bro's binpac subdirectory from SVN r7088.
This commit is contained in:
parent
5a1c4fd5fe
commit
c8665318e6
113 changed files with 15630 additions and 0 deletions
43
tools/binpac/lib/binpac_regex.h
Normal file
43
tools/binpac/lib/binpac_regex.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef binpac_regex_h
|
||||
#define binpac_regex_h
|
||||
|
||||
#include "binpac.h"
|
||||
#include "RE.h"
|
||||
|
||||
class RE_Matcher;
|
||||
|
||||
namespace binpac
|
||||
{
|
||||
|
||||
class RegExMatcher {
|
||||
public:
|
||||
RegExMatcher(const char *pattern)
|
||||
: pattern_(pattern)
|
||||
{
|
||||
re_matcher_ = 0;
|
||||
}
|
||||
|
||||
~RegExMatcher()
|
||||
{
|
||||
delete re_matcher_;
|
||||
}
|
||||
|
||||
// Returns the length of longest match, or -1 on mismatch.
|
||||
int MatchPrefix(const_byteptr data, int len)
|
||||
{
|
||||
if ( ! re_matcher_ )
|
||||
{
|
||||
re_matcher_ = new RE_Matcher(pattern_.c_str());
|
||||
re_matcher_->Compile();
|
||||
}
|
||||
return re_matcher_->MatchPrefix(data, len);
|
||||
}
|
||||
|
||||
private:
|
||||
string pattern_;
|
||||
RE_Matcher *re_matcher_;
|
||||
};
|
||||
|
||||
} // namespace binpac
|
||||
|
||||
#endif // binpac_regex_h
|
Loading…
Add table
Add a link
Reference in a new issue