binpac: Initial import of Bro's binpac subdirectory from SVN r7088.

This commit is contained in:
Jon Siwek 2010-10-13 15:17:20 -05:00 committed by Tim Wojtulewicz
parent 5a1c4fd5fe
commit c8665318e6
113 changed files with 15630 additions and 0 deletions

View 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