UI: ConfBuffer: Prepare writeRuleText()

This commit is contained in:
Nodir Temirkhodjaev 2024-11-08 13:59:06 +05:00
parent 0b0b520703
commit 05d42c036f
2 changed files with 17 additions and 12 deletions

View File

@ -265,13 +265,14 @@ bool ConfBuffer::writeRules(const ConfRulesWalker &confRulesWalker)
buffer().resize(outSize); buffer().resize(outSize);
buffer().fill('\0'); buffer().fill('\0');
PFORT_CONF_RULES rules = (PFORT_CONF_RULES) buffer().data(); // Fill the buffer
char *data = buffer().data();
PFORT_CONF_RULES rules = PFORT_CONF_RULES(data);
rules->max_rule_id = maxRuleId; rules->max_rule_id = maxRuleId;
} }
writeRule(rule, ruleSetMap, ruleSetIds); return writeRule(rule, ruleSetMap, ruleSetIds);
return true;
}); });
} }
@ -548,7 +549,7 @@ bool ConfBuffer::addApp(const App &app, bool isNew, appdata_map_t &appsMap, quin
return true; return true;
} }
void ConfBuffer::writeRule( bool ConfBuffer::writeRule(
const Rule &rule, const ruleset_map_t &ruleSetMap, const ruleid_arr_t &ruleSetIds) const Rule &rule, const ruleset_map_t &ruleSetMap, const ruleid_arr_t &ruleSetIds)
{ {
const int ruleId = rule.ruleId; const int ruleId = rule.ruleId;
@ -610,15 +611,19 @@ void ConfBuffer::writeRule(
// Write the rule's conditions // Write the rule's conditions
if (hasFilter) { if (hasFilter) {
writeRuleText(rule.ruleText); if (!writeRuleText(rule.ruleText))
return false;
} }
return true;
} }
void ConfBuffer::writeRuleText(const QString &ruleText) bool ConfBuffer::writeRuleText(const QString &ruleText)
{ {
RuleTextParser parser(ruleText); RuleTextParser parser(ruleText);
while (parser.parse()) { if (!parser.parse())
// TODO return false;
}
return true;
} }

View File

@ -68,9 +68,9 @@ private:
bool addApp(const App &app, bool isNew, appdata_map_t &appsMap, quint32 &appsSize); bool addApp(const App &app, bool isNew, appdata_map_t &appsMap, quint32 &appsSize);
void writeRule( bool writeRule(
const Rule &rule, const ruleset_map_t &ruleSetMap, const ruleid_arr_t &ruleSetIds); const Rule &rule, const ruleset_map_t &ruleSetMap, const ruleid_arr_t &ruleSetIds);
void writeRuleText(const QString &ruleText); bool writeRuleText(const QString &ruleText);
private: private:
quint32 m_driveMask = 0; quint32 m_driveMask = 0;