From 05d42c036f899ce4628b7af6b1e98ca03e31a306 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Fri, 8 Nov 2024 13:59:06 +0500 Subject: [PATCH] UI: ConfBuffer: Prepare writeRuleText() --- src/ui/util/conf/confbuffer.cpp | 25 +++++++++++++++---------- src/ui/util/conf/confbuffer.h | 4 ++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/ui/util/conf/confbuffer.cpp b/src/ui/util/conf/confbuffer.cpp index 1f1eb076..cd46f1c5 100644 --- a/src/ui/util/conf/confbuffer.cpp +++ b/src/ui/util/conf/confbuffer.cpp @@ -265,13 +265,14 @@ bool ConfBuffer::writeRules(const ConfRulesWalker &confRulesWalker) buffer().resize(outSize); 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; } - writeRule(rule, ruleSetMap, ruleSetIds); - - return true; + return writeRule(rule, ruleSetMap, ruleSetIds); }); } @@ -548,7 +549,7 @@ bool ConfBuffer::addApp(const App &app, bool isNew, appdata_map_t &appsMap, quin return true; } -void ConfBuffer::writeRule( +bool ConfBuffer::writeRule( const Rule &rule, const ruleset_map_t &ruleSetMap, const ruleid_arr_t &ruleSetIds) { const int ruleId = rule.ruleId; @@ -610,15 +611,19 @@ void ConfBuffer::writeRule( // Write the rule's conditions 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); - while (parser.parse()) { - // TODO - } + if (!parser.parse()) + return false; + + return true; } diff --git a/src/ui/util/conf/confbuffer.h b/src/ui/util/conf/confbuffer.h index d57f642d..62138084 100644 --- a/src/ui/util/conf/confbuffer.h +++ b/src/ui/util/conf/confbuffer.h @@ -68,9 +68,9 @@ private: 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); - void writeRuleText(const QString &ruleText); + bool writeRuleText(const QString &ruleText); private: quint32 m_driveMask = 0;