1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2025-02-12 08:37:39 +01:00

fix: Add support for Qt6

This commit is contained in:
Sirius Bakke 2023-07-22 20:06:11 +02:00
parent b6648fd18a
commit f76af1915d
184 changed files with 907 additions and 982 deletions

View File

@ -299,7 +299,11 @@ protected:
{
#ifdef ANTLR_CXX_SUPPORTS_UNCAUGHT_EXCEPTION
// Only give trace if there's no uncaught exception..
if(!ANTLR_USE_NAMESPACE(std)uncaught_exception())
#if __cplusplus > 201402
if(!ANTLR_USE_NAMESPACE(std)uncaught_exceptions())
#else
if(!ANTLR_USE_NAMESPACE(std)uncaught_exception())
#endif
#endif
parser->traceOut(text);
}

View File

@ -30,7 +30,7 @@
#include "fwbuilder/Resources.h"
#include "fwbuilder/Constants.h"
#include <QRegExp>
#include <QRegularExpression>
#include <QTextStream>
#include <QDir>
#include <QFile>
@ -170,8 +170,7 @@ QString Configlet::expand()
{
// Need non-greedy matching so that if_re matches only one {{?var}} ... {{?}}
// clause
QRegExp var_re("\\{\\{\\$([^}]*)\\}\\}", Qt::CaseSensitive, QRegExp::RegExp2);
var_re.setMinimal(true);
QRegularExpression var_re("\\{\\{\\$([^}]*)\\}\\}", QRegularExpression::InvertedGreedinessOption);
// remove comments before processing {{$var}} and {{if var}} so we can
// use these in comments
@ -194,10 +193,11 @@ QString Configlet::expand()
"Check configlet syntax. %1").arg(file_path);
int counter = 0;
int pos = 0;
while ((pos = var_re.indexIn(all_code, pos)) != -1 && counter < 1000)
qsizetype from = 0;
QRegularExpressionMatch match;
while ((from = all_code.indexOf(var_re, from, &match)) != -1 && counter < 1000)
{
QString var = var_re.cap(1);
QString var = match.captured(1);
if (vars.count(var) > 0)
{
@ -243,21 +243,21 @@ QString Configlet::expand()
*/
bool Configlet::processIf(QString &stream, int pos)
{
QRegExp if_re("\\{\\{if {1,}([^}]{1,})\\}\\}", Qt::CaseSensitive, QRegExp::RegExp2);
QRegExp endif_re("\\{\\{endif\\}\\}", Qt::CaseSensitive, QRegExp::RegExp2);
if_re.setMinimal(true);
endif_re.setMinimal(true);
int current_if_pos = if_re.indexIn(stream, pos);
QRegularExpression if_re("\\{\\{if {1,}([^}]{1,})\\}\\}", QRegularExpression::InvertedGreedinessOption);
QRegularExpression endif_re("\\{\\{endif\\}\\}", QRegularExpression::InvertedGreedinessOption);
QRegularExpressionMatch if_re_match;
QRegularExpressionMatch endif_re_match;
qsizetype current_if_pos = stream.indexOf(if_re, pos, &if_re_match);
if (current_if_pos == -1) return false;
int current_if_length = if_re.cap(0).length();
QString current_if_var = if_re.cap(1);
qsizetype current_if_length = if_re_match.capturedLength();
QString current_if_var = if_re_match.captured(1);
// look what is next, another opening if or closing endif
int next_if_pos = if_re.indexIn(
stream, current_if_pos + current_if_length);
int next_endif_pos = endif_re.indexIn(
stream, current_if_pos + current_if_length);
qsizetype next_if_pos = stream.indexOf(if_re, current_if_pos + current_if_length);
qsizetype next_endif_pos = stream.indexOf(endif_re, current_if_pos + current_if_length, &endif_re_match);
if (next_if_pos != -1 && next_if_pos < next_endif_pos)
{
@ -269,10 +269,10 @@ bool Configlet::processIf(QString &stream, int pos)
if (next_endif_pos != -1)
{
int next_endif_length = endif_re.cap(0).length();
qsizetype next_endif_length = endif_re_match.capturedLength();
// current if statement starts at current_if_pos
// and ends at next_endif_pos + next_endif_length
int current_if_clause_length =
qsizetype current_if_clause_length =
next_endif_pos + next_endif_length - current_if_pos;
QString body = stream.mid(
current_if_pos + current_if_length,

View File

@ -41,7 +41,7 @@
#include <QDebug>
#include <QObject>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
using namespace std;
@ -71,8 +71,8 @@ bool interfaceProperties::looksLikeVlanInterface(const QString &int_name)
*/
bool interfaceProperties::looksLikeInterface(const QString &name)
{
QRegExp basic_interface_name_pattern("^[a-zA-Z]+\\d{1,}(\\.\\d{1,})?(:\\d{1,})?$");
return (basic_interface_name_pattern.indexIn(name) != -1);
QRegularExpression basic_interface_name_pattern("^[a-zA-Z]+\\d{1,}(\\.\\d{1,})?(:\\d{1,})?$");
return (name.indexOf(basic_interface_name_pattern) != -1);
}
// simple name validation: does not allow space and "-"

View File

@ -29,7 +29,7 @@
#include <QDebug>
#include <QObject>
#include <QRegExp>
#include <QRegularExpression>
using namespace std;
using namespace libfwbuilder;
@ -37,11 +37,12 @@ using namespace libfwbuilder;
bool iosInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QRegExp vlan_name_pattern("([a-zA-Z-]+\\d{1,}/\\d{1,})\\.(\\d{1,})");
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern("([a-zA-Z-]+\\d{1,}/\\d{1,})\\.(\\d{1,})");
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_pattern.cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(2).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(2).toInt();
return true;
}
return false;

View File

@ -29,7 +29,7 @@
#include <QDebug>
#include <QObject>
#include <QRegExp>
#include <QRegularExpression>
using namespace std;
using namespace libfwbuilder;
@ -37,11 +37,12 @@ using namespace libfwbuilder;
bool junosInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QRegExp vlan_name_pattern("unit (\\d{1,})");
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern("unit (\\d{1,})");
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = QString("unit");
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(1).toInt();
if (vlan_id!=nullptr) *vlan_id = match.captured(1).toInt();
return true;
}
return false;

View File

@ -31,7 +31,7 @@
#include <iostream>
#include <QObject>
#include <QRegExp>
#include <QRegularExpression>
using namespace std;
@ -40,15 +40,16 @@ using namespace libfwbuilder;
bool linux24Interfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QList<QRegExp> vlan_name_patterns;
vlan_name_patterns.append(QRegExp("([a-zA-Z0-9-]+\\d{1,})\\.(\\d{1,})"));
vlan_name_patterns.append(QRegExp("(vlan)(\\d{1,})"));
QList<QRegularExpression> vlan_name_patterns;
vlan_name_patterns.append(QRegularExpression("([a-zA-Z0-9-]+\\d{1,})\\.(\\d{1,})"));
vlan_name_patterns.append(QRegularExpression("(vlan)(\\d{1,})"));
QRegularExpressionMatch match;
for (int idx=0; idx < vlan_name_patterns.size(); ++idx)
{
if (vlan_name_patterns[idx].indexIn(name) != -1)
if (name.indexOf(vlan_name_patterns[idx], 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_patterns[idx].cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_patterns[idx].cap(2).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(2).toInt();
return true;
}
}

View File

@ -29,7 +29,7 @@
#include <QDebug>
#include <QObject>
#include <QRegExp>
#include <QRegularExpression>
using namespace std;
using namespace libfwbuilder;
@ -37,11 +37,12 @@ using namespace libfwbuilder;
bool nxosInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QRegExp vlan_name_pattern("([a-zA-Z-]+\\d{1,}/\\d{1,})\\.(\\d{1,})");
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern("([a-zA-Z-]+\\d{1,}/\\d{1,})\\.(\\d{1,})");
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_pattern.cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(2).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(2).toInt();
return true;
}
return false;

View File

@ -25,18 +25,19 @@
#include "fwbuilder/Interface.h"
#include <QRegExp>
#include <QRegularExpression>
using namespace libfwbuilder;
bool openbsdInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QRegExp vlan_name_pattern(QRegExp("(vlan)(\\d{1,})"));
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern(QRegularExpression("(vlan)(\\d{1,})"));
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_pattern.cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(2).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(2).toInt();
return true;
}
return false;

View File

@ -25,7 +25,7 @@
#include "pixInterfaces.h"
#include <QRegExp>
#include <QRegularExpression>
/*
* http://www.cisco.com/en/US/docs/security/asa/asa70/command/reference/gl.html#wp1644971
@ -41,11 +41,12 @@
bool pixInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QRegExp vlan_name_pattern("([a-zA-Z-]+\\d{1,}(/\\d{1,})*)\\.(\\d{1,})");
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern("([a-zA-Z-]+\\d{1,}(/\\d{1,})*)\\.(\\d{1,})");
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_pattern.cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(3).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(3).toInt();
return true;
}
return false;

View File

@ -27,7 +27,7 @@
#include "fwbuilder/Interface.h"
#include <QRegExp>
#include <QRegularExpression>
#include <QObject>
using namespace std;
@ -66,11 +66,12 @@ bool procurveInterfaces::parseVlan(
}
// Procurve SNMP reports vlan interface names without space
QRegExp vlan_name_pattern("(vlan|Vlan|VLAN) *(\\d{1,})");
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern("(vlan|Vlan|VLAN) *(\\d{1,})");
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_pattern.cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(2).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(2).toInt();
return true;
}
return false;

View File

@ -35,7 +35,6 @@
#include <QtWidgets/QApplication>
#include <QTimer>
#include <QPixmapCache>
#include <QTextCodec>
#include <QLocale>
#include <QDir>
#include <QTranslator>
@ -246,17 +245,21 @@ int main( int argc, char *argv[] )
QString local = QLocale::system().name();//"en_US";//
QTranslator translator(0);
translator.load(QLatin1String("fwbuilder_") +
QString(local), Constants::getLocaleDirectory().c_str());
Q_UNUSED(translator.load(QLatin1String("fwbuilder_") +
QString(local), Constants::getLocaleDirectory().c_str()));
app->installTranslator (&translator);
QString qt_resource_dir =
QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#else
QLibraryInfo::path(QLibraryInfo::TranslationsPath);
#endif
QTranslator qt_translator(0);
qt_translator.load(QLatin1String("qt_") + QLocale::system().name(),
qt_resource_dir);
Q_UNUSED(qt_translator.load(QLatin1String("qt_") + QLocale::system().name(),
qt_resource_dir));
app->installTranslator (&qt_translator);
mw = new FWWindow();

View File

@ -28,7 +28,7 @@
#include <QString>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
#include <QtDebug>
#include <ios>
@ -83,8 +83,9 @@ void IPTImporter::run()
string normalized_input_buffer;
normalized_input_buffer.reserve(input_size);
QRegExp old_negation_short("(-[^- ])\\s!");
QRegExp old_negation_long("(--[^- ]+)\\s!");
QRegularExpression old_negation_short("(-[^- ])\\s!");
QRegularExpression old_negation_long("(--[^- ]+)\\s!");
QRegularExpressionMatch match;
input.seekg (0, ios::beg);
char buf[8192];
@ -103,25 +104,25 @@ void IPTImporter::run()
// negation: "-s ! something" format is deprecated and is replaced with
// "! -s something", but our parser understands only old format.
int pos = 0;
qsizetype pos = 0;
while (true)
{
QString option;
int match_length = 0;
int old_pos = 0;
qsizetype match_length = 0;
qsizetype old_pos = 0;
old_pos = old_negation_short.indexIn(str, pos);
old_pos = str.indexOf(old_negation_short, pos, &match);
if (old_pos != -1)
{
option = old_negation_short.cap(1);
match_length = old_negation_short.matchedLength();
option = match.captured(1);
match_length = match.capturedLength();
} else
{
old_pos = old_negation_long.indexIn(str, pos);
old_pos = str.indexOf(old_negation_long, pos, &match);
if (old_pos != -1)
{
option = old_negation_long.cap(1);
match_length = old_negation_long.matchedLength();
option = match.captured(1);
match_length = match.capturedLength();
}
}

View File

@ -58,7 +58,7 @@
#include <QString>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
#include <QtDebug>
@ -358,9 +358,10 @@ void Importer::setInterfaceParametes(const std::string &phys_intf_or_label,
// "nameif ethernet0 outside security0"
Interface *intf = all_interfaces[phys_intf_or_label];
intf->setLabel(label);
QRegExp pix6_sec_level("security(\\d+)");
if (pix6_sec_level.indexIn(sec_level.c_str()) > -1)
intf->setSecurityLevel(pix6_sec_level.cap(1).toInt());
QRegularExpression pix6_sec_level("security(\\d+)");
QRegularExpressionMatch match;
if (QString::fromStdString(sec_level).indexOf(pix6_sec_level, 0, &match) > -1)
intf->setSecurityLevel(match.captured(1).toInt());
} else
{
// since first arg is not physical interface name, it must be a label

View File

@ -28,7 +28,7 @@
#include <QString>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
#include <QtDebug>
#include <ios>
@ -78,12 +78,13 @@ void PFImporter::run()
}
QString whole_input = whole_input_tmp.join("\n") + "\n";
QRegExp line_continuation("\\\\\\s*\n");
QRegularExpression line_continuation("\\\\\\s*\n");
whole_input.replace(line_continuation, "");
QRegExp inline_comment("#.*$");
QRegExp macro_definition("^\\s*(\\S+)\\s*=\\s*(.*)$");
QRegExp list_of_items("^\\{\\s*((\\S+,?\\s*)+)\\s*\\}$");
QRegularExpression inline_comment("#.*$");
QRegularExpression macro_definition("^\\s*(\\S+)\\s*=\\s*(.*)$");
QRegularExpression list_of_items("^\\{\\s*((\\S+,?\\s*)+)\\s*\\}$");
QRegularExpressionMatch match;
QMap<QString, QString> macros;
QMap<QString, QString> macros_source_lines;
@ -94,15 +95,15 @@ void PFImporter::run()
work_str.replace(inline_comment, "");
work_str = work_str.trimmed();
if (macro_definition.indexIn(work_str) != -1)
if (work_str.indexOf(macro_definition, 0, &match) != -1)
{
QString macro_name = macro_definition.cap(1);
QString value = macro_definition.cap(2);
QString macro_name = match.captured(1);
QString value = match.captured(2);
value.replace('\"', "");
value = value.simplified();
macros[macro_name] = value;
macros_source_lines[macro_name] = macro_definition.cap(0);
macros_source_lines[macro_name] = match.captured(0);
}
}
@ -134,7 +135,7 @@ void PFImporter::run()
* RegExp list_of_items assumes the string has been
* stripped of any quotes and trimmed.
*/
if (list_of_items.indexIn(value) != -1)
if (value.indexOf(list_of_items, 0, &match) != -1)
{
qDebug() << "This macro defines a list";
@ -146,13 +147,9 @@ void PFImporter::run()
* because pf does not allow mixed address/service
* lists anywhere.
*/
QString list_str = list_of_items.cap(1);
QString list_str = match.captured(1);
list_str.replace(",", "");
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QStringList items = list_str.split(QRegExp("\\s"), Qt::SkipEmptyParts);
#else
QStringList items = list_str.split(QRegExp("\\s"), QString::SkipEmptyParts);
#endif
QStringList items = list_str.split(QRegularExpression("\\s"), Qt::SkipEmptyParts);
qDebug() << items;
bool has_address = false;
@ -261,7 +258,8 @@ void PFImporter::substituteMacros(const QMap<QString,QString> &macros,
QString &buffer)
{
// make several passes: sometimes macros can use other macros
QRegExp any_macro_instance("\\$(\\w+)\\W");
QRegularExpression any_macro_instance("\\$(\\w+)\\W");
QRegularExpressionMatch match;
QSet<QString> undefined_macros;
for (;;)
{
@ -271,16 +269,16 @@ void PFImporter::substituteMacros(const QMap<QString,QString> &macros,
it.next();
QString macro_name = it.key();
QString macro_value = it.value();
QRegExp macro_instance(QString("\\$%1(?=\\W)").arg(macro_name));
QRegularExpression macro_instance(QString("\\$%1(?=\\W)").arg(macro_name));
buffer.replace(macro_instance, macro_value);
}
bool has_known_macros = false;
int idx = 0;
while ((idx = buffer.indexOf(any_macro_instance, idx)) != -1)
qsizetype idx = 0;
while ((idx = buffer.indexOf(any_macro_instance, idx, &match)) != -1)
{
QString macro_name = any_macro_instance.cap(1);
QString macro_name = match.captured(1);
if (macros.contains(macro_name)) has_known_macros = true;
else undefined_macros.insert(macro_name);
idx++;

View File

@ -28,7 +28,7 @@
#include <QString>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
#include <QtDebug>
#include <ios>
@ -96,7 +96,7 @@ void PIXImporter::run()
for (it=named_addresses.begin(); it!=named_addresses.end(); ++it)
{
QString re("\\b%1\\b");
str.replace(QRegExp(re.arg(it.key())), it.value());
str.replace(QRegularExpression(re.arg(it.key())), it.value());
}
}

View File

@ -23,7 +23,7 @@
#include "PreImport.h"
#include <QRegExp>
#include <QRegularExpression>
#include <functional>
@ -60,90 +60,90 @@ public:
void PreImport::scan()
{
QList<QRegExp> pix_re;
pix_re << QRegExp("^ASA Version")
<< QRegExp("^PIX Version")
<< QRegExp("^FWSM Version")
<< QRegExp("^nat \\(\\S+,\\S+\\)")
<< QRegExp("^static \\(\\S+,\\S+\\)")
<< QRegExp("^global \\(")
<< QRegExp("^nameif \\S+")
<< QRegExp("^fixup \\S+");
QList<QRegularExpression> pix_re;
pix_re << QRegularExpression("^ASA Version")
<< QRegularExpression("^PIX Version")
<< QRegularExpression("^FWSM Version")
<< QRegularExpression("^nat \\(\\S+,\\S+\\)")
<< QRegularExpression("^static \\(\\S+,\\S+\\)")
<< QRegularExpression("^global \\(")
<< QRegularExpression("^nameif \\S+")
<< QRegularExpression("^fixup \\S+");
QList<QRegExp> fwsm_re;
fwsm_re << QRegExp("^FWSM Version");
QList<QRegularExpression> fwsm_re;
fwsm_re << QRegularExpression("^FWSM Version");
QList<QRegExp> ios_re;
ios_re << QRegExp("IOS Version")
<< QRegExp("^[vV]ersion 1[012]\\..*");
QList<QRegularExpression> ios_re;
ios_re << QRegularExpression("IOS Version")
<< QRegularExpression("^[vV]ersion 1[012]\\..*");
QList<QRegExp> iptables_re;
iptables_re << QRegExp("# Generated by iptables-save")
<< QRegExp("^:INPUT ")
<< QRegExp("^:OUTPUT ")
<< QRegExp("^:FORWARD ")
<< QRegExp("^-A INPUT ")
<< QRegExp("^-A OUTPUT ")
<< QRegExp("^-A FORWARD ");
QList<QRegularExpression> iptables_re;
iptables_re << QRegularExpression("# Generated by iptables-save")
<< QRegularExpression("^:INPUT ")
<< QRegularExpression("^:OUTPUT ")
<< QRegularExpression("^:FORWARD ")
<< QRegularExpression("^-A INPUT ")
<< QRegularExpression("^-A OUTPUT ")
<< QRegularExpression("^-A FORWARD ");
QList<QRegExp> iptables_with_counters_re;
iptables_with_counters_re << QRegExp("^\\[\\d+:\\d+\\] -A INPUT ")
<< QRegExp("^\\[\\d+:\\d+\\] -A OUTPUT ")
<< QRegExp("^\\[\\d+:\\d+\\] -A FORWARD ");
QList<QRegularExpression> iptables_with_counters_re;
iptables_with_counters_re << QRegularExpression("^\\[\\d+:\\d+\\] -A INPUT ")
<< QRegularExpression("^\\[\\d+:\\d+\\] -A OUTPUT ")
<< QRegularExpression("^\\[\\d+:\\d+\\] -A FORWARD ");
QList<QRegExp> pf_conf_re;
pf_conf_re << QRegExp("^scrub\\s+\\S+")
<< QRegExp("^set\\s+timeout\\s+\\S+")
<< QRegExp("^pass\\s+")
<< QRegExp("^block\\s+")
<< QRegExp("^nat\\s+(?!\\()")
<< QRegExp("^rdr\\s+(?!\\()")
<< QRegExp("^table\\s+<\\S+>\\s+");
QList<QRegularExpression> pf_conf_re;
pf_conf_re << QRegularExpression("^scrub\\s+\\S+")
<< QRegularExpression("^set\\s+timeout\\s+\\S+")
<< QRegularExpression("^pass\\s+")
<< QRegularExpression("^block\\s+")
<< QRegularExpression("^nat\\s+(?!\\()")
<< QRegularExpression("^rdr\\s+(?!\\()")
<< QRegularExpression("^table\\s+<\\S+>\\s+");
foreach (QString line, *buffer)
{
if (platform == UNKNOWN)
{
foreach (QRegExp re, pix_re)
foreach (QRegularExpression re, pix_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = PIX;
break;
}
}
foreach (QRegExp re, fwsm_re)
foreach (QRegularExpression re, fwsm_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = FWSM;
break;
}
}
foreach (QRegExp re, ios_re)
foreach (QRegularExpression re, ios_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = IOSACL;
break;
}
}
foreach (QRegExp re, iptables_re)
foreach (QRegularExpression re, iptables_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = IPTABLES;
break;
}
}
foreach (QRegExp re, pf_conf_re)
foreach (QRegularExpression re, pf_conf_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = PF;
break;
@ -153,9 +153,9 @@ void PreImport::scan()
if (platform == IPTABLES)
{
foreach (QRegExp re, iptables_with_counters_re)
foreach (QRegularExpression re, iptables_with_counters_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = IPTABLES_WITH_COUNTERS;
break;
@ -208,15 +208,15 @@ bool PreImport::isReversePFConfigurationStyle(matchPFDirection &dir_op)
bool has_block_no_quick = false;
bool has_command_with_quick_after_block = false;
bool has_command_with_no_quick_after_block = false;
QRegExp cont("\\\\\\s*\n");
QRegularExpression cont("\\\\\\s*\n");
QString line;
QStringListIterator it(*buffer);
while (it.hasNext())
{
// first, unfold lines ending with "\"
line = it.next();
int cont_idx;
while ( (cont_idx = cont.indexIn(line)) > -1 && it.hasNext())
qsizetype cont_idx = 0;
while ( (cont_idx = line.indexOf(cont, cont_idx)) > -1 && it.hasNext())
{
line.insert(cont_idx, it.next());
}

View File

@ -57,7 +57,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -91,9 +93,10 @@ int main(int argc, char **argv)
{
QCoreApplication app(argc, argv, false);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// compilers always write file names into manifest in Utf8
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();
if (args.size()<=1)

View File

@ -64,7 +64,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -101,7 +103,9 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -62,7 +62,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -97,7 +99,9 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -42,7 +42,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include <QTime>
#include <QElapsedTimer>
@ -83,7 +85,9 @@ int main(int argc, char **argv)
total_time_timer.start();
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -56,7 +56,6 @@
#include <QString>
#include <QRegExp>
#include <QtDebug>
#include <algorithm>

View File

@ -59,7 +59,7 @@
#include <QString>
#include <QtDebug>
#include <QRegExp>
#include <QRegularExpression>
#include <QStringList>
@ -284,7 +284,7 @@ void OSConfigurator_linux24::addVirtualAddressForNAT(const Address *addr)
string OSConfigurator_linux24::normalizeSetName(const string &txt)
{
QString table_name = txt.c_str();
table_name.replace(QRegExp("[ +*!#|]"), "_");
table_name.replace(QRegularExpression("[ +*!#|]"), "_");
return table_name.toStdString();
}
@ -479,15 +479,12 @@ QString OSConfigurator_linux24::addressTableWrapper(FWObject *rule,
bool ipv6)
{
QString combined_command = command;
QRegExp address_table_re("\\$at_(\\S+)");
int pos = address_table_re.indexIn(command);
if (pos > -1)
QRegularExpression address_table_re("\\$at_(\\S+)");
QRegularExpressionMatch match;
if (command.indexOf(address_table_re, 0, &match) > -1)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QStringList command_lines = QString(command).split("\n", Qt::SkipEmptyParts);
#else
QStringList command_lines = QString(command).split("\n", QString::SkipEmptyParts);
#endif
if (command_lines.size() > 1)
{
command_lines.push_front("{");
@ -500,7 +497,7 @@ QString OSConfigurator_linux24::addressTableWrapper(FWObject *rule,
command_wrappers->collapseEmptyStrings(true);
command_wrappers->setVariable("ipv6", ipv6);
QString at_var = address_table_re.cap(1);
QString at_var = match.captured(1);
QString at_file = rule->getStr("address_table_file").c_str();
command_wrappers->setVariable("address_table_file", at_file);
@ -545,15 +542,16 @@ string OSConfigurator_linux24::printRunTimeWrappers(FWObject *rule,
command_wrappers->setVariable("address_table", false);
QRegExp intf_re("\\$i_([^ :]+)");
QRegularExpression intf_re("\\$i_([^ :]+)");
QRegularExpressionMatch match;
QStringList iface_names;
QStringList iface_vars;
int pos = -1;
while ((pos = intf_re.indexIn(combined_command, pos + 1)) > -1)
qsizetype pos = -1;
while ((pos = combined_command.indexOf(intf_re, pos + 1, &match)) > -1)
{
QString name = intf_re.cap(1);
int match_len = intf_re.matchedLength();
QString name = match.captured(1);
int match_len = match.capturedLength();
iface_names.push_back(name);
iface_vars.push_back("$i_" + name);
if (name.contains("*"))
@ -574,11 +572,7 @@ string OSConfigurator_linux24::printRunTimeWrappers(FWObject *rule,
if (!no_wrapper)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QStringList command_lines = QString(combined_command).split("\n", Qt::SkipEmptyParts);
#else
QStringList command_lines = QString(combined_command).split("\n", QString::SkipEmptyParts);
#endif
if (command_lines.size() > 1)
{
command_lines.push_front("{");

View File

@ -30,9 +30,8 @@
#include "fwcompiler/OSConfigurator.h"
#include "OSData_ipt.h"
class QString;
class QStringList;
#include <QStringList>
namespace libfwbuilder {
class FWObject;

View File

@ -63,7 +63,7 @@
#include <QString>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
#include <QtDebug>
@ -654,10 +654,10 @@ bool OSConfigurator_linux24::validateInterfaces()
iface->getOptionsObject()->getStr("type") == "bonding")
{
QString subint_name = subinterface->getName().c_str();
QRegExp vlan1("[a-zA-Z-]+\\d{1,}\\.\\d{1,}");
QRegExp vlan2("vlan\\d{1,}");
if (vlan1.indexIn(subint_name) != -1 ||
vlan1.indexIn(subint_name) != -1)
QRegularExpression vlan1("[a-zA-Z-]+\\d{1,}\\.\\d{1,}");
QRegularExpression vlan2("vlan\\d{1,}");
// Note: this checked for vlan1 twice. Must have been a typo.
if (subint_name.indexOf(vlan1) != -1 || subint_name.indexOf(vlan2) != -1)
{
QString err(
"Vlan subinterfaces as slaves of bonding interfaces "

View File

@ -57,7 +57,6 @@
#include "Configlet.h"
#include <QStringList>
#include <QRegExp>
#include <QtDebug>
#include <iostream>

View File

@ -69,8 +69,6 @@
#include <climits>
#include <QString>
#include <QRegExp>
using namespace libfwbuilder;
using namespace fwcompiler;

View File

@ -21,6 +21,8 @@
*/
#include <list>
#include "ipt_utils.h"
#include "fwbuilder/FWObjectDatabase.h"
@ -35,7 +37,7 @@
#include "combinedAddress.h"
#include <QRegExp>
#include <QRegularExpression>
using namespace libfwbuilder;
@ -86,7 +88,7 @@ void build_interface_groups(
*/
QString iname = QString(iface->getName().c_str());
iname.replace(QRegExp("[0-9]{1,}$"), "+");
iname.replace(QRegularExpression("[0-9]{1,}$"), "+");
iname.replace("*", "+");
if (regular_interfaces.count(iname) == 0)

View File

@ -57,7 +57,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -92,7 +94,9 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -55,7 +55,7 @@
#include <qapplication.h>
#include <QStackedWidget>
#include <qcursor.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <QtDebug>
#include <iostream>
@ -119,9 +119,7 @@ void ActionsDialog::validate(bool *res)
{
*res=false;
QMessageBox::critical(this, "Firewall Builder",
tr("'Change inbound interface', 'Continue packet inspection' and 'Make a copy' options are mutually exclusive"),
tr("&Continue"), 0, 0,
0 );
tr("'Change inbound interface', 'Continue packet inspection' and 'Make a copy' options are mutually exclusive"));
}
}
}
@ -140,13 +138,11 @@ void ActionsDialog::applyChanges()
/* rule name for accounting may contain only alphanumeric characters
* and no white spaces or spec. characters
*/
if (rn.contains(QRegExp("[^a-zA-Z0-9_]"))!=0)
if (rn.contains(QRegularExpression("[^a-zA-Z0-9_]"))!=0)
{
QMessageBox::information(
this,"Firewall Builder",
tr("Rule name for accounting is converted to the iptables\nchain name and therefore may not contain white space\nand special characters."),
tr("&Continue"), QString(),QString(),
0, 1 );
tr("Rule name for accounting is converted to the iptables\nchain name and therefore may not contain white space\nand special characters."));
return;
}

View File

@ -128,8 +128,7 @@ void AddressRangeDialog::validate(bool *res)
QMessageBox::critical(
this, "Firewall Builder",
QString::fromUtf8(ex.toString().c_str()),
tr("&Continue"), nullptr, nullptr,
0 );
QMessageBox::Ok);
blockSignals(false);
}
}

View File

@ -41,7 +41,7 @@ BackgroundCompileInfoWidget::BackgroundCompileInfoWidget(QWidget *parent, instDi
m_progressBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
QHBoxLayout *hboxlayout = new QHBoxLayout();
hboxlayout->setSpacing(0);
hboxlayout->setMargin(0);
hboxlayout->setContentsMargins(0, 0, 0, 0);
hboxlayout->addWidget(m_label);
hboxlayout->addWidget(m_progressBar);
setLayout(hboxlayout);

View File

@ -568,7 +568,7 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
IF (UseQt6)
qt_wrap_cpp(libgui_hdrs_moc ${libgui_hdrs})