Support PCRE2

This commit is contained in:
Martin Vierula
2022-04-13 09:37:54 -07:00
parent 5519f6cfae
commit f84614fe06
9 changed files with 380 additions and 18 deletions

View File

@@ -16,7 +16,14 @@
#ifndef SRC_OPERATORS_VERIFY_CC_H_
#define SRC_OPERATORS_VERIFY_CC_H_
#if WITH_PCRE2
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
#else
#include <pcre.h>
#endif
#include <string>
#include <memory>
#include <utility>
@@ -32,7 +39,11 @@ class VerifyCC : public Operator {
explicit VerifyCC(std::unique_ptr<RunTimeString> param)
: Operator("VerifyCC", std::move(param)),
m_pc(NULL),
#if WITH_PCRE2
m_match_data(NULL) { }
#else
m_pce(NULL) { }
#endif
~VerifyCC();
bool evaluate(Transaction *t, RuleWithActions *rule,
@@ -40,8 +51,13 @@ class VerifyCC : public Operator {
std::shared_ptr<RuleMessage> ruleMessage) override;
bool init(const std::string &param, std::string *error) override;
private:
#if WITH_PCRE2
pcre2_code *m_pc;
pcre2_match_data *m_match_data;
#else
pcre *m_pc;
pcre_extra *m_pce;
#endif
static int luhnVerify(const char *ccnumber, int len);
};