mirror of
https://github.com/tnodir/fort
synced 2024-11-14 22:19:05 +00:00
UI: ConfUtil: Refactor writeConf()
This commit is contained in:
parent
190bb5bcc0
commit
26ad39851f
@ -271,9 +271,11 @@ bool ConfBuffer::write(
|
||||
+ FORT_CONF_STR_DATA_SIZE(opt.prefixAppsSize)
|
||||
+ FORT_CONF_STR_DATA_SIZE(opt.exeAppsSize));
|
||||
|
||||
buffer().resize(confIoSize);
|
||||
buffer().resize(confIoSize); // shrink to actual size
|
||||
|
||||
ConfUtil::writeConf(buffer().data(), wca, opt);
|
||||
char *data = buffer().data();
|
||||
|
||||
ConfUtil::writeConf(&data, wca, opt);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -152,27 +152,29 @@ QString ConfUtil::parseAppPath(const QStringView &line, bool &isWild, bool &isPr
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
void ConfUtil::writeConf(char *output, const WriteConfArgs &wca, AppParseOptions &opt)
|
||||
void ConfUtil::writeConf(char **data, const WriteConfArgs &wca, AppParseOptions &opt)
|
||||
{
|
||||
PFORT_CONF_IO drvConfIo = (PFORT_CONF_IO) output;
|
||||
PFORT_CONF_IO drvConfIo = PFORT_CONF_IO(*data);
|
||||
PFORT_CONF drvConf = &drvConfIo->conf;
|
||||
char *data = drvConf->data;
|
||||
|
||||
quint32 addrGroupsOff;
|
||||
quint32 wildAppsOff, prefixAppsOff, exeAppsOff;
|
||||
|
||||
#define CONF_DATA_OFFSET quint32(data - drvConf->data)
|
||||
*data = drvConf->data;
|
||||
|
||||
#define CONF_DATA_OFFSET quint32(*data - drvConf->data)
|
||||
addrGroupsOff = CONF_DATA_OFFSET;
|
||||
writeLongs(&data, wca.ad.addressGroupOffsets);
|
||||
writeAddressRanges(&data, wca.ad.addressRanges);
|
||||
writeLongs(data, wca.ad.addressGroupOffsets);
|
||||
writeAddressRanges(data, wca.ad.addressRanges);
|
||||
|
||||
wildAppsOff = CONF_DATA_OFFSET;
|
||||
writeApps(&data, opt.wildAppsMap);
|
||||
writeApps(data, opt.wildAppsMap);
|
||||
|
||||
prefixAppsOff = CONF_DATA_OFFSET;
|
||||
writeApps(&data, opt.prefixAppsMap, /*useHeader=*/true);
|
||||
writeApps(data, opt.prefixAppsMap, /*useHeader=*/true);
|
||||
|
||||
exeAppsOff = CONF_DATA_OFFSET;
|
||||
writeApps(&data, opt.exeAppsMap);
|
||||
writeApps(data, opt.exeAppsMap);
|
||||
#undef CONF_DATA_OFFSET
|
||||
|
||||
PFORT_CONF_GROUP conf_group = &drvConfIo->conf_group;
|
||||
@ -181,8 +183,8 @@ void ConfUtil::writeConf(char *output, const WriteConfArgs &wca, AppParseOptions
|
||||
|
||||
writeLimits(conf_group, wca.conf.appGroups());
|
||||
|
||||
data = (char *) &drvConf->flags;
|
||||
writeConfFlags(&data, wca.conf);
|
||||
*data = (char *) &drvConf->flags;
|
||||
writeConfFlags(data, wca.conf);
|
||||
|
||||
drvConf->proc_wild = opt.procWild;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
static QString parseAppPath(const QStringView &line, bool &isWild, bool &isPrefix);
|
||||
|
||||
static void writeConf(char *output, const WriteConfArgs &wca, AppParseOptions &opt);
|
||||
static void writeConf(char **data, const WriteConfArgs &wca, AppParseOptions &opt);
|
||||
static void writeConfFlags(char **data, const FirewallConf &conf);
|
||||
|
||||
static void writeAddressRanges(char **data, const addrranges_arr_t &addressRanges);
|
||||
|
Loading…
Reference in New Issue
Block a user