|
57 | 57 |
|
58 | 58 | #ifdef HAVE_RULES |
59 | 59 | #include "regex.h" |
| 60 | +#include "rule.h" |
60 | 61 |
|
61 | 62 | // xml is used for rules |
62 | 63 | #include "xml.h" |
@@ -1304,7 +1305,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a |
1304 | 1305 | // Rule given at command line |
1305 | 1306 | else if (std::strncmp(argv[i], "--rule=", 7) == 0) { |
1306 | 1307 | #ifdef HAVE_RULES |
1307 | | - Settings::Rule rule; |
| 1308 | + Rule rule; |
1308 | 1309 | rule.pattern = 7 + argv[i]; |
1309 | 1310 |
|
1310 | 1311 | if (rule.pattern.empty()) { |
@@ -1340,7 +1341,8 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a |
1340 | 1341 | if (node && strcmp(node->Value(), "rules") == 0) |
1341 | 1342 | node = node->FirstChildElement("rule"); |
1342 | 1343 | for (; node && strcmp(node->Value(), "rule") == 0; node = node->NextSiblingElement()) { |
1343 | | - Settings::Rule rule; |
| 1344 | + Rule rule; |
| 1345 | + Regex::Engine regexEngine = Regex::Engine::Pcre; |
1344 | 1346 |
|
1345 | 1347 | for (const tinyxml2::XMLElement *subnode = node->FirstChildElement(); subnode; subnode = subnode->NextSiblingElement()) { |
1346 | 1348 | const char * const subname = subnode->Name(); |
@@ -1373,7 +1375,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a |
1373 | 1375 | else if (std::strcmp(subname, "engine") == 0) { |
1374 | 1376 | const char * const engine = empty_if_null(subtext); |
1375 | 1377 | if (std::strcmp(engine, "pcre") == 0) { |
1376 | | - rule.engine = Regex::Engine::Pcre; |
| 1378 | + regexEngine = Regex::Engine::Pcre; |
1377 | 1379 | } |
1378 | 1380 | else { |
1379 | 1381 | mLogger.printError(std::string("unknown regex engine '") + engine + "'."); |
@@ -1407,7 +1409,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a |
1407 | 1409 | } |
1408 | 1410 |
|
1409 | 1411 | std::string regex_err; |
1410 | | - auto regex = Regex::create(rule.pattern, rule.engine, regex_err); |
| 1412 | + auto regex = Regex::create(rule.pattern, regexEngine, regex_err); |
1411 | 1413 | if (!regex) { |
1412 | 1414 | mLogger.printError("unable to load rule-file '" + ruleFile + "' - pattern '" + rule.pattern + "' failed to compile (" + regex_err + ")."); |
1413 | 1415 | return Result::Fail; |
|
0 commit comments