1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-05-02 07:07:32 +02:00

feat: Apply modernize-use-nullptr

This commit is contained in:
Sirius Bakke 2018-09-12 20:21:26 +02:00
parent defc5c7b63
commit 7824066a96
197 changed files with 1659 additions and 1659 deletions

View File

@ -71,7 +71,7 @@ void ASTFactory::registerFactory( int type, const char* ast_name, factory_type f
// check validity of arguments... // check validity of arguments...
if( type < Token::MIN_USER_TYPE ) if( type < Token::MIN_USER_TYPE )
throw ANTLRException("Internal parser error invalid type passed to RegisterFactory"); throw ANTLRException("Internal parser error invalid type passed to RegisterFactory");
if( factory == 0 ) if( factory == nullptr )
throw ANTLRException("Internal parser error 0 factory passed to RegisterFactory"); throw ANTLRException("Internal parser error 0 factory passed to RegisterFactory");
// resize up to and including 'type' and initalize any gaps to default // resize up to and including 'type' and initalize any gaps to default
@ -243,12 +243,12 @@ RefAST ASTFactory::make(ANTLR_USE_NAMESPACE(std)vector<RefAST>& nodes)
// link in children; // link in children;
for( unsigned int i = 1; i < nodes.size(); i++ ) for( unsigned int i = 1; i < nodes.size(); i++ )
{ {
if ( nodes[i] == 0 ) // ignore null nodes if ( nodes[i] == nullptr ) // ignore null nodes
continue; continue;
if ( root == 0 ) // Set the root and set it up for a flat list if ( root == nullptr ) // Set the root and set it up for a flat list
root = tail = nodes[i]; root = tail = nodes[i];
else if ( tail == 0 ) else if ( tail == nullptr )
{ {
root->setFirstChild(nodes[i]); root->setFirstChild(nodes[i]);
tail = root->getFirstChild(); tail = root->getFirstChild();

View File

@ -32,7 +32,7 @@ ASTRef* ASTRef::getRef(const AST* p)
else else
return new ASTRef(pp); return new ASTRef(pp);
} else } else
return 0; return nullptr;
} }
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE

View File

@ -273,7 +273,7 @@ ANTLR_API RefAST nullAST;
#if defined(_MSC_VER) && !defined(__ICL) // Microsoft Visual C++ #if defined(_MSC_VER) && !defined(__ICL) // Microsoft Visual C++
extern ANTLR_API AST* const nullASTptr = 0; extern ANTLR_API AST* const nullASTptr = 0;
#else #else
ANTLR_API AST* const nullASTptr = 0; ANTLR_API AST* const nullASTptr = nullptr;
#endif #endif
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE

View File

@ -83,7 +83,7 @@ void LLkParser::traceOut(const char* rname)
RefToken LLkParser::LT(unsigned int i) RefToken LLkParser::LT(unsigned int i)
{ {
//assert(this!=NULL); //clang error: 'this' pointer cannot be null in well-defined C++ code; //assert(this!=NULL); //clang error: 'this' pointer cannot be null in well-defined C++ code;
assert(inputState!=NULL); assert(inputState!=nullptr);
TokenBuffer &tb = inputState->getInput(); TokenBuffer &tb = inputState->getInput();
//assert(&tb!=NULL); //clang error: reference cannot be bound to dereferenced null pointer in well-defined C++ code; //assert(&tb!=NULL); //clang error: reference cannot be bound to dereferenced null pointer in well-defined C++ code;
return tb.LT(i); return tb.LT(i);

View File

@ -14,9 +14,9 @@ namespace antlr {
MismatchedTokenException::MismatchedTokenException() MismatchedTokenException::MismatchedTokenException()
: RecognitionException("Mismatched Token: expecting any AST node","<AST>",-1,-1) : RecognitionException("Mismatched Token: expecting any AST node","<AST>",-1,-1)
, token(0) , token(nullptr)
, node(nullASTptr) , node(nullASTptr)
, tokenNames(0) , tokenNames(nullptr)
, numTokens(0) , numTokens(0)
{ {
} }
@ -30,7 +30,7 @@ MismatchedTokenException::MismatchedTokenException(
int upper_, int upper_,
bool matchNot bool matchNot
) : RecognitionException("Mismatched Token","<AST>",-1,-1) ) : RecognitionException("Mismatched Token","<AST>",-1,-1)
, token(0) , token(nullptr)
, node(node_) , node(node_)
, tokenText( (node_ ? node_->toString(): ANTLR_USE_NAMESPACE(std)string("<empty tree>")) ) , tokenText( (node_ ? node_->toString(): ANTLR_USE_NAMESPACE(std)string("<empty tree>")) )
, mismatchType(matchNot ? NOT_RANGE : RANGE) , mismatchType(matchNot ? NOT_RANGE : RANGE)
@ -49,7 +49,7 @@ MismatchedTokenException::MismatchedTokenException(
int expecting_, int expecting_,
bool matchNot bool matchNot
) : RecognitionException("Mismatched Token","<AST>",-1,-1) ) : RecognitionException("Mismatched Token","<AST>",-1,-1)
, token(0) , token(nullptr)
, node(node_) , node(node_)
, tokenText( (node_ ? node_->toString(): ANTLR_USE_NAMESPACE(std)string("<empty tree>")) ) , tokenText( (node_ ? node_->toString(): ANTLR_USE_NAMESPACE(std)string("<empty tree>")) )
, mismatchType(matchNot ? NOT_TOKEN : TOKEN) , mismatchType(matchNot ? NOT_TOKEN : TOKEN)
@ -67,7 +67,7 @@ MismatchedTokenException::MismatchedTokenException(
BitSet set_, BitSet set_,
bool matchNot bool matchNot
) : RecognitionException("Mismatched Token","<AST>",-1,-1) ) : RecognitionException("Mismatched Token","<AST>",-1,-1)
, token(0) , token(nullptr)
, node(node_) , node(node_)
, tokenText( (node_ ? node_->toString(): ANTLR_USE_NAMESPACE(std)string("<empty tree>")) ) , tokenText( (node_ ? node_->toString(): ANTLR_USE_NAMESPACE(std)string("<empty tree>")) )
, mismatchType(matchNot ? NOT_SET : SET) , mismatchType(matchNot ? NOT_SET : SET)

View File

@ -16,7 +16,7 @@ ANTLR_USING_NAMESPACE(std)
NoViableAltException::NoViableAltException(RefAST t) NoViableAltException::NoViableAltException(RefAST t)
: RecognitionException("NoViableAlt","<AST>",-1,-1), : RecognitionException("NoViableAlt","<AST>",-1,-1),
token(0), node(t) token(nullptr), node(t)
{ {
} }

View File

@ -32,7 +32,7 @@ TokenRef* TokenRef::getRef(const Token* p)
else else
return new TokenRef(pp); return new TokenRef(pp);
} else } else
return 0; return nullptr;
} }
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE

View File

@ -20,7 +20,7 @@ namespace antlr {
*/ */
TokenStreamSelector::TokenStreamSelector() TokenStreamSelector::TokenStreamSelector()
: input(0) : input(nullptr)
{ {
} }

View File

@ -54,7 +54,7 @@ using namespace std;
static unsigned long calculateDimension(FWObject* obj) static unsigned long calculateDimension(FWObject* obj)
{ {
if (Group::cast(obj)!=NULL) if (Group::cast(obj)!=nullptr)
{ {
unsigned long res=0; unsigned long res=0;
for (FWObject::iterator i1=obj->begin(); i1!=obj->end(); ++i1) for (FWObject::iterator i1=obj->begin(); i1!=obj->end(); ++i1)
@ -68,7 +68,7 @@ static unsigned long calculateDimension(FWObject* obj)
} else } else
{ {
Address *a=Address::cast(obj); Address *a=Address::cast(obj);
if (a!=NULL) if (a!=nullptr)
{ {
if (a->isAny()) return LONG_MAX; if (a->isAny()) return LONG_MAX;
return a->dimension(); return a->dimension();
@ -79,12 +79,12 @@ static unsigned long calculateDimension(FWObject* obj)
void Helper::expand_group_recursive(FWObject *o,list<FWObject*> &ol) void Helper::expand_group_recursive(FWObject *o,list<FWObject*> &ol)
{ {
if (Group::cast( o )!=NULL) if (Group::cast( o )!=nullptr)
{ {
for (FWObject::iterator i2=o->begin(); i2!=o->end(); ++i2) for (FWObject::iterator i2=o->begin(); i2!=o->end(); ++i2)
{ {
FWObject *o1= *i2; FWObject *o1= *i2;
if (FWReference::cast(o1)!=NULL) o1=FWReference::cast(o1)->getPointer(); if (FWReference::cast(o1)!=nullptr) o1=FWReference::cast(o1)->getPointer();
assert(o1); assert(o1);
expand_group_recursive(o1,ol); expand_group_recursive(o1,ol);
@ -112,7 +112,7 @@ int Helper::findInterfaceByAddress(Address *obj)
int Helper::findInterfaceByAddress(const InetAddr *addr, int Helper::findInterfaceByAddress(const InetAddr *addr,
const InetAddr *nm) const InetAddr *nm)
{ {
if (addr==NULL) return -1; if (addr==nullptr) return -1;
#if DEBUG_NETZONE_OPS #if DEBUG_NETZONE_OPS
cerr << "Helper::findInterfaceByAddress"; cerr << "Helper::findInterfaceByAddress";
@ -150,7 +150,7 @@ int Helper::findInterfaceByAddress(const InetAddr *addr,
cerr << endl; cerr << endl;
#endif #endif
if (nm != NULL) if (nm != nullptr)
{ {
InetAddrMask interface_subnet(*(i_addr->getAddressPtr()), InetAddrMask interface_subnet(*(i_addr->getAddressPtr()),
*(i_addr->getNetmaskPtr())); *(i_addr->getNetmaskPtr()));
@ -254,7 +254,7 @@ int Helper::findInterfaceByNetzone(const InetAddr *addr, const InetAddr *nm)
{ {
Address *netzone_addr = Address::cast(*j); Address *netzone_addr = Address::cast(*j);
if (netzone_addr == NULL) continue; if (netzone_addr == nullptr) continue;
#if DEBUG_NETZONE_OPS #if DEBUG_NETZONE_OPS
cerr << "Helper::findInterfaceByNetzone"; cerr << "Helper::findInterfaceByNetzone";
@ -265,7 +265,7 @@ int Helper::findInterfaceByNetzone(const InetAddr *addr, const InetAddr *nm)
// if addr==NULL, return id of the interfacce that has // if addr==NULL, return id of the interfacce that has
// net_zone=="any" // net_zone=="any"
if (addr==NULL) if (addr==nullptr)
{ {
if (netzone_addr->getId()==FWObjectDatabase::ANY_ADDRESS_ID) if (netzone_addr->getId()==FWObjectDatabase::ANY_ADDRESS_ID)
return iface->getId(); // id of the interface return iface->getId(); // id of the interface
@ -278,7 +278,7 @@ int Helper::findInterfaceByNetzone(const InetAddr *addr, const InetAddr *nm)
const InetAddr *nz_addr = netzone_addr->getAddressPtr(); const InetAddr *nz_addr = netzone_addr->getAddressPtr();
const InetAddr *nz_netm = netzone_addr->getNetmaskPtr(); const InetAddr *nz_netm = netzone_addr->getNetmaskPtr();
if (nm != NULL && nz_netm != NULL) if (nm != nullptr && nz_netm != nullptr)
{ {
InetAddrMask nz_subnet(*nz_addr, *nz_netm); InetAddrMask nz_subnet(*nz_addr, *nz_netm);
InetAddrMask other_subnet(*addr, *nm); InetAddrMask other_subnet(*addr, *nm);
@ -408,9 +408,9 @@ list<int> Helper::findInterfaceByNetzoneOrAll(RuleElement *re)
} else } else
{ {
FWObject *fo = re->front(); FWObject *fo = re->front();
if (FWReference::cast(fo)!=NULL) fo=FWReference::cast(fo)->getPointer(); if (FWReference::cast(fo)!=nullptr) fo=FWReference::cast(fo)->getPointer();
Address *a = Address::cast(fo); Address *a = Address::cast(fo);
if (a==NULL) if (a==nullptr)
{ {
Rule *rule = Rule::cast(re->getParent()); Rule *rule = Rule::cast(re->getParent());
Q_UNUSED(rule); Q_UNUSED(rule);

View File

@ -206,7 +206,7 @@ const char* rw[] = {
"icmp-traceroute", "icmp-traceroute",
"icmp-conversion-error", "icmp-conversion-error",
"icmp-mobile-redirect", "icmp-mobile-redirect",
NULL nullptr
}; };
QSet<QString> NamedObject::reserved_words; QSet<QString> NamedObject::reserved_words;
@ -220,7 +220,7 @@ NamedObject::NamedObject(const FWObject *_obj, const QString &_platform)
if (reserved_words.empty()) if (reserved_words.empty())
{ {
const char** cptr = rw; const char** cptr = rw;
while (*cptr!=NULL) while (*cptr!=nullptr)
{ {
reserved_words.insert(QString(*cptr)); reserved_words.insert(QString(*cptr));
cptr++; cptr++;
@ -231,10 +231,10 @@ NamedObject::NamedObject(const FWObject *_obj, const QString &_platform)
QString NamedObject::getCommandWord() QString NamedObject::getCommandWord()
{ {
if (Address::constcast(obj)!=NULL && Address::constcast(obj)->isAny()) if (Address::constcast(obj)!=nullptr && Address::constcast(obj)->isAny())
return "any"; return "any";
if (Service::constcast(obj)!=NULL && Service::constcast(obj)->isAny()) if (Service::constcast(obj)!=nullptr && Service::constcast(obj)->isAny())
return "any"; return "any";
if (Interface::constcast(obj)) if (Interface::constcast(obj))
@ -262,7 +262,7 @@ QString NamedObject::sanitizeObjectName(const QString &name)
QString NamedObject::createNetworkObjectCommand(const Address *addr_obj) QString NamedObject::createNetworkObjectCommand(const Address *addr_obj)
{ {
if (addr_obj == NULL) return ""; if (addr_obj == nullptr) return "";
if (addr_obj->isAny()) return ""; if (addr_obj->isAny()) return "";
if (Interface::constcast(obj)) return ""; if (Interface::constcast(obj)) return "";
@ -323,7 +323,7 @@ QString NamedObject::printPorts(int rs, int re)
QString NamedObject::createServiceObjectCommand(const Service *serv_obj) QString NamedObject::createServiceObjectCommand(const Service *serv_obj)
{ {
if (serv_obj == NULL) return ""; if (serv_obj == nullptr) return "";
if (serv_obj->isAny()) return ""; if (serv_obj->isAny()) return "";
QStringList res; QStringList res;
@ -377,10 +377,10 @@ QString NamedObject::createServiceObjectCommand(const Service *serv_obj)
QString NamedObject::getCommand() QString NamedObject::getCommand()
{ {
if (Address::constcast(obj)!=NULL) if (Address::constcast(obj)!=nullptr)
return createNetworkObjectCommand(Address::constcast(obj)); return createNetworkObjectCommand(Address::constcast(obj));
if (Service::constcast(obj)!=NULL) if (Service::constcast(obj)!=nullptr)
return createServiceObjectCommand(Service::constcast(obj)); return createServiceObjectCommand(Service::constcast(obj));
return ""; return "";
@ -388,8 +388,8 @@ QString NamedObject::getCommand()
QString NamedObject::getCommandWhenObjectGroupMember() QString NamedObject::getCommandWhenObjectGroupMember()
{ {
if (Address::constcast(obj)!=NULL) return "network-object object " + name; if (Address::constcast(obj)!=nullptr) return "network-object object " + name;
if (Service::constcast(obj)!=NULL) return "service-object object " + name; if (Service::constcast(obj)!=nullptr) return "service-object object " + name;
return ""; return "";
} }

View File

@ -51,10 +51,10 @@ QString PIXObjectGroup::groupMemberToString(FWObject *obj,
if (this->getObjectGroupType() == NETWORK) if (this->getObjectGroupType() == NETWORK)
{ {
Address *a = Address::cast(obj); Address *a = Address::cast(obj);
assert(a!=NULL); assert(a!=nullptr);
const InetAddr *addr = a->getAddressPtr(); const InetAddr *addr = a->getAddressPtr();
ostr << "network-object "; ostr << "network-object ";
if (Network::cast(obj)!=NULL) if (Network::cast(obj)!=nullptr)
{ {
const InetAddr *mask = a->getNetmaskPtr(); const InetAddr *mask = a->getNetmaskPtr();
ostr << addr->toString() << " "; ostr << addr->toString() << " ";
@ -72,7 +72,7 @@ QString PIXObjectGroup::groupMemberToString(FWObject *obj,
{ {
ostr << "protocol-object "; ostr << "protocol-object ";
Service *s=Service::cast(obj); Service *s=Service::cast(obj);
assert(s!=NULL); assert(s!=nullptr);
ostr << s->getProtocolName(); ostr << s->getProtocolName();
return ostr.str().c_str(); return ostr.str().c_str();
} }
@ -81,7 +81,7 @@ QString PIXObjectGroup::groupMemberToString(FWObject *obj,
{ {
ostr << "icmp-object "; ostr << "icmp-object ";
ICMPService *s=ICMPService::cast(obj); ICMPService *s=ICMPService::cast(obj);
assert(s!=NULL); assert(s!=nullptr);
if ( s->getInt("type")== -1) if ( s->getInt("type")== -1)
ostr << "any"; ostr << "any";
else else
@ -93,7 +93,7 @@ QString PIXObjectGroup::groupMemberToString(FWObject *obj,
{ {
ostr << "port-object "; ostr << "port-object ";
Service *s=Service::cast(obj); Service *s=Service::cast(obj);
assert(s!=NULL); assert(s!=nullptr);
int rs=TCPUDPService::cast(s)->getDstRangeStart(); int rs=TCPUDPService::cast(s)->getDstRangeStart();
int re=TCPUDPService::cast(s)->getDstRangeEnd(); int re=TCPUDPService::cast(s)->getDstRangeEnd();

View File

@ -57,7 +57,7 @@ void init(char * const*)
userDataDir = string(getenv("HOME")); userDataDir = string(getenv("HOME"));
char *lname = getenv("LOGNAME"); char *lname = getenv("LOGNAME");
if (lname!=NULL) if (lname!=nullptr)
user_name = QString(lname); user_name = QString(lname);
else else
{ {

View File

@ -92,7 +92,7 @@ void CompilerDriver::assembleFwScriptInternal(Cluster *cluster,
time_t tm; time_t tm;
struct tm *stm; struct tm *stm;
tm = time(NULL); tm = time(nullptr);
stm = localtime(&tm); stm = localtime(&tm);
timestr = strdup(ctime(&tm)); timestr = strdup(ctime(&tm));
timestr[strlen(timestr)-1] = '\0'; timestr[strlen(timestr)-1] = '\0';

View File

@ -103,9 +103,9 @@ using namespace libfwbuilder;
using namespace std; using namespace std;
FWWindow *mw = NULL; FWWindow *mw = nullptr;
FWBSettings *st = NULL; FWBSettings *st = nullptr;
FWBApplication *app = NULL; FWBApplication *app = nullptr;
string cmd_str = ""; string cmd_str = "";
command cmd = NONE; command cmd = NONE;
@ -117,7 +117,7 @@ int conflict_res = 1;
vector<string> platforms; vector<string> platforms;
FWObjectDatabase *objdb = NULL; FWObjectDatabase *objdb = nullptr;
int fwbdebug = 0; int fwbdebug = 0;
@ -493,7 +493,7 @@ int main(int argc, char * const *argv)
case 'a': case 'a':
int num=0; int num=0;
Q_UNUSED(num); Q_UNUSED(num);
if (optarg!=NULL) if (optarg!=nullptr)
{ {
string str = optarg; string str = optarg;
num = splitStr(',', str, &ops); num = splitStr(',', str, &ops);
@ -544,7 +544,7 @@ int main(int argc, char * const *argv)
case 'a': case 'a':
int num=0; int num=0;
Q_UNUSED(num); Q_UNUSED(num);
if (optarg!=NULL) if (optarg!=nullptr)
{ {
string str = optarg; string str = optarg;
num = splitStr(',', str, &ops); num = splitStr(',', str, &ops);
@ -738,8 +738,8 @@ int main(int argc, char * const *argv)
.split("/", QString::SkipEmptyParts); .split("/", QString::SkipEmptyParts);
string fw_name = components.last().toUtf8().constData(); string fw_name = components.last().toUtf8().constData();
Library *library = NULL; Library *library = nullptr;
while (library == NULL) while (library == nullptr)
{ {
components.pop_back(); components.pop_back();
string library_path = components.join("/").toUtf8().constData(); string library_path = components.join("/").toUtf8().constData();

View File

@ -59,7 +59,7 @@ void importConfig(const string &import_config,
std::istringstream instream(buffer); std::istringstream instream(buffer);
QueueLogger *logger = new QueueLogger(); QueueLogger *logger = new QueueLogger();
logger->copyToStderr(); logger->copyToStderr();
Importer* imp = NULL; Importer* imp = nullptr;
QStringList sl_buf = QString::fromUtf8(buffer.c_str()).split("\n"); QStringList sl_buf = QString::fromUtf8(buffer.c_str()).split("\n");
PreImport pi(&sl_buf); PreImport pi(&sl_buf);

View File

@ -147,7 +147,7 @@ string getAttributeValue(FWObject *obj, const string &attr_name)
return DNSName::cast(obj)->getSourceName(); return DNSName::cast(obj)->getSourceName();
} }
if (TCPUDPService::cast(obj)!=NULL) if (TCPUDPService::cast(obj)!=nullptr)
{ {
ostringstream str; ostringstream str;
if (attr_name=="src_range_start") if (attr_name=="src_range_start")
@ -161,7 +161,7 @@ string getAttributeValue(FWObject *obj, const string &attr_name)
if (str.tellp()>0) return str.str(); if (str.tellp()>0) return str.str();
} }
if (ICMPService::cast(obj)!=NULL) if (ICMPService::cast(obj)!=nullptr)
{ {
if (attr_name=="icmp_type") return obj->getStr("type"); if (attr_name=="icmp_type") return obj->getStr("type");
if (attr_name=="icmp_code") return obj->getStr("code"); if (attr_name=="icmp_code") return obj->getStr("code");

View File

@ -248,7 +248,7 @@ bool testPlatform(const string &pl, const string &os)
FWObject* createObject(FWObjectDatabase *objdb, FWObject* createObject(FWObjectDatabase *objdb,
const string &type, const string &parent) const string &type, const string &parent)
{ {
FWObject* obj = NULL; FWObject* obj = nullptr;
string path; string path;
obj = objdb->create(type); obj = objdb->create(type);

View File

@ -182,8 +182,8 @@ FWObject* IOSImporter::createTCPUDPNeqObject(const QString &proto,
if ( ! name.isEmpty()) sig.object_name = name; if ( ! name.isEmpty()) sig.object_name = name;
QString group_name; QString group_name;
FWObject *srv1 = NULL; FWObject *srv1 = nullptr;
FWObject *srv2 = NULL; FWObject *srv2 = nullptr;
if (src_port_op == "neq") if (src_port_op == "neq")
{ {
@ -221,7 +221,7 @@ FWObject* IOSImporter::createTCPUDPNeqObject(const QString &proto,
srv2 = service_maker->createObject(sig); srv2 = service_maker->createObject(sig);
} }
assert(srv1 != NULL && srv2 != NULL); assert(srv1 != nullptr && srv2 != nullptr);
ObjectMaker maker(Library::cast(library), error_tracker); ObjectMaker maker(Library::cast(library), error_tracker);
FWObject *grp = FWObject *grp =
@ -250,8 +250,8 @@ void IOSImporter::ignoreCurrentInterface()
void IOSImporter::pushRule() void IOSImporter::pushRule()
{ {
assert(current_ruleset!=NULL); assert(current_ruleset!=nullptr);
assert(current_rule!=NULL); assert(current_rule!=nullptr);
// populate all elements of the rule // populate all elements of the rule
addMessageToLog( addMessageToLog(
@ -270,7 +270,7 @@ void IOSImporter::MergeRules::move(FWObject* r)
// classes PolicyRule and RuleSetOptions. If r does not cast to // classes PolicyRule and RuleSetOptions. If r does not cast to
// PolicyRule, then it must be RuleSetOptions and we should just // PolicyRule, then it must be RuleSetOptions and we should just
// skip it. // skip it.
if (rule==NULL) if (rule==nullptr)
{ {
r->getParent()->remove(r); r->getParent()->remove(r);
return; return;
@ -310,7 +310,7 @@ Firewall* IOSImporter::finalize()
fw->getManagementObject(); // creates management obj fw->getManagementObject(); // creates management obj
FWObject *policy = getFirewallObject()->getFirstByType(Policy::TYPENAME); FWObject *policy = getFirewallObject()->getFirstByType(Policy::TYPENAME);
assert( policy!=NULL ); assert( policy!=nullptr );
if (all_rulesets.size()!=0) if (all_rulesets.size()!=0)
{ {
@ -401,7 +401,7 @@ Firewall* IOSImporter::finalize()
if (_dir=="out") direction = PolicyRule::Outbound; if (_dir=="out") direction = PolicyRule::Outbound;
// not all access lists are associated with interfaces // not all access lists are associated with interfaces
if (intf!=NULL) if (intf!=nullptr)
{ {
if (fwbdebug) if (fwbdebug)
qDebug() << " interface=" qDebug() << " interface="
@ -434,6 +434,6 @@ Firewall* IOSImporter::finalize()
} }
else else
{ {
return NULL; return nullptr;
} }
} }

View File

@ -75,9 +75,9 @@ IPTImporter::IPTImporter(FWObject *lib,
current_table = ""; current_table = "";
current_chain = ""; current_chain = "";
current_state = ""; current_state = "";
current_ruleset = NULL; current_ruleset = nullptr;
current_rule = NULL; current_rule = nullptr;
last_mark_rule = NULL; last_mark_rule = nullptr;
clear(); clear();
@ -397,13 +397,13 @@ void IPTImporter::processModuleMatches()
{ {
PolicyRule *rule = PolicyRule::cast(current_rule); PolicyRule *rule = PolicyRule::cast(current_rule);
RuleElementSrv* srv = rule->getSrv(); RuleElementSrv* srv = rule->getSrv();
assert(srv!=NULL); assert(srv!=nullptr);
FWOptions *fwopt = getFirewallObject()->getOptionsObject(); FWOptions *fwopt = getFirewallObject()->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
FWOptions *ropt = current_rule->getOptionsObject(); FWOptions *ropt = current_rule->getOptionsObject();
assert(ropt!=NULL); assert(ropt!=nullptr);
addAllModuleMatches(rule); addAllModuleMatches(rule);
@ -459,7 +459,7 @@ void IPTImporter::addAllModuleMatches(PolicyRule *rule)
void IPTImporter::addMarkMatch(PolicyRule *rule) void IPTImporter::addMarkMatch(PolicyRule *rule)
{ {
RuleElementSrv* srv = rule->getSrv(); RuleElementSrv* srv = rule->getSrv();
assert(srv!=NULL); assert(srv!=nullptr);
if (rule->getSrv()->isAny() && !match_mark.empty()) if (rule->getSrv()->isAny() && !match_mark.empty())
{ {
ObjectSignature sig(error_tracker); ObjectSignature sig(error_tracker);
@ -474,7 +474,7 @@ void IPTImporter::addMarkMatch(PolicyRule *rule)
void IPTImporter::addLengthMatch(PolicyRule *rule) void IPTImporter::addLengthMatch(PolicyRule *rule)
{ {
RuleElementSrv* srv = rule->getSrv(); RuleElementSrv* srv = rule->getSrv();
assert(srv!=NULL); assert(srv!=nullptr);
if (rule->getSrv()->isAny() && !length_spec.empty()) if (rule->getSrv()->isAny() && !length_spec.empty())
{ {
// create custom service with module "length" // create custom service with module "length"
@ -491,7 +491,7 @@ void IPTImporter::addLengthMatch(PolicyRule *rule)
void IPTImporter::addPktTypeMatch(PolicyRule *rule) void IPTImporter::addPktTypeMatch(PolicyRule *rule)
{ {
RuleElementSrv* srv = rule->getSrv(); RuleElementSrv* srv = rule->getSrv();
assert(srv!=NULL); assert(srv!=nullptr);
if (rule->getSrv()->isAny() && !pkt_type_spec.empty()) if (rule->getSrv()->isAny() && !pkt_type_spec.empty())
{ {
// create custom service with module "pkttype" // create custom service with module "pkttype"
@ -508,7 +508,7 @@ void IPTImporter::addPktTypeMatch(PolicyRule *rule)
void IPTImporter::addLimitMatch(PolicyRule *rule) void IPTImporter::addLimitMatch(PolicyRule *rule)
{ {
FWOptions *ropt = rule->getOptionsObject(); FWOptions *ropt = rule->getOptionsObject();
assert(ropt!=NULL); assert(ropt!=nullptr);
if (target!="LOG" && !limit_val.empty()) if (target!="LOG" && !limit_val.empty())
{ {
// TODO: this is where we should add support for hashlimit // TODO: this is where we should add support for hashlimit
@ -523,7 +523,7 @@ void IPTImporter::addLimitMatch(PolicyRule *rule)
void IPTImporter::addRecentMatch(PolicyRule *rule) void IPTImporter::addRecentMatch(PolicyRule *rule)
{ {
RuleElementSrv* srv = rule->getSrv(); RuleElementSrv* srv = rule->getSrv();
assert(srv!=NULL); assert(srv!=nullptr);
if (rule->getSrv()->isAny() && !recent_match.empty()) if (rule->getSrv()->isAny() && !recent_match.empty())
{ {
// create custom service with module "recent" // create custom service with module "recent"
@ -541,7 +541,7 @@ void IPTImporter::addRecentMatch(PolicyRule *rule)
void IPTImporter::addStateMatch(libfwbuilder::PolicyRule *rule, const string &state) void IPTImporter::addStateMatch(libfwbuilder::PolicyRule *rule, const string &state)
{ {
RuleElementSrv* srv = rule->getSrv(); RuleElementSrv* srv = rule->getSrv();
assert(srv!=NULL); assert(srv!=nullptr);
if (rule->getSrv()->isAny() && !state.empty()) if (rule->getSrv()->isAny() && !state.empty())
{ {
// create custom service with module "state" // create custom service with module "state"
@ -569,7 +569,7 @@ PolicyRule* IPTImporter::createPolicyBranch(
bool clear_rule_elements, bool make_stateless) bool clear_rule_elements, bool make_stateless)
{ {
UnidirectionalRuleSet *rs = branch_rulesets[branch_ruleset_name]; UnidirectionalRuleSet *rs = branch_rulesets[branch_ruleset_name];
if (rs==NULL) if (rs==nullptr)
rs = getUnidirRuleSet(branch_ruleset_name, Policy::TYPENAME); rs = getUnidirRuleSet(branch_ruleset_name, Policy::TYPENAME);
branch_rulesets[branch_ruleset_name] = rs; branch_rulesets[branch_ruleset_name] = rs;
rs->ruleset->setName(branch_ruleset_name); rs->ruleset->setName(branch_ruleset_name);
@ -584,10 +584,10 @@ PolicyRule* IPTImporter::createPolicyBranch(
rule->setBranch(rs->ruleset); rule->setBranch(rs->ruleset);
FWOptions *ropt = rule->getOptionsObject(); FWOptions *ropt = rule->getOptionsObject();
assert(ropt!=NULL); assert(ropt!=nullptr);
ropt->setBool("stateless", true); ropt->setBool("stateless", true);
if (rule->getParent() != NULL) if (rule->getParent() != nullptr)
{ {
ostringstream str1; ostringstream str1;
str1 << "Called from ruleset " << rule->getParent()->getName() str1 << "Called from ruleset " << rule->getParent()->getName()
@ -607,7 +607,7 @@ PolicyRule* IPTImporter::createPolicyBranch(
if (make_stateless) if (make_stateless)
{ {
FWOptions *ropt = new_rule->getOptionsObject(); FWOptions *ropt = new_rule->getOptionsObject();
assert(ropt!=NULL); assert(ropt!=nullptr);
ropt->setBool("stateless", true); ropt->setBool("stateless", true);
} }
@ -622,7 +622,7 @@ NATRule* IPTImporter::createNATBranch(
bool clear_rule_elements) bool clear_rule_elements)
{ {
UnidirectionalRuleSet *rs = branch_rulesets[branch_ruleset_name]; UnidirectionalRuleSet *rs = branch_rulesets[branch_ruleset_name];
if (rs==NULL) if (rs==nullptr)
rs = getUnidirRuleSet(branch_ruleset_name, NAT::TYPENAME); rs = getUnidirRuleSet(branch_ruleset_name, NAT::TYPENAME);
branch_rulesets[branch_ruleset_name] = rs; branch_rulesets[branch_ruleset_name] = rs;
rs->ruleset->setName(branch_ruleset_name); rs->ruleset->setName(branch_ruleset_name);
@ -636,7 +636,7 @@ NATRule* IPTImporter::createNATBranch(
rule->setRuleType(NATRule::NATBranch); rule->setRuleType(NATRule::NATBranch);
rule->setBranch(rs->ruleset); rule->setBranch(rs->ruleset);
if (rule->getParent() != NULL) if (rule->getParent() != nullptr)
{ {
ostringstream str1; ostringstream str1;
str1 << "Called from ruleset " << rule->getParent()->getName() str1 << "Called from ruleset " << rule->getParent()->getName()
@ -670,7 +670,7 @@ NATRule* IPTImporter::createNATBranch(
void IPTImporter::pushRule() void IPTImporter::pushRule()
{ {
// assert(current_ruleset!=NULL); // assert(current_ruleset!=NULL);
if (current_rule==NULL) return; if (current_rule==nullptr) return;
if (current_table=="nat") pushNATRule(); if (current_table=="nat") pushNATRule();
else pushPolicyRule(); else pushPolicyRule();
@ -684,10 +684,10 @@ void IPTImporter::pushPolicyRule()
rule->setLogging(false); rule->setLogging(false);
FWOptions *fwopt = getFirewallObject()->getOptionsObject(); FWOptions *fwopt = getFirewallObject()->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
FWOptions *ropt = current_rule->getOptionsObject(); FWOptions *ropt = current_rule->getOptionsObject();
assert(ropt!=NULL); assert(ropt!=nullptr);
bool skip_rule = false; bool skip_rule = false;
@ -879,7 +879,7 @@ void IPTImporter::pushPolicyRule()
std::string branch_ruleset_name = target; std::string branch_ruleset_name = target;
action = PolicyRule::Branch; action = PolicyRule::Branch;
UnidirectionalRuleSet *rs = branch_rulesets[branch_ruleset_name]; UnidirectionalRuleSet *rs = branch_rulesets[branch_ruleset_name];
if (rs==NULL) if (rs==nullptr)
rs = getUnidirRuleSet(branch_ruleset_name, Policy::TYPENAME); rs = getUnidirRuleSet(branch_ruleset_name, Policy::TYPENAME);
branch_rulesets[branch_ruleset_name] = rs; branch_rulesets[branch_ruleset_name] = rs;
@ -917,12 +917,12 @@ void IPTImporter::pushPolicyRule()
{ {
RuleElementSrv *srv = rule->getSrv(); RuleElementSrv *srv = rule->getSrv();
std::string protocol = ""; std::string protocol = "";
FWObject *estab = NULL; FWObject *estab = nullptr;
FWObjectDatabase *dbroot = getFirewallObject()->getRoot(); FWObjectDatabase *dbroot = getFirewallObject()->getRoot();
FWObject *std_obj = dbroot->findInIndex(FWObjectDatabase::STANDARD_LIB_ID); FWObject *std_obj = dbroot->findInIndex(FWObjectDatabase::STANDARD_LIB_ID);
estab = std_obj->findObjectByName(CustomService::TYPENAME, "ESTABLISHED"); estab = std_obj->findObjectByName(CustomService::TYPENAME, "ESTABLISHED");
if (estab == NULL) if (estab == nullptr)
{ {
ObjectSignature sig(error_tracker); ObjectSignature sig(error_tracker);
sig.type_name = CustomService::TYPENAME; sig.type_name = CustomService::TYPENAME;
@ -1034,11 +1034,11 @@ void IPTImporter::pushPolicyRule()
if (target=="CONNMARK" && if (target=="CONNMARK" &&
last_mark_rule != NULL && last_mark_rule != nullptr &&
!action_params["connmark_save_mark"].empty()) !action_params["connmark_save_mark"].empty())
{ {
FWOptions *lmr_ropt = last_mark_rule->getOptionsObject(); FWOptions *lmr_ropt = last_mark_rule->getOptionsObject();
assert(lmr_ropt!=NULL); assert(lmr_ropt!=nullptr);
lmr_ropt->setBool("ipt_mark_connections", true); lmr_ropt->setBool("ipt_mark_connections", true);
skip_rule = true; skip_rule = true;
addMessageToLog( addMessageToLog(
@ -1097,7 +1097,7 @@ void IPTImporter::pushPolicyRule()
} }
// add rule to the right ruleset // add rule to the right ruleset
RuleSet *ruleset = NULL; RuleSet *ruleset = nullptr;
std::string ruleset_name = ""; std::string ruleset_name = "";
// if (isStandardChain(current_chain)) // if (isStandardChain(current_chain))
@ -1115,7 +1115,7 @@ void IPTImporter::pushPolicyRule()
UnidirectionalRuleSet *rs = getUnidirRuleSet(current_chain, UnidirectionalRuleSet *rs = getUnidirRuleSet(current_chain,
Policy::TYPENAME); Policy::TYPENAME);
assert(rs!=NULL); assert(rs!=nullptr);
ruleset = rs->ruleset; ruleset = rs->ruleset;
ruleset->add(current_rule); ruleset->add(current_rule);
@ -1238,7 +1238,7 @@ void IPTImporter::pushPolicyRule()
markCurrentRuleBad(); markCurrentRuleBad();
} }
current_rule = NULL; current_rule = nullptr;
rule_comment = ""; rule_comment = "";
clear(); clear();
@ -1251,10 +1251,10 @@ void IPTImporter::pushNATRule()
NATRule *rule = NATRule::cast(current_rule); NATRule *rule = NATRule::cast(current_rule);
FWOptions *fwopt = getFirewallObject()->getOptionsObject(); FWOptions *fwopt = getFirewallObject()->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
FWOptions *ropt = current_rule->getOptionsObject(); FWOptions *ropt = current_rule->getOptionsObject();
assert(ropt!=NULL); assert(ropt!=nullptr);
addOSrc(); addOSrc();
addODst(); addODst();
@ -1276,7 +1276,7 @@ void IPTImporter::pushNATRule()
rule_type = NATRule::Masq; rule_type = NATRule::Masq;
RuleElementTSrc *re = rule->getTSrc(); RuleElementTSrc *re = rule->getTSrc();
assert(re!=NULL); assert(re!=nullptr);
if ( !o_intf.empty() ) if ( !o_intf.empty() )
{ {
newInterface(o_intf); newInterface(o_intf);
@ -1292,7 +1292,7 @@ void IPTImporter::pushNATRule()
{ {
rule_type = NATRule::SNAT; rule_type = NATRule::SNAT;
FWObject *tsrc = NULL; FWObject *tsrc = nullptr;
if (nat_addr1!=nat_addr2) if (nat_addr1!=nat_addr2)
{ {
ObjectSignature sig(error_tracker); ObjectSignature sig(error_tracker);
@ -1310,7 +1310,7 @@ void IPTImporter::pushNATRule()
} }
RuleElementTSrc *re = rule->getTSrc(); RuleElementTSrc *re = rule->getTSrc();
assert(re!=NULL); assert(re!=nullptr);
re->addRef(tsrc); re->addRef(tsrc);
if (!nat_port_range_start.empty()) if (!nat_port_range_start.empty())
@ -1319,14 +1319,14 @@ void IPTImporter::pushNATRule()
str_tuple nat_port_range(nat_port_range_start, nat_port_range_end); str_tuple nat_port_range(nat_port_range_start, nat_port_range_end);
FWObject *s = createTCPUDPService(nat_port_range, empty_range, protocol); FWObject *s = createTCPUDPService(nat_port_range, empty_range, protocol);
RuleElementTSrv *re = rule->getTSrv(); RuleElementTSrv *re = rule->getTSrv();
assert(re!=NULL); assert(re!=nullptr);
re->addRef(s); re->addRef(s);
} }
if (!o_intf.empty()) if (!o_intf.empty())
{ {
RuleElement *itf_o_re = rule->getItfOutb(); RuleElement *itf_o_re = rule->getItfOutb();
assert(itf_o_re!=NULL); assert(itf_o_re!=nullptr);
newInterface(o_intf); newInterface(o_intf);
Interface *intf = all_interfaces[o_intf]; Interface *intf = all_interfaces[o_intf];
itf_o_re->addRef(intf); itf_o_re->addRef(intf);
@ -1342,11 +1342,11 @@ void IPTImporter::pushNATRule()
if (current_chain == "OUTPUT") if (current_chain == "OUTPUT")
{ {
RuleElementOSrc *re = rule->getOSrc(); RuleElementOSrc *re = rule->getOSrc();
assert(re!=NULL); assert(re!=nullptr);
re->addRef(getFirewallObject()); re->addRef(getFirewallObject());
} }
FWObject *tdst = NULL; FWObject *tdst = nullptr;
if (nat_addr1!=nat_addr2) if (nat_addr1!=nat_addr2)
{ {
ObjectSignature sig(error_tracker); ObjectSignature sig(error_tracker);
@ -1364,7 +1364,7 @@ void IPTImporter::pushNATRule()
} }
RuleElementTDst *re = rule->getTDst(); RuleElementTDst *re = rule->getTDst();
assert(re!=NULL); assert(re!=nullptr);
re->addRef(tdst); re->addRef(tdst);
if (!nat_port_range_start.empty()) if (!nat_port_range_start.empty())
@ -1373,14 +1373,14 @@ void IPTImporter::pushNATRule()
str_tuple nat_port_range(nat_port_range_start, nat_port_range_end); str_tuple nat_port_range(nat_port_range_start, nat_port_range_end);
FWObject *s = createTCPUDPService(empty_range, nat_port_range, protocol); FWObject *s = createTCPUDPService(empty_range, nat_port_range, protocol);
RuleElementTSrv *re = rule->getTSrv(); RuleElementTSrv *re = rule->getTSrv();
assert(re!=NULL); assert(re!=nullptr);
re->addRef(s); re->addRef(s);
} }
if (!i_intf.empty()) if (!i_intf.empty())
{ {
RuleElement *itf_i_re = rule->getItfInb(); RuleElement *itf_i_re = rule->getItfInb();
assert(itf_i_re!=NULL); assert(itf_i_re!=nullptr);
newInterface(i_intf); newInterface(i_intf);
Interface *intf = all_interfaces[i_intf]; Interface *intf = all_interfaces[i_intf];
itf_i_re->addRef(intf); itf_i_re->addRef(intf);
@ -1392,7 +1392,7 @@ void IPTImporter::pushNATRule()
rule_type = NATRule::Redirect; rule_type = NATRule::Redirect;
RuleElementTDst *re = rule->getTDst(); RuleElementTDst *re = rule->getTDst();
assert(re!=NULL); assert(re!=nullptr);
re->addRef(getFirewallObject()); re->addRef(getFirewallObject());
if (!nat_port_range_start.empty()) if (!nat_port_range_start.empty())
@ -1401,14 +1401,14 @@ void IPTImporter::pushNATRule()
str_tuple nat_port_range(nat_port_range_start, nat_port_range_end); str_tuple nat_port_range(nat_port_range_start, nat_port_range_end);
FWObject *s = createTCPUDPService(empty_range, nat_port_range, protocol); FWObject *s = createTCPUDPService(empty_range, nat_port_range, protocol);
RuleElementTSrv *re = rule->getTSrv(); RuleElementTSrv *re = rule->getTSrv();
assert(re!=NULL); assert(re!=nullptr);
re->addRef(s); re->addRef(s);
} }
if ( ! o_intf.empty()) if ( ! o_intf.empty())
{ {
RuleElement *itf_o_re = rule->getItfOutb(); RuleElement *itf_o_re = rule->getItfOutb();
assert(itf_o_re!=NULL); assert(itf_o_re!=nullptr);
newInterface(o_intf); newInterface(o_intf);
Interface *intf = all_interfaces[o_intf]; Interface *intf = all_interfaces[o_intf];
itf_o_re->addRef(intf); itf_o_re->addRef(intf);
@ -1417,14 +1417,14 @@ void IPTImporter::pushNATRule()
if (target=="NETMAP") if (target=="NETMAP")
{ {
FWObject *o = NULL; FWObject *o = nullptr;
if (!src_a.empty()) if (!src_a.empty())
{ {
rule_type = NATRule::SNetnat; rule_type = NATRule::SNetnat;
RuleElementTSrc *tsrc = rule->getTSrc(); RuleElementTSrc *tsrc = rule->getTSrc();
assert(tsrc!=NULL); assert(tsrc!=nullptr);
ObjectSignature sig(error_tracker); ObjectSignature sig(error_tracker);
sig.type_name = Address::TYPENAME; sig.type_name = Address::TYPENAME;
@ -1439,7 +1439,7 @@ void IPTImporter::pushNATRule()
rule_type = NATRule::DNetnat; rule_type = NATRule::DNetnat;
RuleElementTDst *tdst = rule->getTDst(); RuleElementTDst *tdst = rule->getTDst();
assert(tdst!=NULL); assert(tdst!=nullptr);
ObjectSignature sig(error_tracker); ObjectSignature sig(error_tracker);
sig.type_name = Address::TYPENAME; sig.type_name = Address::TYPENAME;
@ -1463,7 +1463,7 @@ void IPTImporter::pushNATRule()
rule->setAction(NATRule::Branch); rule->setAction(NATRule::Branch);
UnidirectionalRuleSet *rs = branch_rulesets[branch_ruleset_name]; UnidirectionalRuleSet *rs = branch_rulesets[branch_ruleset_name];
if (rs==NULL) if (rs==nullptr)
{ {
rs = getUnidirRuleSet(branch_ruleset_name, NAT::TYPENAME); rs = getUnidirRuleSet(branch_ruleset_name, NAT::TYPENAME);
branch_rulesets[branch_ruleset_name] = rs; branch_rulesets[branch_ruleset_name] = rs;
@ -1477,18 +1477,18 @@ void IPTImporter::pushNATRule()
rule->setRuleType(rule_type); rule->setRuleType(rule_type);
// add rule to the right ruleset // add rule to the right ruleset
RuleSet *ruleset = NULL; RuleSet *ruleset = nullptr;
std::string ruleset_name = ""; std::string ruleset_name = "";
if (isStandardChain(current_chain)) if (isStandardChain(current_chain))
{ {
ruleset = RuleSet::cast( ruleset = RuleSet::cast(
getFirewallObject()->getFirstByType(NAT::TYPENAME)); getFirewallObject()->getFirstByType(NAT::TYPENAME));
assert(ruleset!=NULL); assert(ruleset!=nullptr);
ruleset->add(current_rule); ruleset->add(current_rule);
} else } else
{ {
UnidirectionalRuleSet *rs = getUnidirRuleSet(current_chain, NAT::TYPENAME); UnidirectionalRuleSet *rs = getUnidirRuleSet(current_chain, NAT::TYPENAME);
assert(rs!=NULL); assert(rs!=nullptr);
rs->ruleset->add(current_rule); rs->ruleset->add(current_rule);
ruleset = rs->ruleset; ruleset = rs->ruleset;
} }
@ -1505,7 +1505,7 @@ void IPTImporter::pushNATRule()
// assert( nat!=NULL ); // assert( nat!=NULL );
// nat->add(current_rule); // nat->add(current_rule);
current_rule = NULL; current_rule = nullptr;
rule_comment = ""; rule_comment = "";
clear(); clear();
@ -1540,7 +1540,7 @@ Firewall* IPTImporter::finalize()
fw->getManagementObject(); // creates management obj fw->getManagementObject(); // creates management obj
FWOptions *fwopt = fw->getOptionsObject(); FWOptions *fwopt = fw->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
fwopt->setBool("firewall_is_part_of_any_and_networks", false); fwopt->setBool("firewall_is_part_of_any_and_networks", false);
@ -1562,7 +1562,7 @@ Firewall* IPTImporter::finalize()
// check if all child objects were populated properly // check if all child objects were populated properly
FWOptions *ropt = rule->getOptionsObject(); FWOptions *ropt = rule->getOptionsObject();
assert(ropt != NULL); assert(ropt != nullptr);
ropt->setBool("stateless", true); ropt->setBool("stateless", true);
rule->setAction(PolicyRule::Accept); rule->setAction(PolicyRule::Accept);
@ -1597,7 +1597,7 @@ Firewall* IPTImporter::finalize()
if (rs->name == "INPUT") if (rs->name == "INPUT")
{ {
RuleElementDst* dst = rule->getDst(); RuleElementDst* dst = rule->getDst();
assert(dst!=NULL); assert(dst!=nullptr);
dst->addRef(fw); dst->addRef(fw);
rule->setDirection(PolicyRule::Inbound); rule->setDirection(PolicyRule::Inbound);
@ -1622,7 +1622,7 @@ Firewall* IPTImporter::finalize()
if (rs->name == "OUTPUT") if (rs->name == "OUTPUT")
{ {
RuleElementSrc* src = rule->getSrc(); RuleElementSrc* src = rule->getSrc();
assert(src!=NULL); assert(src!=nullptr);
src->addRef(fw); src->addRef(fw);
rule->setDirection(PolicyRule::Outbound); rule->setDirection(PolicyRule::Outbound);
} }
@ -1665,7 +1665,7 @@ Firewall* IPTImporter::finalize()
} }
else else
{ {
return NULL; return nullptr;
} }
} }
@ -1681,9 +1681,9 @@ UnidirectionalRuleSet* IPTImporter::getUnidirRuleSet(
{ {
string all_rulesets_index = current_table + "/" + ruleset_name; string all_rulesets_index = current_table + "/" + ruleset_name;
UnidirectionalRuleSet *rs = all_rulesets[all_rulesets_index]; UnidirectionalRuleSet *rs = all_rulesets[all_rulesets_index];
if (rs == NULL) if (rs == nullptr)
{ {
RuleSet *ruleset = NULL; RuleSet *ruleset = nullptr;
FWObjectDatabase *dbroot = getFirewallObject()->getRoot(); FWObjectDatabase *dbroot = getFirewallObject()->getRoot();
if (isStandardChain(ruleset_name)) if (isStandardChain(ruleset_name))
@ -1709,7 +1709,7 @@ UnidirectionalRuleSet* IPTImporter::getUnidirRuleSet(
break; break;
} }
} }
if (ruleset == NULL) if (ruleset == nullptr)
{ {
ruleset = RuleSet::cast(dbroot->create(Policy::TYPENAME)); ruleset = RuleSet::cast(dbroot->create(Policy::TYPENAME));
FWOptions *rulesetopt = ruleset->getOptionsObject(); FWOptions *rulesetopt = ruleset->getOptionsObject();
@ -1733,7 +1733,7 @@ UnidirectionalRuleSet* IPTImporter::getUnidirRuleSet(
break; break;
} }
} }
if (ruleset == NULL) if (ruleset == nullptr)
{ {
ruleset = RuleSet::cast(dbroot->create(Policy::TYPENAME)); ruleset = RuleSet::cast(dbroot->create(Policy::TYPENAME));
FWOptions *rulesetopt = ruleset->getOptionsObject(); FWOptions *rulesetopt = ruleset->getOptionsObject();

View File

@ -487,7 +487,7 @@ void PFImporter::convertTcpFlags(QList<int> &flags_list,
FWObject* PFImporter::makeAddressObj(AddressSpec &as) FWObject* PFImporter::makeAddressObj(AddressSpec &as)
{ {
if (as.at == AddressSpec::ANY) return NULL; if (as.at == AddressSpec::ANY) return nullptr;
if (as.at == AddressSpec::INTERFACE_OR_HOST_NAME) if (as.at == AddressSpec::INTERFACE_OR_HOST_NAME)
{ {
@ -497,7 +497,7 @@ FWObject* PFImporter::makeAddressObj(AddressSpec &as)
if (int_prop->looksLikeInterface(as.address.c_str())) if (int_prop->looksLikeInterface(as.address.c_str()))
{ {
Interface *intf = getInterfaceByName(as.address); Interface *intf = getInterfaceByName(as.address);
if (intf == NULL) if (intf == nullptr)
{ {
// this interface was never used in "on <intf>" clause before // this interface was never used in "on <intf>" clause before
newInterface(as.address); newInterface(as.address);
@ -532,7 +532,7 @@ FWObject* PFImporter::makeAddressObj(AddressSpec &as)
if (as.at == AddressSpec::INTERFACE_NETWORK) if (as.at == AddressSpec::INTERFACE_NETWORK)
{ {
Interface *intf = getInterfaceByName(as.address); Interface *intf = getInterfaceByName(as.address);
if (intf == NULL) if (intf == nullptr)
{ {
// this interface was never used in "on <intf>" clause before // this interface was never used in "on <intf>" clause before
newInterface(as.address); newInterface(as.address);
@ -540,7 +540,7 @@ FWObject* PFImporter::makeAddressObj(AddressSpec &as)
} }
FWObject *o = intf->getFirstByType(AttachedNetworks::TYPENAME); FWObject *o = intf->getFirstByType(AttachedNetworks::TYPENAME);
if ( o != NULL ) if ( o != nullptr )
{ {
return o; return o;
} else { } else {
@ -560,7 +560,7 @@ FWObject* PFImporter::makeAddressObj(AddressSpec &as)
{ {
error_tracker->registerError( error_tracker->registerError(
QObject::tr("import of 'interface:broadcast' is not supported.")); QObject::tr("import of 'interface:broadcast' is not supported."));
return NULL; return nullptr;
} }
if (as.at == AddressSpec::HOST_ADDRESS) if (as.at == AddressSpec::HOST_ADDRESS)
@ -580,7 +580,7 @@ FWObject* PFImporter::makeAddressObj(AddressSpec &as)
error_tracker->registerError( error_tracker->registerError(
QObject::tr("Warning: matching '%1' is not supported") QObject::tr("Warning: matching '%1' is not supported")
.arg(as.address.c_str())); .arg(as.address.c_str()));
return NULL; return nullptr;
} }
} }
@ -594,7 +594,7 @@ FWObject* PFImporter::makeAddressObj(AddressSpec &as)
return at; return at;
} }
return NULL; return nullptr;
} }
void PFImporter::addLogging() void PFImporter::addLogging()
@ -667,7 +667,7 @@ void PFImporter::pushRule()
else else
pushNATRule(); pushNATRule();
assert(current_rule!=NULL); assert(current_rule!=nullptr);
if (error_tracker->hasWarnings()) if (error_tracker->hasWarnings())
{ {
@ -692,7 +692,7 @@ void PFImporter::pushRule()
markCurrentRuleBad(); markCurrentRuleBad();
} }
current_rule = NULL; current_rule = nullptr;
rule_comment = ""; rule_comment = "";
clear(); clear();
@ -708,7 +708,7 @@ void PFImporter::pushPolicyRule()
// base class uses dictionary all_rulesets to do some checks (e.g. // base class uses dictionary all_rulesets to do some checks (e.g.
// countRules()) so we'll create one dummy UnidirectionalRuleSet object // countRules()) so we'll create one dummy UnidirectionalRuleSet object
string ruleset_name = ruleset->getName(); string ruleset_name = ruleset->getName();
if (checkUnidirRuleSet(ruleset_name) == NULL) if (checkUnidirRuleSet(ruleset_name) == nullptr)
{ {
UnidirectionalRuleSet *rs = new UnidirectionalRuleSet(); UnidirectionalRuleSet *rs = new UnidirectionalRuleSet();
rs->name = ruleset_name; rs->name = ruleset_name;
@ -716,7 +716,7 @@ void PFImporter::pushPolicyRule()
all_rulesets[ruleset_name] = rs; all_rulesets[ruleset_name] = rs;
} }
assert(current_rule!=NULL); assert(current_rule!=nullptr);
// populate all elements of the rule // populate all elements of the rule
// Note that standard function // Note that standard function
@ -734,7 +734,7 @@ void PFImporter::pushPolicyRule()
PolicyRule *rule = PolicyRule::cast(current_rule); PolicyRule *rule = PolicyRule::cast(current_rule);
FWOptions *ropt = current_rule->getOptionsObject(); FWOptions *ropt = current_rule->getOptionsObject();
assert(ropt!=NULL); assert(ropt!=nullptr);
if (action=="pass") if (action=="pass")
{ {
@ -811,7 +811,7 @@ void PFImporter::pushPolicyRule()
for (it=iface_group.begin(); it!=iface_group.end(); ++it) for (it=iface_group.begin(); it!=iface_group.end(); ++it)
{ {
Interface *intf = getInterfaceByName(it->name); Interface *intf = getInterfaceByName(it->name);
assert(intf!=NULL); assert(intf!=nullptr);
RuleElement *re =rule->getItf(); RuleElement *re =rule->getItf();
re->addRef(intf); re->addRef(intf);
if (it->neg) re->setNeg(true); if (it->neg) re->setNeg(true);
@ -853,7 +853,7 @@ void PFImporter::pushPolicyRule()
sig.type_name = TagService::TYPENAME; sig.type_name = TagService::TYPENAME;
sig.tag = tag.c_str(); sig.tag = tag.c_str();
FWObject *tobj = commitObject(service_maker->createObject(sig)); FWObject *tobj = commitObject(service_maker->createObject(sig));
rule->setTagging(tobj != NULL); rule->setTagging(tobj != nullptr);
rule->setTagObject(tobj); rule->setTagObject(tobj);
} }
@ -911,7 +911,7 @@ void PFImporter::pushPolicyRule()
RouteSpec &rs = *it; RouteSpec &rs = *it;
Interface *intf = getInterfaceByName(rs.iface); Interface *intf = getInterfaceByName(rs.iface);
if (intf == NULL) if (intf == nullptr)
{ {
// this interface was never used in "on <intf>" clause before // this interface was never used in "on <intf>" clause before
intf = newInterface(rs.iface); intf = newInterface(rs.iface);
@ -990,7 +990,7 @@ void PFImporter::pushNATRule()
// base class uses dictionary all_rulesets to do some checks (e.g. // base class uses dictionary all_rulesets to do some checks (e.g.
// countRules()) so we'll create one dummy UnidirectionalRuleSet object // countRules()) so we'll create one dummy UnidirectionalRuleSet object
string ruleset_name = ruleset->getName(); string ruleset_name = ruleset->getName();
if (checkUnidirRuleSet(ruleset_name) == NULL) if (checkUnidirRuleSet(ruleset_name) == nullptr)
{ {
UnidirectionalRuleSet *rs = new UnidirectionalRuleSet(); UnidirectionalRuleSet *rs = new UnidirectionalRuleSet();
rs->name = ruleset_name; rs->name = ruleset_name;
@ -998,7 +998,7 @@ void PFImporter::pushNATRule()
all_rulesets[ruleset_name] = rs; all_rulesets[ruleset_name] = rs;
} }
assert(current_rule!=NULL); assert(current_rule!=nullptr);
QString message_str = QString message_str =
QString("nat rule: action %1; interfaces: %2"); QString("nat rule: action %1; interfaces: %2");
@ -1006,7 +1006,7 @@ void PFImporter::pushNATRule()
NATRule *rule = NATRule::cast(current_rule); NATRule *rule = NATRule::cast(current_rule);
FWOptions *ropt = current_rule->getOptionsObject(); FWOptions *ropt = current_rule->getOptionsObject();
assert(ropt!=NULL); assert(ropt!=nullptr);
if (action=="nat") rule->setRuleType(NATRule::SNAT); if (action=="nat") rule->setRuleType(NATRule::SNAT);
if (action=="rdr") rule->setRuleType(NATRule::DNAT); if (action=="rdr") rule->setRuleType(NATRule::DNAT);
@ -1021,7 +1021,7 @@ void PFImporter::pushNATRule()
for (it=iface_group.begin(); it!=iface_group.end(); ++it) for (it=iface_group.begin(); it!=iface_group.end(); ++it)
{ {
Interface *intf = getInterfaceByName(it->name); Interface *intf = getInterfaceByName(it->name);
assert(intf!=NULL); assert(intf!=nullptr);
RuleElement *re =rule->getItfOutb(); RuleElement *re =rule->getItfOutb();
re->addRef(intf); re->addRef(intf);
if (it->neg) re->setNeg(true); if (it->neg) re->setNeg(true);
@ -1300,7 +1300,7 @@ Firewall* PFImporter::finalize()
if (int_prop->looksLikeInterface(skip_interface_name.c_str())) if (int_prop->looksLikeInterface(skip_interface_name.c_str()))
{ {
Interface *intf = getInterfaceByName(skip_interface_name); Interface *intf = getInterfaceByName(skip_interface_name);
if (intf == NULL) if (intf == nullptr)
{ {
// this interface was never used in "on // this interface was never used in "on
// <intf>" clause before // <intf>" clause before
@ -1377,7 +1377,7 @@ Firewall* PFImporter::finalize()
} }
else else
{ {
return NULL; return nullptr;
} }
} }
@ -1392,7 +1392,7 @@ Interface* PFImporter::getInterfaceByName(const string &name)
return intf; return intf;
} }
} }
return NULL; return nullptr;
} }
void PFImporter::newAddressTableObject(const string &name, const string &file) void PFImporter::newAddressTableObject(const string &name, const string &file)
@ -1437,7 +1437,7 @@ void PFImporter::newAddressTableObject(const string &name,
ObjectMaker maker(Library::cast(library), error_tracker); ObjectMaker maker(Library::cast(library), error_tracker);
FWObject *og = FWObject *og =
commitObject(maker.createObject(ObjectGroup::TYPENAME, name.c_str())); commitObject(maker.createObject(ObjectGroup::TYPENAME, name.c_str()));
assert(og!=NULL); assert(og!=nullptr);
address_table_registry[name.c_str()] = og; address_table_registry[name.c_str()] = og;
if (has_negations) if (has_negations)

View File

@ -91,11 +91,11 @@ void PIXImporter::clear()
{ {
Importer::clear(); Importer::clear();
current_named_object = NULL; current_named_object = nullptr;
named_object_name = ""; named_object_name = "";
named_object_comment = ""; named_object_comment = "";
current_object_group = NULL; current_object_group = nullptr;
object_group_name = ""; object_group_name = "";
object_group_comment = ""; object_group_comment = "";
object_group_service_protocol = ""; object_group_service_protocol = "";
@ -142,7 +142,7 @@ Interface* PIXImporter::getInterfaceByLabel(const string &label)
return intf; return intf;
} }
} }
return NULL; return nullptr;
} }
@ -251,8 +251,8 @@ void PIXImporter::fixServiceObjectUsedForBothSrcAndDstPorts()
// named object/object group) // named object/object group)
if (src_port_spec.empty() || dst_port_spec.empty()) return; if (src_port_spec.empty() || dst_port_spec.empty()) return;
FWObject *src_port_obj = NULL; FWObject *src_port_obj = nullptr;
FWObject *dst_port_obj = NULL; FWObject *dst_port_obj = nullptr;
if (!src_port_spec.empty() && if (!src_port_spec.empty() &&
named_objects_registry.count(src_port_spec.c_str()) > 0) named_objects_registry.count(src_port_spec.c_str()) > 0)
@ -265,11 +265,11 @@ void PIXImporter::fixServiceObjectUsedForBothSrcAndDstPorts()
// if both src_port_obj and dst_port_obj are NULL, this means // if both src_port_obj and dst_port_obj are NULL, this means
// both port operations are in-line port matches that will be // both port operations are in-line port matches that will be
// taken are of in the base class functions // taken are of in the base class functions
if (src_port_obj == NULL && dst_port_obj == NULL) return; if (src_port_obj == nullptr && dst_port_obj == nullptr) return;
// If only one of the two is NULL, use base class functions to // If only one of the two is NULL, use base class functions to
// fill it in from its port_op and port_spec variables // fill it in from its port_op and port_spec variables
if (dst_port_obj == NULL) if (dst_port_obj == nullptr)
{ {
src_port_spec = ""; src_port_spec = "";
src_port_op = ""; src_port_op = "";
@ -278,7 +278,7 @@ void PIXImporter::fixServiceObjectUsedForBothSrcAndDstPorts()
else dst_port_obj = createUDPService(); else dst_port_obj = createUDPService();
} }
if (src_port_obj == NULL) if (src_port_obj == nullptr)
{ {
dst_port_spec = ""; dst_port_spec = "";
dst_port_op = ""; dst_port_op = "";
@ -307,7 +307,7 @@ void PIXImporter::mixServiceObjects(FWObject *src_ports,
FWObject *dst_ports, FWObject *dst_ports,
FWObject *service_group) FWObject *service_group)
{ {
if (Group::cast(src_ports)!=NULL) if (Group::cast(src_ports)!=nullptr)
{ {
for (FWObject::iterator i1=src_ports->begin(); i1!=src_ports->end(); ++i1) for (FWObject::iterator i1=src_ports->begin(); i1!=src_ports->end(); ++i1)
{ {
@ -317,7 +317,7 @@ void PIXImporter::mixServiceObjects(FWObject *src_ports,
return; return;
} }
if (Group::cast(dst_ports)!=NULL) if (Group::cast(dst_ports)!=nullptr)
{ {
for (FWObject::iterator i1=dst_ports->begin(); i1!=dst_ports->end(); ++i1) for (FWObject::iterator i1=dst_ports->begin(); i1!=dst_ports->end(); ++i1)
{ {
@ -354,10 +354,10 @@ void PIXImporter::mixServiceObjects(FWObject *src_ports,
FWObject* PIXImporter::mirrorServiceObjectRecursively(FWObject *obj) FWObject* PIXImporter::mirrorServiceObjectRecursively(FWObject *obj)
{ {
FWObject *res = NULL; FWObject *res = nullptr;
string new_name = obj->getName() + "-mirror"; string new_name = obj->getName() + "-mirror";
if (Service::cast(obj) != NULL) if (Service::cast(obj) != nullptr)
{ {
FWObject *new_obj = service_maker->getMirroredServiceObject(obj); FWObject *new_obj = service_maker->getMirroredServiceObject(obj);
if (new_obj) if (new_obj)
@ -477,7 +477,7 @@ void PIXImporter::pushRule()
else else
pushNATRule(); pushNATRule();
assert(current_rule!=NULL); assert(current_rule!=nullptr);
if (error_tracker->hasWarnings()) if (error_tracker->hasWarnings())
{ {
@ -502,7 +502,7 @@ void PIXImporter::pushRule()
markCurrentRuleBad(); markCurrentRuleBad();
} }
current_rule = NULL; current_rule = nullptr;
rule_comment = ""; rule_comment = "";
clear(); clear();
@ -511,8 +511,8 @@ void PIXImporter::pushRule()
void PIXImporter::pushPolicyRule() void PIXImporter::pushPolicyRule()
{ {
assert(current_ruleset!=NULL); assert(current_ruleset!=nullptr);
assert(current_rule!=NULL); assert(current_rule!=nullptr);
// populate all elements of the rule // populate all elements of the rule
addMessageToLog( addMessageToLog(
@ -523,7 +523,7 @@ void PIXImporter::pushPolicyRule()
PolicyRule *rule = PolicyRule::cast(current_rule); PolicyRule *rule = PolicyRule::cast(current_rule);
FWOptions *ropt = current_rule->getOptionsObject(); FWOptions *ropt = current_rule->getOptionsObject();
assert(ropt!=NULL); assert(ropt!=nullptr);
if (action=="permit") if (action=="permit")
{ {
@ -678,10 +678,10 @@ Firewall* PIXImporter::finalize()
rearrangeVlanInterfaces(); rearrangeVlanInterfaces();
FWObject *policy = getFirewallObject()->getFirstByType(Policy::TYPENAME); FWObject *policy = getFirewallObject()->getFirstByType(Policy::TYPENAME);
assert( policy!=NULL ); assert( policy!=nullptr );
FWObject *nat = getFirewallObject()->getFirstByType(NAT::TYPENAME); FWObject *nat = getFirewallObject()->getFirstByType(NAT::TYPENAME);
assert( nat!=NULL ); assert( nat!=nullptr );
if (all_rulesets.size()!=0) if (all_rulesets.size()!=0)
{ {
@ -816,7 +816,7 @@ Firewall* PIXImporter::finalize()
<< "dir: " << _dir.c_str(); << "dir: " << _dir.c_str();
// not all access lists are associated with interfaces // not all access lists are associated with interfaces
if (intf != NULL) if (intf != nullptr)
{ {
if (fwbdebug) if (fwbdebug)
qDebug() << " interface: " qDebug() << " interface: "
@ -867,7 +867,7 @@ Firewall* PIXImporter::finalize()
} }
else else
{ {
return NULL; return nullptr;
} }
} }
@ -1001,7 +1001,7 @@ void PIXImporter::setNamedObjectDescription(const std::string &txt)
{ {
named_object_comment = QString::fromUtf8(txt.c_str()); named_object_comment = QString::fromUtf8(txt.c_str());
if (current_named_object != NULL && ! named_object_name.isEmpty()) if (current_named_object != nullptr && ! named_object_name.isEmpty())
{ {
current_named_object->setBool(".import-commited", false); current_named_object->setBool(".import-commited", false);
current_named_object->setComment(""); current_named_object->setComment("");
@ -1089,7 +1089,7 @@ void PIXImporter::newObjectGroupICMP(const string &name)
void PIXImporter::setObjectGroupDescription(const std::string &descr) void PIXImporter::setObjectGroupDescription(const std::string &descr)
{ {
object_group_comment = QString::fromUtf8(descr.c_str()); object_group_comment = QString::fromUtf8(descr.c_str());
if (current_object_group != NULL && ! object_group_name.isEmpty()) if (current_object_group != nullptr && ! object_group_name.isEmpty())
{ {
current_object_group->setBool(".import-commited", false); current_object_group->setBool(".import-commited", false);
current_object_group->setComment(""); current_object_group->setComment("");
@ -1132,7 +1132,7 @@ void PIXImporter::addIPServiceToObjectGroup()
void PIXImporter::addTCPUDPServiceToObjectGroup() void PIXImporter::addTCPUDPServiceToObjectGroup()
{ {
FWObject *new_obj = NULL; FWObject *new_obj = nullptr;
if (protocol.empty() && ! object_group_service_protocol.isEmpty()) if (protocol.empty() && ! object_group_service_protocol.isEmpty())
protocol = object_group_service_protocol.toStdString(); protocol = object_group_service_protocol.toStdString();

View File

@ -118,7 +118,7 @@ int GetProtoByName::getProtocolByName(const QString &name)
if (protocols.contains(name)) return protocols[name]; if (protocols.contains(name)) return protocols[name];
struct protoent *pe = getprotobyname(name.toLatin1().constData()); struct protoent *pe = getprotobyname(name.toLatin1().constData());
if (pe!=NULL) if (pe!=nullptr)
return pe->p_proto; return pe->p_proto;
return -1; return -1;

View File

@ -684,7 +684,7 @@ int GetServByName::getPortByName(const QString &name, const QString &proto)
struct servent *se = getservbyname(name.toLatin1().constData(), struct servent *se = getservbyname(name.toLatin1().constData(),
proto.toLatin1().constData()); proto.toLatin1().constData());
if (se!=NULL) if (se!=nullptr)
{ {
int port = ntohs(se->s_port); int port = ntohs(se->s_port);
//free(se); //free(se);

View File

@ -79,7 +79,7 @@ void ObjectMakerErrorTracker::registerWarning(const string &msg)
void ObjectMaker::clear() void ObjectMaker::clear()
{ {
last_created = NULL; last_created = nullptr;
named_object_registry.clear(); named_object_registry.clear();
anon_object_registry.clear(); anon_object_registry.clear();
} }
@ -93,13 +93,13 @@ FWObject* ObjectMaker::findMatchingObject(const ObjectSignature &sig)
if (named_object_registry.count(sig_str) > 0) if (named_object_registry.count(sig_str) > 0)
return library->getRoot()->findInIndex( return library->getRoot()->findInIndex(
named_object_registry[sig_str]); named_object_registry[sig_str]);
return NULL; return nullptr;
} }
if (anon_object_registry.count(sig_str) > 0) if (anon_object_registry.count(sig_str) > 0)
return library->getRoot()->findInIndex(anon_object_registry[sig_str]); return library->getRoot()->findInIndex(anon_object_registry[sig_str]);
return NULL; return nullptr;
} }
void ObjectMaker::registerNamedObject(const ObjectSignature &sig, void ObjectMaker::registerNamedObject(const ObjectSignature &sig,
@ -110,7 +110,7 @@ void ObjectMaker::registerNamedObject(const ObjectSignature &sig,
QString as = anon_sig.toString(); QString as = anon_sig.toString();
if (anon_object_registry.count(as) > 0) anon_object_registry.remove(as); if (anon_object_registry.count(as) > 0) anon_object_registry.remove(as);
named_object_registry[sig.toString()] = (obj!=NULL) ? obj->getId() : -1; named_object_registry[sig.toString()] = (obj!=nullptr) ? obj->getId() : -1;
} }
void ObjectMaker::registerAnonymousObject(const ObjectSignature &sig, void ObjectMaker::registerAnonymousObject(const ObjectSignature &sig,
@ -118,7 +118,7 @@ void ObjectMaker::registerAnonymousObject(const ObjectSignature &sig,
{ {
ObjectSignature anon_sig = sig; ObjectSignature anon_sig = sig;
anon_sig.object_name = ""; anon_sig.object_name = "";
anon_object_registry[anon_sig.toString()] = (obj!=NULL) ? obj->getId() : -1; anon_object_registry[anon_sig.toString()] = (obj!=nullptr) ? obj->getId() : -1;
} }
/* /*
@ -140,14 +140,14 @@ FWObject* ObjectMaker::promoteToNamedObject(FWObject *obj,
new_obj->duplicate(obj); new_obj->duplicate(obj);
new_obj->setName(objName); new_obj->setName(objName);
ObjectSignature sig(error_tracker); ObjectSignature sig(error_tracker);
new_obj->dispatch(&sig, (void*)(NULL)); new_obj->dispatch(&sig, (void*)nullptr);
registerNamedObject(sig, new_obj); registerNamedObject(sig, new_obj);
return new_obj; return new_obj;
} else } else
{ {
obj->setName(objName); obj->setName(objName);
ObjectSignature sig(error_tracker); ObjectSignature sig(error_tracker);
obj->dispatch(&sig, (void*)(NULL)); obj->dispatch(&sig, (void*)nullptr);
registerNamedObject(sig, obj); registerNamedObject(sig, obj);
return obj; return obj;
} }
@ -158,7 +158,7 @@ FWObject* ObjectMaker::promoteToNamedObject(FWObject *obj,
FWObject* ObjectMaker::createObject(const std::string &objType, FWObject* ObjectMaker::createObject(const std::string &objType,
const std::string &objName) const std::string &objName)
{ {
assert(library!=NULL); assert(library!=nullptr);
FWBTree tree ; FWBTree tree ;
FWObject *slot = tree.getStandardSlotForObject(library,objType.c_str()); FWObject *slot = tree.getStandardSlotForObject(library,objType.c_str());
return createObject(slot, objType, objName); return createObject(slot, objType, objName);
@ -168,9 +168,9 @@ FWObject* ObjectMaker::createObject(FWObject *parent,
const std::string &objType, const std::string &objType,
const std::string &objName) const std::string &objName)
{ {
assert(library!=NULL); assert(library!=nullptr);
FWObject* o = library->getRoot()->create(objType); FWObject* o = library->getRoot()->create(objType);
if (parent != NULL) if (parent != nullptr)
{ {
if (parent->isReadOnly()) if (parent->isReadOnly())
{ {
@ -201,7 +201,7 @@ FWObject* ObjectMaker::createObject(FWObject *parent,
FWObject* ObjectMaker::createObject(ObjectSignature &) FWObject* ObjectMaker::createObject(ObjectSignature &)
{ {
return NULL; return nullptr;
} }
//**************************************************************** //****************************************************************
@ -230,7 +230,7 @@ void ObjectMaker::prepareForDeduplication(FWObject *root)
{ {
ObjectSignature sig(error_tracker); ObjectSignature sig(error_tracker);
root->dispatch(&sig, (void*)(NULL)); root->dispatch(&sig, (void*)nullptr);
registerNamedObject(sig, root); registerNamedObject(sig, root);
registerAnonymousObject(sig, root); // this erases sig.object_name registerAnonymousObject(sig, root); // this erases sig.object_name

View File

@ -65,7 +65,7 @@ using namespace libfwbuilder;
using namespace fwcompiler; using namespace fwcompiler;
FWObjectDatabase *objdb = NULL; FWObjectDatabase *objdb = nullptr;
class UpgradePredicate: public XMLTools::UpgradePredicate class UpgradePredicate: public XMLTools::UpgradePredicate
{ {

View File

@ -117,7 +117,7 @@ void expand_interface_with_phys_address(Compiler *compiler,
std::list<FWObject*> lipaddr; std::list<FWObject*> lipaddr;
std::list<FWObject*> lother; std::list<FWObject*> lother;
physAddress *pa = NULL; physAddress *pa = nullptr;
for (std::list<FWObject*>::iterator j=ol1.begin(); j!=ol1.end(); j++) for (std::list<FWObject*>::iterator j=ol1.begin(); j!=ol1.end(); j++)
{ {
@ -126,7 +126,7 @@ void expand_interface_with_phys_address(Compiler *compiler,
lipaddr.push_back(*j); lipaddr.push_back(*j);
continue; continue;
} }
if (physAddress::cast(*j)!=NULL) if (physAddress::cast(*j)!=nullptr)
{ {
pa = physAddress::cast(*j); pa = physAddress::cast(*j);
continue; continue;
@ -137,7 +137,7 @@ void expand_interface_with_phys_address(Compiler *compiler,
/* /*
* if pa==NULL then this is trivial case: there is no physical address * if pa==NULL then this is trivial case: there is no physical address
*/ */
if (pa==NULL) if (pa==nullptr)
{ {
list_result.insert(list_result.end(), ol1.begin(), ol1.end()); list_result.insert(list_result.end(), ol1.begin(), ol1.end());
return; return;
@ -163,10 +163,10 @@ void expand_interface_with_phys_address(Compiler *compiler,
*/ */
FWObject *p = Host::getParentHost(iface); FWObject *p = Host::getParentHost(iface);
//FWObject *p = iface->getParentHost(); //FWObject *p = iface->getParentHost();
assert(p!=NULL); assert(p!=nullptr);
FWOptions *hopt = Host::cast(p)->getOptionsObject(); FWOptions *hopt = Host::cast(p)->getOptionsObject();
bool use_mac = (hopt!=NULL && hopt->getBool("use_mac_addr_filter") ); bool use_mac = (hopt!=nullptr && hopt->getBool("use_mac_addr_filter") );
if (lipaddr.empty()) list_result.push_back(pa); if (lipaddr.empty()) list_result.push_back(pa);
else else

View File

@ -78,14 +78,14 @@ bool Address::isAny() const
const Address* Address::getAddressObject() const const Address* Address::getAddressObject() const
{ {
return NULL; return nullptr;
} }
const InetAddrMask* Address::getInetAddrMaskObjectPtr() const const InetAddrMask* Address::getInetAddrMaskObjectPtr() const
{ {
const Address *addr_obj = getAddressObject(); const Address *addr_obj = getAddressObject();
if (addr_obj) return addr_obj->inet_addr_mask; if (addr_obj) return addr_obj->inet_addr_mask;
return NULL; return nullptr;
} }
bool Address::hasInetAddress() const bool Address::hasInetAddress() const
@ -102,28 +102,28 @@ const InetAddr* Address::getAddressPtr() const
{ {
const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr(); const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr();
if (inet_addr_mask) return inet_addr_mask->getAddressPtr(); if (inet_addr_mask) return inet_addr_mask->getAddressPtr();
return NULL; return nullptr;
} }
const InetAddr* Address::getNetmaskPtr() const const InetAddr* Address::getNetmaskPtr() const
{ {
const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr(); const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr();
if (inet_addr_mask) return inet_addr_mask->getNetmaskPtr(); if (inet_addr_mask) return inet_addr_mask->getNetmaskPtr();
return NULL; return nullptr;
} }
const InetAddr* Address::getNetworkAddressPtr() const const InetAddr* Address::getNetworkAddressPtr() const
{ {
const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr(); const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr();
if (inet_addr_mask) return inet_addr_mask->getNetworkAddressPtr(); if (inet_addr_mask) return inet_addr_mask->getNetworkAddressPtr();
return NULL; return nullptr;
} }
const InetAddr* Address::getBroadcastAddressPtr() const const InetAddr* Address::getBroadcastAddressPtr() const
{ {
const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr(); const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr();
if (inet_addr_mask) return inet_addr_mask->getBroadcastAddressPtr(); if (inet_addr_mask) return inet_addr_mask->getBroadcastAddressPtr();
return NULL; return nullptr;
} }
void Address::setAddress(const InetAddr& a) void Address::setAddress(const InetAddr& a)
@ -147,20 +147,20 @@ void Address::setAddressNetmask(const std::string&)
unsigned int Address::dimension() const unsigned int Address::dimension() const
{ {
const InetAddrMask *addr_obj = getInetAddrMaskObjectPtr(); const InetAddrMask *addr_obj = getInetAddrMaskObjectPtr();
if (addr_obj!=NULL) return addr_obj->dimension(); if (addr_obj!=nullptr) return addr_obj->dimension();
return 1; return 1;
} }
bool Address::belongs(const InetAddr &other) const bool Address::belongs(const InetAddr &other) const
{ {
const InetAddrMask *addr_obj = getInetAddrMaskObjectPtr(); const InetAddrMask *addr_obj = getInetAddrMaskObjectPtr();
if (addr_obj!=NULL) return addr_obj->belongs(other); if (addr_obj!=nullptr) return addr_obj->belongs(other);
return false; return false;
} }
bool Address::cmp(const FWObject *obj, bool recursive) bool Address::cmp(const FWObject *obj, bool recursive)
{ {
if (Address::constcast(obj)==NULL) return false; if (Address::constcast(obj)==nullptr) return false;
if (!FWObject::cmp(obj, recursive)) return false; if (!FWObject::cmp(obj, recursive)) return false;
if (hasInetAddress()!=Address::constcast(obj)->hasInetAddress()) return false; if (hasInetAddress()!=Address::constcast(obj)->hasInetAddress()) return false;
if (!hasInetAddress()) return true; if (!hasInetAddress()) return true;

View File

@ -75,7 +75,7 @@ void AddressRange::setNetmask(const InetAddr& ) {}
FWObject& AddressRange::shallowDuplicate(const FWObject *o, bool preserve_id) FWObject& AddressRange::shallowDuplicate(const FWObject *o, bool preserve_id)
{ {
const AddressRange *n = dynamic_cast<const AddressRange *>(o); const AddressRange *n = dynamic_cast<const AddressRange *>(o);
if (n==NULL) { if (n==nullptr) {
std::ostringstream s; std::ostringstream s;
s << "Attempt to copy incompatible object to AddressRange: objectID="; s << "Attempt to copy incompatible object to AddressRange: objectID=";
@ -91,7 +91,7 @@ FWObject& AddressRange::shallowDuplicate(const FWObject *o, bool preserve_id)
bool AddressRange::cmp(const FWObject *obj, bool recursive) bool AddressRange::cmp(const FWObject *obj, bool recursive)
{ {
if (AddressRange::constcast(obj)==NULL) return false; if (AddressRange::constcast(obj)==nullptr) return false;
if (!FWObject::cmp(obj, recursive)) return false; if (!FWObject::cmp(obj, recursive)) return false;
InetAddr o1b; InetAddr o1b;
@ -113,12 +113,12 @@ void AddressRange::fromXML(xmlNodePtr root)
FWObject::fromXML(root); FWObject::fromXML(root);
const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("start_address"))); const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("start_address")));
assert(n!=NULL); assert(n!=nullptr);
start_address = InetAddr(AF_UNSPEC, n); start_address = InetAddr(AF_UNSPEC, n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("end_address"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("end_address")));
assert(n!=NULL); assert(n!=nullptr);
end_address = InetAddr(AF_UNSPEC, n); end_address = InetAddr(AF_UNSPEC, n);
FREEXMLBUFF(n); FREEXMLBUFF(n);

View File

@ -68,12 +68,12 @@ void AddressTable::fromXML(xmlNodePtr root)
const char *n; const char *n;
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("filename"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("filename")));
assert(n!=NULL); assert(n!=nullptr);
setStr("filename", n); setStr("filename", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("run_time"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("run_time")));
assert(n!=NULL); assert(n!=nullptr);
setStr("run_time", n); setStr("run_time", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
@ -156,7 +156,7 @@ void AddressTable::loadFromSource(bool ipv6, FWOptions *options,
} }
if (!buf.empty()) if (!buf.empty())
{ {
new_addr = NULL; new_addr = nullptr;
if (ipv6 && buf.find(":")!=string::npos) if (ipv6 && buf.find(":")!=string::npos)
{ {
try try

View File

@ -46,7 +46,7 @@ using namespace libfwbuilder;
BackgroundOp::BackgroundOp():running(false),connected(true) BackgroundOp::BackgroundOp():running(false),connected(true)
{ {
error = NULL; error = nullptr;
stop_program = new SyncFlag(false); stop_program = new SyncFlag(false);
iamdead = new SyncFlag(false); iamdead = new SyncFlag(false);
pthread_attr_init(&tattr); pthread_attr_init(&tattr);
@ -167,7 +167,7 @@ void *background_thread(void *args)
delete logger; delete logger;
delete isdead; delete isdead;
delete void_pair; delete void_pair;
return(NULL); return(nullptr);
} }
*logger << "Exception: " << ex.toString().c_str() << '\n'; *logger << "Exception: " << ex.toString().c_str() << '\n';
bop->error=new FWException(ex); bop->error=new FWException(ex);
@ -183,7 +183,7 @@ void *background_thread(void *args)
delete logger; delete logger;
delete isdead; delete isdead;
delete void_pair; delete void_pair;
return(NULL); return(nullptr);
} }
/* operation completed - clear "running" flag */ /* operation completed - clear "running" flag */
@ -213,7 +213,7 @@ void *background_thread(void *args)
delete logger; delete logger;
delete void_pair; delete void_pair;
return(NULL); return(nullptr);
} }
} }

View File

@ -60,7 +60,7 @@ void Cluster::init(FWObjectDatabase *root)
Firewall::init(root); Firewall::init(root);
// create one conntrack member group // create one conntrack member group
FWObject *state_sync_members = getFirstByType(StateSyncClusterGroup::TYPENAME); FWObject *state_sync_members = getFirstByType(StateSyncClusterGroup::TYPENAME);
if (state_sync_members == NULL) if (state_sync_members == nullptr)
{ {
state_sync_members = root->create(StateSyncClusterGroup::TYPENAME); state_sync_members = root->create(StateSyncClusterGroup::TYPENAME);
state_sync_members->setName("State Sync Group"); state_sync_members->setName("State Sync Group");
@ -115,7 +115,7 @@ ClusterGroup* Cluster::getStateSyncGroupObject()
StateSyncClusterGroup *group = StateSyncClusterGroup::cast( StateSyncClusterGroup *group = StateSyncClusterGroup::cast(
getFirstByType(StateSyncClusterGroup::TYPENAME)); getFirstByType(StateSyncClusterGroup::TYPENAME));
if (group == NULL) if (group == nullptr)
{ {
// create a new ClusterGroup object // create a new ClusterGroup object
group = StateSyncClusterGroup::cast(getRoot()->create( group = StateSyncClusterGroup::cast(getRoot()->create(
@ -159,12 +159,12 @@ FWObject& Cluster::duplicate(const FWObject *obj,
void Cluster::updateLastInstalledTimestamp() void Cluster::updateLastInstalledTimestamp()
{ {
setInt("lastInstalled", time(NULL)); setInt("lastInstalled", time(nullptr));
} }
void Cluster::updateLastModifiedTimestamp() void Cluster::updateLastModifiedTimestamp()
{ {
setInt("lastModified", time(NULL)); setInt("lastModified", time(nullptr));
} }
bool Cluster::needsInstall() bool Cluster::needsInstall()
@ -199,7 +199,7 @@ time_t Cluster::getLastCompiled()
void Cluster::updateLastCompiledTimestamp() void Cluster::updateLastCompiledTimestamp()
{ {
setInt("lastCompiled", time(NULL)); setInt("lastCompiled", time(nullptr));
} }
bool Cluster::getInactive() bool Cluster::getInactive()
@ -250,7 +250,7 @@ void Cluster::getMembersList(list<libfwbuilder::Firewall*> &members)
{ {
FWObject *member = FWReference::getObject(*j); FWObject *member = FWReference::getObject(*j);
if (ClusterGroupOptions::isA(member)) continue; if (ClusterGroupOptions::isA(member)) continue;
Firewall *fw = NULL; Firewall *fw = nullptr;
// as of 05/04 members of StateSyncClusterGroup are interfaces. See // as of 05/04 members of StateSyncClusterGroup are interfaces. See
// tickets #10 and #11 // tickets #10 and #11
if (Interface::cast(member)) if (Interface::cast(member))
@ -284,7 +284,7 @@ bool Cluster::hasMember(Firewall *fw)
{ {
FWObject *member = FWReference::getObject(*j); FWObject *member = FWReference::getObject(*j);
if (ClusterGroupOptions::isA(member)) continue; if (ClusterGroupOptions::isA(member)) continue;
Firewall *member_fw = NULL; Firewall *member_fw = nullptr;
// as of 05/04/2009 members of StateSyncClusterGroup are // as of 05/04/2009 members of StateSyncClusterGroup are
// interfaces. See tickets #10 and #11 // interfaces. See tickets #10 and #11
if (Interface::cast(member)) if (Interface::cast(member))

View File

@ -35,7 +35,7 @@ ClusterGroup::ClusterGroup() : ObjectGroup()
void ClusterGroup::init(FWObjectDatabase *root) void ClusterGroup::init(FWObjectDatabase *root)
{ {
FWObject *gopt = getFirstByType(ClusterGroupOptions::TYPENAME); FWObject *gopt = getFirstByType(ClusterGroupOptions::TYPENAME);
if (gopt == NULL) if (gopt == nullptr)
{ {
gopt = root->create(ClusterGroupOptions::TYPENAME); gopt = root->create(ClusterGroupOptions::TYPENAME);
add(gopt); add(gopt);
@ -76,13 +76,13 @@ void ClusterGroup::fromXML(xmlNodePtr parent)
const char *n; const char *n;
n = FROMXMLCAST(xmlGetProp(parent, TOXMLCAST("type"))); n = FROMXMLCAST(xmlGetProp(parent, TOXMLCAST("type")));
if (n != NULL) if (n != nullptr)
{ {
setStr("type", n); setStr("type", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n = FROMXMLCAST(xmlGetProp(parent, TOXMLCAST("master_iface"))); n = FROMXMLCAST(xmlGetProp(parent, TOXMLCAST("master_iface")));
if (n != NULL) if (n != nullptr)
{ {
setStr("master_iface", n); setStr("master_iface", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
@ -116,7 +116,7 @@ ClusterGroupOptions* ClusterGroup::getOptionsObject()
ClusterGroupOptions *gopt = ClusterGroupOptions::cast( ClusterGroupOptions *gopt = ClusterGroupOptions::cast(
getFirstByType(ClusterGroupOptions::TYPENAME)); getFirstByType(ClusterGroupOptions::TYPENAME));
if (gopt == NULL) if (gopt == nullptr)
{ {
gopt = ClusterGroupOptions::cast( gopt = ClusterGroupOptions::cast(
getRoot()->create(ClusterGroupOptions::TYPENAME)); getRoot()->create(ClusterGroupOptions::TYPENAME));
@ -127,7 +127,7 @@ ClusterGroupOptions* ClusterGroup::getOptionsObject()
FWObject& ClusterGroup::duplicateForUndo(const FWObject *obj) FWObject& ClusterGroup::duplicateForUndo(const FWObject *obj)
{ {
if (ClusterGroup::constcast(obj)==NULL) return *this; if (ClusterGroup::constcast(obj)==nullptr) return *this;
setRO(false); setRO(false);
@ -152,7 +152,7 @@ FWObject& ClusterGroup::duplicateForUndo(const FWObject *obj)
} }
} }
if (their_opts && mine_opts) mine_opts->duplicate(their_opts); if (their_opts && mine_opts) mine_opts->duplicate(their_opts);
if (their_opts && mine_opts==NULL) addCopyOf(their_opts); if (their_opts && mine_opts==nullptr) addCopyOf(their_opts);
shallowDuplicate(obj); shallowDuplicate(obj);
return *this; return *this;
@ -182,6 +182,6 @@ Interface* ClusterGroup::getInterfaceForMemberFirewall(Firewall *fw)
if (other_iface->isChildOf(fw)) return other_iface; if (other_iface->isChildOf(fw)) return other_iface;
} }
return NULL; return nullptr;
} }

View File

@ -106,7 +106,7 @@ void CustomService::fromXML(xmlNodePtr root)
if (cur && !xmlIsBlankNode(cur)) if (cur && !xmlIsBlankNode(cur))
{ {
n = FROMXMLCAST(xmlGetProp(cur,TOXMLCAST("platform"))); n = FROMXMLCAST(xmlGetProp(cur,TOXMLCAST("platform")));
assert(n!=NULL); assert(n!=nullptr);
cont = FROMXMLCAST( xmlNodeGetContent(cur) ); cont = FROMXMLCAST( xmlNodeGetContent(cur) );
if (cont) if (cont)
{ {
@ -138,8 +138,8 @@ xmlNodePtr CustomService::toXML(xmlNodePtr parent)
{ {
const string &platform = (*i).first; const string &platform = (*i).first;
const string &code = (*i).second; const string &code = (*i).second;
xmlChar *codebuf = xmlEncodeSpecialChars(NULL, STRTOXMLCAST(code) ); xmlChar *codebuf = xmlEncodeSpecialChars(nullptr, STRTOXMLCAST(code) );
opt=xmlNewChild(me,NULL,TOXMLCAST("CustomServiceCommand"), codebuf); opt=xmlNewChild(me,nullptr,TOXMLCAST("CustomServiceCommand"), codebuf);
FREEXMLBUFF(codebuf); FREEXMLBUFF(codebuf);
xmlNewProp(opt, TOXMLCAST("platform") , STRTOXMLCAST(platform)); xmlNewProp(opt, TOXMLCAST("platform") , STRTOXMLCAST(platform));
@ -149,7 +149,7 @@ xmlNodePtr CustomService::toXML(xmlNodePtr parent)
bool CustomService::cmp(const FWObject *obj, bool recursive) bool CustomService::cmp(const FWObject *obj, bool recursive)
{ {
if (CustomService::constcast(obj)==NULL) return false; if (CustomService::constcast(obj)==nullptr) return false;
if (!FWObject::cmp(obj, recursive)) return false; if (!FWObject::cmp(obj, recursive)) return false;
const CustomService *o2 = CustomService::constcast(obj); const CustomService *o2 = CustomService::constcast(obj);

View File

@ -76,12 +76,12 @@ void DNSName::fromXML(xmlNodePtr root)
const char *n; const char *n;
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dnsrec"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dnsrec")));
assert(n!=NULL); assert(n!=nullptr);
setStr("dnsrec", n); setStr("dnsrec", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dnsrectype"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dnsrectype")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("dnsrectype", n); setStr("dnsrectype", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
@ -91,7 +91,7 @@ void DNSName::fromXML(xmlNodePtr root)
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("run_time"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("run_time")));
assert(n!=NULL); assert(n!=nullptr);
setStr("run_time", n); setStr("run_time", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
@ -132,7 +132,7 @@ void DNSName::loadFromSource(bool ipv6, FWOptions *options,
//Address *a = Address::cast( //Address *a = Address::cast(
// getRoot()->create((ipv6)?IPv6::TYPENAME:IPv4::TYPENAME)); // getRoot()->create((ipv6)?IPv6::TYPENAME:IPv4::TYPENAME));
int af = AF_INET; int af = AF_INET;
Address *a = NULL; Address *a = nullptr;
if (ipv6) { a = getRoot()->createIPv6(); af = AF_INET6; } if (ipv6) { a = getRoot()->createIPv6(); af = AF_INET6; }
else a = getRoot()->createIPv4(); else a = getRoot()->createIPv4();
getRoot()->add(a); getRoot()->add(a);
@ -161,7 +161,7 @@ void DNSName::loadFromSource(bool ipv6, FWOptions *options,
{ {
err << " Using dummy address in test mode"; err << " Using dummy address in test mode";
int af = AF_INET; int af = AF_INET;
Address *a = NULL; Address *a = nullptr;
if (ipv6) if (ipv6)
{ {
a = getRoot()->createIPv6(); a = getRoot()->createIPv6();

View File

@ -45,7 +45,7 @@ DynamicGroup::~DynamicGroup() {}
bool DynamicGroup::validateChild(FWObject *o) bool DynamicGroup::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
return FWObject::validateChild(o); return FWObject::validateChild(o);
} }
@ -55,7 +55,7 @@ void DynamicGroup::fromXML(xmlNodePtr root)
FWObject::fromXML(root); FWObject::fromXML(root);
for (xmlNodePtr child = root->xmlChildrenNode; for (xmlNodePtr child = root->xmlChildrenNode;
child != 0; child = child->next) { child != nullptr; child = child->next) {
if (child->type != XML_ELEMENT_NODE) continue; if (child->type != XML_ELEMENT_NODE) continue;
assert(strcmp(FROMXMLCAST(child->name), "SelectionCriteria") == 0); assert(strcmp(FROMXMLCAST(child->name), "SelectionCriteria") == 0);
@ -87,8 +87,8 @@ xmlNodePtr DynamicGroup::toXML(xmlNodePtr parent)
if (!splitFilter(*iter, type, keyword)) continue; if (!splitFilter(*iter, type, keyword)) continue;
if (!makeFilter(filter, type, keyword)) continue; if (!makeFilter(filter, type, keyword)) continue;
xmlNodePtr item = xmlNewChild(me, NULL, xmlNodePtr item = xmlNewChild(me, nullptr,
TOXMLCAST("SelectionCriteria"), NULL); TOXMLCAST("SelectionCriteria"), nullptr);
xmlNewProp(item, TOXMLCAST("type"), STRTOXMLCAST(type)); xmlNewProp(item, TOXMLCAST("type"), STRTOXMLCAST(type));
xmlNewProp(item, TOXMLCAST("keyword"), STRTOXMLCAST(keyword)); xmlNewProp(item, TOXMLCAST("keyword"), STRTOXMLCAST(keyword));
} }
@ -164,22 +164,22 @@ void DynamicGroup::loadFromSource(bool ipv6, FWOptions *options, bool test_mode)
static bool isInDeletedObjs(FWObject *obj) static bool isInDeletedObjs(FWObject *obj)
{ {
FWObject *lib = obj->getLibrary(); FWObject *lib = obj->getLibrary();
return lib == 0 || lib->getId() == FWObjectDatabase::DELETED_OBJECTS_ID; return lib == nullptr || lib->getId() == FWObjectDatabase::DELETED_OBJECTS_ID;
} }
bool DynamicGroup::isMemberOfGroup(FWObject *obj) bool DynamicGroup::isMemberOfGroup(FWObject *obj)
{ {
if (obj == this) return false; if (obj == this) return false;
if (ObjectGroup::cast(obj) == 0 && Address::cast(obj) == 0) return false; if (ObjectGroup::cast(obj) == nullptr && Address::cast(obj) == nullptr) return false;
if (RuleElement::cast(obj) != 0) return false; if (RuleElement::cast(obj) != nullptr) return false;
if (isInDeletedObjs(obj)) return false; if (isInDeletedObjs(obj)) return false;
/* There's no way to figure out what are the "standard" object /* There's no way to figure out what are the "standard" object
groups (like "address tables") from within the fwbuilder groups (like "address tables") from within the fwbuilder
library, so we rely on counting how deep we are in the tree library, so we rely on counting how deep we are in the tree
instead. */ instead. */
if (ObjectGroup::cast(obj) != 0 && if (ObjectGroup::cast(obj) != nullptr &&
obj->getDistanceFromRoot() <= 3) return false; obj->getDistanceFromRoot() <= 3) return false;
const set<string> &keywords = obj->getKeywords(); const set<string> &keywords = obj->getKeywords();

View File

@ -67,7 +67,7 @@ string FWObject::dataDir;
void FWObject::fromXML(xmlNodePtr root) void FWObject::fromXML(xmlNodePtr root)
{ {
assert(root!=NULL); assert(root!=nullptr);
const char *n; const char *n;
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("name"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("name")));
@ -92,20 +92,20 @@ void FWObject::fromXML(xmlNodePtr root)
} }
n = FROMXMLCAST(xmlGetProp(root, TOXMLCAST("keywords"))); n = FROMXMLCAST(xmlGetProp(root, TOXMLCAST("keywords")));
if (n != 0) { if (n != nullptr) {
keywords = stringToSet(n); keywords = stringToSet(n);
dbroot->keywords.insert(keywords.begin(), keywords.end()); dbroot->keywords.insert(keywords.begin(), keywords.end());
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n = FROMXMLCAST(xmlGetProp(root, TOXMLCAST("subfolders"))); n = FROMXMLCAST(xmlGetProp(root, TOXMLCAST("subfolders")));
if (n != 0) { if (n != nullptr) {
setStr("subfolders", n); setStr("subfolders", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n = FROMXMLCAST(xmlGetProp(root, TOXMLCAST("folder"))); n = FROMXMLCAST(xmlGetProp(root, TOXMLCAST("folder")));
if (n != 0) { if (n != nullptr) {
setStr("folder", n); setStr("folder", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
@ -125,7 +125,7 @@ void FWObject::fromXML(xmlNodePtr root)
if (cur && !xmlIsBlankNode(cur)) if (cur && !xmlIsBlankNode(cur))
{ {
FWObject *o = dbr->createFromXML(cur); FWObject *o = dbr->createFromXML(cur);
if (o!=NULL) if (o!=nullptr)
{ {
/* Add w/o validation. Trust XML to do that */ /* Add w/o validation. Trust XML to do that */
add(o, false); add(o, false);
@ -157,9 +157,9 @@ xmlNodePtr FWObject::toXML(xmlNodePtr parent, bool process_children)
xmlNodePtr me = xmlNewChild( xmlNodePtr me = xmlNewChild(
parent, parent,
NULL, nullptr,
xml_name.empty() ? STRTOXMLCAST(getTypeName()) : STRTOXMLCAST(xml_name), xml_name.empty() ? STRTOXMLCAST(getTypeName()) : STRTOXMLCAST(xml_name),
NULL); nullptr);
if (id!=-1) if (id!=-1)
{ {
@ -199,8 +199,8 @@ FWObject::FWObject()
{ {
busy = false; busy = false;
ref_counter = 0; ref_counter = 0;
parent = NULL; parent = nullptr;
dbroot = NULL; dbroot = nullptr;
name = ""; name = "";
comment = ""; comment = "";
id = -1; id = -1;
@ -217,8 +217,8 @@ FWObject::FWObject(bool new_id)
{ {
busy = false; busy = false;
ref_counter = 0; ref_counter = 0;
parent = NULL; parent = nullptr;
dbroot = NULL; dbroot = nullptr;
name = ""; name = "";
comment = ""; comment = "";
id = -1; id = -1;
@ -261,7 +261,7 @@ void* FWObject::getPrivateData(const string &key) const
{ {
map<string, void*>::const_iterator it = private_data.find(key); map<string, void*>::const_iterator it = private_data.find(key);
if(it == private_data.end()) if(it == private_data.end())
return NULL; return nullptr;
else else
return it->second; return it->second;
} }
@ -323,7 +323,7 @@ FWObject* FWObject::findObjectByName(const string &type,
if(o) return o; if(o) return o;
} }
return NULL; // not found return nullptr; // not found
} }
FWObject* FWObject::findObjectByAttribute(const std::string &attr, FWObject* FWObject::findObjectByAttribute(const std::string &attr,
@ -340,7 +340,7 @@ FWObject* FWObject::findObjectByAttribute(const std::string &attr,
if(o) return o; if(o) return o;
} }
return NULL; // not found return nullptr; // not found
} }
@ -425,10 +425,10 @@ FWObject& FWObject::duplicate(const FWObject *x, bool preserve_id)
FWObject* FWObject::addCopyOf(const FWObject *x, bool preserve_id) FWObject* FWObject::addCopyOf(const FWObject *x, bool preserve_id)
{ {
if (x==NULL) return NULL; if (x==nullptr) return nullptr;
FWObject *o1; FWObject *o1;
FWObjectDatabase *root = getRoot(); FWObjectDatabase *root = getRoot();
if (root==NULL) root = x->getRoot(); if (root==nullptr) root = x->getRoot();
// do not prepopulte children for objects that do that automatically // do not prepopulte children for objects that do that automatically
// in their constructor // in their constructor
o1 = root->create(x->getTypeName(), -1); o1 = root->create(x->getTypeName(), -1);
@ -485,8 +485,8 @@ FWObject& FWObject::shallowDuplicate(const FWObject *x, bool preserve_id)
setId(old_id); setId(old_id);
} }
if (dbroot==NULL) setRoot(x->getRoot()); if (dbroot==nullptr) setRoot(x->getRoot());
if (dbroot!=NULL) dbroot->addToIndex(this); if (dbroot!=nullptr) dbroot->addToIndex(this);
setReadOnly(x->ro); setReadOnly(x->ro);
setDirty(true); setDirty(true);
@ -499,7 +499,7 @@ class InheritsFWOptions: public std::unary_function<FWObject*, bool>
InheritsFWOptions() {} InheritsFWOptions() {}
bool operator()(const FWObject *o) const bool operator()(const FWObject *o) const
{ {
return FWOptions::constcast(o)!=NULL; return FWOptions::constcast(o)!=nullptr;
} }
}; };
@ -540,7 +540,7 @@ const string& FWObject::getLibraryName() const
FWObject* FWObject::getLibrary() const FWObject* FWObject::getLibrary() const
{ {
const FWObject *p=this; const FWObject *p=this;
while (p!=NULL && !Library::isA(p) ) p=p->getParent(); while (p!=nullptr && !Library::isA(p) ) p=p->getParent();
return (FWObject*)p; return (FWObject*)p;
} }
@ -552,7 +552,7 @@ FWObjectDatabase* FWObject::getRoot() const
int FWObject::getDistanceFromRoot() const int FWObject::getDistanceFromRoot() const
{ {
int count = 0; int count = 0;
for (FWObject *obj = getParent(); obj != 0; obj = obj->getParent()) { for (FWObject *obj = getParent(); obj != nullptr; obj = obj->getParent()) {
count++; count++;
} }
return count; return count;
@ -572,9 +572,9 @@ string FWObject::getPath(bool relative, bool detailed) const
list<string> res; list<string> res;
const FWObject *p = this; const FWObject *p = this;
if (p == NULL) res.push_front("(0x0)"); if (p == nullptr) res.push_front("(0x0)");
while (p!=NULL) while (p!=nullptr)
{ {
if (relative && Library::isA(p)) break; if (relative && Library::isA(p)) break;
ostringstream s; ostringstream s;
@ -620,7 +620,7 @@ void FWObject::setId(int c)
{ {
id = c; id = c;
setDirty(true); setDirty(true);
if (dbroot!=NULL) dbroot->addToIndex(this); if (dbroot!=nullptr) dbroot->addToIndex(this);
} }
} }
@ -749,7 +749,7 @@ void FWObject::dump(std::ostream &f,bool recursive,bool brief,int offset) const
{ {
list<FWObject*>::const_iterator m; list<FWObject*>::const_iterator m;
for (m=begin(); m!=end(); ++m) { for (m=begin(); m!=end(); ++m) {
if ( (o=(*m))!=NULL) o->dump(f,recursive,brief,offset+2); if ( (o=(*m))!=nullptr) o->dump(f,recursive,brief,offset+2);
} }
} }
} else } else
@ -764,7 +764,7 @@ void FWObject::dump(std::ostream &f,bool recursive,bool brief,int offset) const
f << string(offset,' ') << "Type: " << getTypeName() << endl; f << string(offset,' ') << "Type: " << getTypeName() << endl;
f << string(offset,' ') << "Library:" << getLibrary() << endl; f << string(offset,' ') << "Library:" << getLibrary() << endl;
// f << string(offset,' ') << "Path: " << getPath() << endl; // f << string(offset,' ') << "Path: " << getPath() << endl;
n=(getParent()!=NULL)?getParent()->getName():""; n=(getParent()!=nullptr)?getParent()->getName():"";
f << string(offset,' ') << "Parent: " << getParent() f << string(offset,' ') << "Parent: " << getParent()
<< " name=" << n << endl; << " name=" << n << endl;
f << string(offset,' ') << "Root: " << getRoot() << endl; f << string(offset,' ') << "Root: " << getRoot() << endl;
@ -780,7 +780,7 @@ void FWObject::dump(std::ostream &f,bool recursive,bool brief,int offset) const
list<FWObject*>::const_iterator m; list<FWObject*>::const_iterator m;
for (m=begin(); m!=end(); ++m) for (m=begin(); m!=end(); ++m)
{ {
if ( (o=(*m))!=NULL) o->dump(f,recursive,brief,offset+2); if ( (o=(*m))!=nullptr) o->dump(f,recursive,brief,offset+2);
} }
} }
} }
@ -807,7 +807,7 @@ void FWObject::_adopt(FWObject *obj)
void FWObject::addAt(int where_id, FWObject *obj) void FWObject::addAt(int where_id, FWObject *obj)
{ {
FWObject *p = getRoot()->findInIndex( where_id ); FWObject *p = getRoot()->findInIndex( where_id );
assert (p!=NULL); assert (p!=nullptr);
p->add(obj); p->add(obj);
} }
@ -816,7 +816,7 @@ void FWObject::add(FWObject *obj, bool validate)
checkReadOnly(); checkReadOnly();
FWObject *old_parent = obj->getParent(); FWObject *old_parent = obj->getParent();
if (old_parent != NULL) if (old_parent != nullptr)
{ {
cerr << "WARNING: object " << obj << " " cerr << "WARNING: object " << obj << " "
<< "(name: " << obj->getName() << "(name: " << obj->getName()
@ -829,7 +829,7 @@ void FWObject::add(FWObject *obj, bool validate)
<< " type: " << getTypeName() << ") " << " type: " << getTypeName() << ") "
<< endl; << endl;
assert(old_parent == NULL); assert(old_parent == nullptr);
} }
// do not allow to add the same object twice // do not allow to add the same object twice
@ -858,7 +858,7 @@ void FWObject::add(FWObject *obj, bool validate)
void FWObject::reparent(FWObject *obj, bool validate) void FWObject::reparent(FWObject *obj, bool validate)
{ {
FWObject *old_parent = obj->getParent(); FWObject *old_parent = obj->getParent();
if (old_parent != NULL && old_parent != this) if (old_parent != nullptr && old_parent != this)
{ {
old_parent->remove(obj, false); old_parent->remove(obj, false);
add(obj, validate); add(obj, validate);
@ -896,8 +896,8 @@ void FWObject::insert_before(FWObject *o1, FWObject *obj)
{ {
checkReadOnly(); checkReadOnly();
if (obj == NULL) return; if (obj == nullptr) return;
if (o1 == NULL) if (o1 == nullptr)
{ {
insert(begin(), obj); insert(begin(), obj);
_adopt(obj); _adopt(obj);
@ -918,7 +918,7 @@ void FWObject::insert_after(FWObject *o1, FWObject *obj)
{ {
checkReadOnly(); checkReadOnly();
if (obj == NULL) return; if (obj == nullptr) return;
list<FWObject*>::iterator m = find(begin(), end(), o1); list<FWObject*>::iterator m = find(begin(), end(), o1);
if (m != end()) if (m != end())
@ -964,7 +964,7 @@ void FWObject::remove(FWObject *obj, bool delete_if_last)
delete obj; delete obj;
} }
obj->parent = NULL; obj->parent = nullptr;
} }
} }
@ -1130,7 +1130,7 @@ bool FWObject::verifyTree()
FWObject *o_parent = o->getParent(); FWObject *o_parent = o->getParent();
if (o_parent != this) if (o_parent != this)
{ {
if (o_parent != NULL) if (o_parent != nullptr)
{ {
cerr << "WARNING: Object " << o << " (name: '" << o->getName() cerr << "WARNING: Object " << o << " (name: '" << o->getName()
<< "' type: " << o->getTypeName() << ")" << "' type: " << o->getTypeName() << ")"
@ -1264,7 +1264,7 @@ bool FWObject::isChildOf(FWObject *obj)
cerr << endl; cerr << endl;
#endif #endif
FWObject *p=this; FWObject *p=this;
while (p!=NULL && p!=obj) p=p->getParent(); while (p!=nullptr && p!=obj) p=p->getParent();
return (p==obj); return (p==obj);
} }
@ -1289,9 +1289,9 @@ FWObject* FWObject::getById (int id, bool recursive)
int oid = o->getId(); int oid = o->getId();
if(id==oid) return o; if(id==oid) return o;
if(recursive && (o=o->getById(id, true))!=NULL ) return o; if(recursive && (o=o->getById(id, true))!=nullptr ) return o;
} }
return NULL; // not found return nullptr; // not found
} }
FWObject* FWObject::getFirstByType(const string &type_name) const FWObject* FWObject::getFirstByType(const string &type_name) const
@ -1335,7 +1335,7 @@ FWObjectTypedChildIterator FWObject::findByType(const std::string &type_name) co
void FWObject::setDirty(bool f) void FWObject::setDirty(bool f)
{ {
FWObjectDatabase *dbr = getRoot(); FWObjectDatabase *dbr = getRoot();
if (dbr==NULL) return; if (dbr==nullptr) return;
if (dbr==this) dirty = f; if (dbr==this) dirty = f;
else dbr->dirty = f; else dbr->dirty = f;
} }
@ -1343,7 +1343,7 @@ void FWObject::setDirty(bool f)
bool FWObject::isDirty() bool FWObject::isDirty()
{ {
FWObjectDatabase *dbr = getRoot(); FWObjectDatabase *dbr = getRoot();
if (dbr==NULL) return false; if (dbr==nullptr) return false;
return (dbr->dirty); return (dbr->dirty);
} }
@ -1376,7 +1376,7 @@ void FWObject::setReadOnly(bool f)
bool FWObject::isReadOnly() bool FWObject::isReadOnly()
{ {
FWObjectDatabase *dbr = getRoot(); FWObjectDatabase *dbr = getRoot();
if (dbr==NULL || dbr->busy) return false; if (dbr==nullptr || dbr->busy) return false;
FWObject *p=this; FWObject *p=this;
while (p) while (p)
{ {
@ -1504,7 +1504,7 @@ FWObject::tree_iterator& FWObject::tree_iterator::operator++()
} }
FWObject *p = node; FWObject *p = node;
while (node->getParent()!=NULL) while (node->getParent()!=nullptr)
{ {
p = node->getParent(); p = node->getParent();
@ -1591,7 +1591,7 @@ void FWObject::replaceReferenceInternal(int old_id, int new_id, int &counter)
if (old_id == new_id) return; if (old_id == new_id) return;
FWReference *ref = FWReference::cast(this); FWReference *ref = FWReference::cast(this);
if (ref==NULL) if (ref==nullptr)
{ {
for (FWObject::iterator j1=begin(); j1!=end(); ++j1) for (FWObject::iterator j1=begin(); j1!=end(); ++j1)
(*j1)->replaceReferenceInternal(old_id, new_id, counter); (*j1)->replaceReferenceInternal(old_id, new_id, counter);
@ -1607,7 +1607,7 @@ void FWObject::replaceReferenceInternal(int old_id, int new_id, int &counter)
void FWObject::findDependencies(list<FWObject*> &deps) void FWObject::findDependencies(list<FWObject*> &deps)
{ {
int loop_id = time(NULL); int loop_id = time(nullptr);
_findDependencies_internal(this, deps, loop_id); _findDependencies_internal(this, deps, loop_id);
} }
@ -1615,9 +1615,9 @@ void FWObject::_findDependencies_internal(FWObject *obj,
list<FWObject*> &deps, list<FWObject*> &deps,
int anti_loop_id) int anti_loop_id)
{ {
if (obj==NULL) return; if (obj==nullptr) return;
if (FWOptions::cast(obj)) return; if (FWOptions::cast(obj)) return;
if (FWReference::cast(obj)!=NULL) if (FWReference::cast(obj)!=nullptr)
{ {
_findDependencies_internal(FWReference::cast(obj)->getPointer(), _findDependencies_internal(FWReference::cast(obj)->getPointer(),
deps, anti_loop_id); deps, anti_loop_id);

View File

@ -55,7 +55,7 @@ void FWOptions::fromXML(xmlNodePtr root)
if (cur && !xmlIsBlankNode(cur)) if (cur && !xmlIsBlankNode(cur))
{ {
n = FROMXMLCAST(xmlGetProp(cur,TOXMLCAST("name"))); n = FROMXMLCAST(xmlGetProp(cur,TOXMLCAST("name")));
assert(n!=NULL); assert(n!=nullptr);
cont = FROMXMLCAST( xmlNodeGetContent(cur) ); cont = FROMXMLCAST( xmlNodeGetContent(cur) );
if (cont) if (cont)
{ {
@ -72,9 +72,9 @@ xmlNodePtr FWOptions::toXML(xmlNodePtr root)
xmlNodePtr opt; xmlNodePtr opt;
xmlNodePtr me = xmlNewChild( xmlNodePtr me = xmlNewChild(
root, NULL, root, nullptr,
xml_name.empty() ? STRTOXMLCAST(getTypeName()) : STRTOXMLCAST(xml_name), xml_name.empty() ? STRTOXMLCAST(getTypeName()) : STRTOXMLCAST(xml_name),
NULL); nullptr);
for(map<string, string>::const_iterator i=data.begin(); i!=data.end(); ++i) for(map<string, string>::const_iterator i=data.begin(); i!=data.end(); ++i)
{ {
@ -87,7 +87,7 @@ xmlNodePtr FWOptions::toXML(xmlNodePtr root)
STRTOXMLCAST(value) ); STRTOXMLCAST(value) );
// xmlChar *valbuf = xmlEncodeEntitiesReentrant(root->doc, // xmlChar *valbuf = xmlEncodeEntitiesReentrant(root->doc,
// STRTOXMLCAST(value) ); // STRTOXMLCAST(value) );
opt = xmlNewChild(me, NULL, TOXMLCAST("Option"), valbuf); opt = xmlNewChild(me, nullptr, TOXMLCAST("Option"), valbuf);
FREEXMLBUFF(valbuf); FREEXMLBUFF(valbuf);
xmlNewProp(opt, TOXMLCAST("name") , STRTOXMLCAST(name)); xmlNewProp(opt, TOXMLCAST("name") , STRTOXMLCAST(name));

View File

@ -48,7 +48,7 @@ FWReference::FWReference(FWObject *p)
FWReference::FWReference() FWReference::FWReference()
{ {
setPointer(NULL); setPointer(nullptr);
} }
FWReference::~FWReference() {} FWReference::~FWReference() {}
@ -56,11 +56,11 @@ FWReference::~FWReference() {}
void FWReference::fromXML(xmlNodePtr root) void FWReference::fromXML(xmlNodePtr root)
{ {
assert(root!=NULL); assert(root!=nullptr);
FWObject::fromXML(root); FWObject::fromXML(root);
const char *n = FROMXMLCAST(xmlGetProp(root, TOXMLCAST("ref"))); const char *n = FROMXMLCAST(xmlGetProp(root, TOXMLCAST("ref")));
assert(n!=NULL); assert(n!=nullptr);
str_ref = n; str_ref = n;
//setInt("ref", n); //setInt("ref", n);
// if object with id str_ref has not been loaded yet, // if object with id str_ref has not been loaded yet,
@ -75,9 +75,9 @@ xmlNodePtr FWReference::toXML(xmlNodePtr parent)
{ {
xmlNodePtr me = xmlNewChild( xmlNodePtr me = xmlNewChild(
parent, parent,
NULL, nullptr,
xml_name.empty() ? STRTOXMLCAST(getTypeName()) : STRTOXMLCAST(xml_name), xml_name.empty() ? STRTOXMLCAST(getTypeName()) : STRTOXMLCAST(xml_name),
NULL); nullptr);
if (int_ref == -1 && !str_ref.empty()) if (int_ref == -1 && !str_ref.empty())
int_ref = FWObjectDatabase::getIntId(str_ref); int_ref = FWObjectDatabase::getIntId(str_ref);
@ -102,7 +102,7 @@ FWObject& FWReference::shallowDuplicate(const FWObject *_other,
bool FWReference::cmp(const FWObject *obj, bool /* UNUSED recursive */) bool FWReference::cmp(const FWObject *obj, bool /* UNUSED recursive */)
{ {
const FWReference *rx = FWReference::constcast(obj); const FWReference *rx = FWReference::constcast(obj);
if (rx == NULL) return false; if (rx == nullptr) return false;
if (int_ref != rx->int_ref || str_ref != rx->str_ref) return false; if (int_ref != rx->int_ref || str_ref != rx->str_ref) return false;
return true; return true;
} }
@ -167,7 +167,7 @@ void FWReference::dump(std::ostream &f, bool recursive, bool brief, int offset)
FWObject* FWReference::getObject(FWObject* o) FWObject* FWReference::getObject(FWObject* o)
{ {
if (o==NULL) return NULL; if (o==nullptr) return nullptr;
if (FWReference::cast(o)!=NULL) return FWReference::cast(o)->getPointer(); if (FWReference::cast(o)!=nullptr) return FWReference::cast(o)->getPointer();
return o; return o;
} }

View File

@ -66,7 +66,7 @@ Firewall::Firewall()
void Firewall::init(FWObjectDatabase *root) void Firewall::init(FWObjectDatabase *root)
{ {
FWObject *opt = getFirstByType(FirewallOptions::TYPENAME); FWObject *opt = getFirstByType(FirewallOptions::TYPENAME);
if (opt == NULL) if (opt == nullptr)
{ {
add( root->createFirewallOptions() ); add( root->createFirewallOptions() );
RuleSet *p; RuleSet *p;
@ -87,45 +87,45 @@ Firewall::~Firewall() {}
void Firewall::fromXML(xmlNodePtr root) void Firewall::fromXML(xmlNodePtr root)
{ {
const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("platform"))); const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("platform")));
assert(n!=NULL); assert(n!=nullptr);
setStr("platform", n); setStr("platform", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("version"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("version")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("version", n); setStr("version", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("host_OS"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("host_OS")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("host_OS", n); setStr("host_OS", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("lastModified"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("lastModified")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("lastModified", n); setStr("lastModified", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("lastInstalled"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("lastInstalled")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("lastInstalled", n); setStr("lastInstalled", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("lastCompiled"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("lastCompiled")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("lastCompiled", n); setStr("lastCompiled", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("inactive"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("inactive")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("inactive", n); setStr("inactive", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
@ -344,12 +344,12 @@ FWObject& Firewall::duplicateForUndo(const FWObject *obj)
void Firewall::updateLastInstalledTimestamp() void Firewall::updateLastInstalledTimestamp()
{ {
setInt("lastInstalled",time(NULL)); setInt("lastInstalled",time(nullptr));
} }
void Firewall::updateLastModifiedTimestamp() void Firewall::updateLastModifiedTimestamp()
{ {
setInt("lastModified",time(NULL)); setInt("lastModified",time(nullptr));
} }
bool Firewall::needsInstall() bool Firewall::needsInstall()
@ -382,7 +382,7 @@ time_t Firewall::getLastCompiled()
} }
void Firewall::updateLastCompiledTimestamp() void Firewall::updateLastCompiledTimestamp()
{ {
setInt("lastCompiled",time(NULL)); setInt("lastCompiled",time(nullptr));
} }
bool Firewall::getInactive() bool Firewall::getInactive()

View File

@ -96,8 +96,8 @@ bool Group::hasMember(FWObject *o)
FWObject& Group::duplicateForUndo(const FWObject *obj) FWObject& Group::duplicateForUndo(const FWObject *obj)
{ {
setRO(false); setRO(false);
if ((obj->size() && FWReference::cast(obj->front())!=NULL) || if ((obj->size() && FWReference::cast(obj->front())!=nullptr) ||
(this->size() && FWReference::cast(this->front())!=NULL)) (this->size() && FWReference::cast(this->front())!=nullptr))
{ {
destroyChildren(); destroyChildren();
for(list<FWObject*>::const_iterator m=obj->begin(); m!=obj->end(); ++m) for(list<FWObject*>::const_iterator m=obj->begin(); m!=obj->end(); ++m)

View File

@ -48,7 +48,7 @@ Host::Host()
void Host::init(FWObjectDatabase *root) void Host::init(FWObjectDatabase *root)
{ {
FWObject *opt = getFirstByType(HostOptions::TYPENAME); FWObject *opt = getFirstByType(HostOptions::TYPENAME);
if (opt == NULL) if (opt == nullptr)
add( root->createHostOptions() ); add( root->createHostOptions() );
} }
@ -69,7 +69,7 @@ xmlNodePtr Host::toXML(xmlNodePtr parent)
FWObject *o; FWObject *o;
for(FWObjectTypedChildIterator j=findByType(Interface::TYPENAME); j!=j.end(); ++j) for(FWObjectTypedChildIterator j=findByType(Interface::TYPENAME); j!=j.end(); ++j)
if((o=(*j))!=NULL ) if((o=(*j))!=nullptr )
o->toXML(me); o->toXML(me);
o=getFirstByType( Management::TYPENAME ); o=getFirstByType( Management::TYPENAME );
@ -146,13 +146,13 @@ const InetAddr* Host::getManagementAddress()
} }
} }
return NULL; return nullptr;
} }
const Address* Host::getAddressObject() const const Address* Host::getAddressObject() const
{ {
FWObjectTypedChildIterator j = findByType(Interface::TYPENAME); FWObjectTypedChildIterator j = findByType(Interface::TYPENAME);
if (j == j.end()) return NULL; if (j == j.end()) return nullptr;
return Interface::cast(*j)->getAddressObject(); return Interface::cast(*j)->getAddressObject();
} }
@ -176,7 +176,7 @@ int Host::countInetAddresses(bool skip_loopback) const
FWObject* Host::getParentHost(FWObject *obj) FWObject* Host::getParentHost(FWObject *obj)
{ {
FWObject *parent_h = obj; FWObject *parent_h = obj;
while (parent_h != NULL && Host::cast(parent_h) == NULL) while (parent_h != nullptr && Host::cast(parent_h) == nullptr)
parent_h = parent_h->getParent(); parent_h = parent_h->getParent();
return parent_h; return parent_h;
} }

View File

@ -52,12 +52,12 @@ void ICMPService::fromXML(xmlNodePtr root)
FWObject::fromXML(root); FWObject::fromXML(root);
const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("type"))); const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("type")));
assert(n!=NULL); assert(n!=nullptr);
setStr("type", n); setStr("type", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("code"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("code")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("code", n); setStr("code", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);

View File

@ -94,82 +94,82 @@ void IPService::fromXML(xmlNodePtr root)
FWObject::fromXML(root); FWObject::fromXML(root);
const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("protocol_num"))); const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("protocol_num")));
assert(n!=NULL); assert(n!=nullptr);
setStr("protocol_num", n); setStr("protocol_num", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("fragm"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("fragm")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("fragm", n); setStr("fragm", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("short_fragm"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("short_fragm")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("short_fragm", n); setStr("short_fragm", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("any_opt"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("any_opt")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("any_opt", n); setStr("any_opt", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("lsrr"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("lsrr")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("lsrr", n); setStr("lsrr", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("ssrr"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("ssrr")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("ssrr", n); setStr("ssrr", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("rr"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("rr")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("rr", n); setStr("rr", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("ts"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("ts")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("ts", n); setStr("ts", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("tos"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("tos")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("tos", n); setStr("tos", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dscp"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dscp")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("dscp", n); setStr("dscp", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("rtralt"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("rtralt")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("rtralt", n); setStr("rtralt", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("rtralt_value"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("rtralt_value")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("rtralt_value", n); setStr("rtralt_value", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);

View File

@ -66,7 +66,7 @@ void IPv4::fromXML(xmlNodePtr root)
FWObject::fromXML(root); FWObject::fromXML(root);
const char* n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("address"))); const char* n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("address")));
assert(n!=NULL); assert(n!=nullptr);
// strip whitespace and other non-numeric characters at the beginng and end // strip whitespace and other non-numeric characters at the beginng and end
string addr(n); string addr(n);
@ -83,7 +83,7 @@ void IPv4::fromXML(xmlNodePtr root)
FREEXMLBUFF(n); FREEXMLBUFF(n);
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("netmask"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("netmask")));
assert(n!=NULL); assert(n!=nullptr);
string netm(n); string netm(n);
first = netm.find_first_of("0123456789"); first = netm.find_first_of("0123456789");

View File

@ -81,12 +81,12 @@ void IPv6::fromXML(xmlNodePtr root)
FWObject::fromXML(root); FWObject::fromXML(root);
const char* n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("address"))); const char* n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("address")));
assert(n!=NULL); assert(n!=nullptr);
setAddress(InetAddr(AF_INET6, n)); setAddress(InetAddr(AF_INET6, n));
FREEXMLBUFF(n); FREEXMLBUFF(n);
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("netmask"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("netmask")));
assert(n!=NULL); assert(n!=nullptr);
if (strlen(n)) if (strlen(n))
{ {
if (string(n).find(":")!=string::npos) if (string(n).find(":")!=string::npos)

View File

@ -69,11 +69,11 @@ InetAddrMask::InetAddrMask(bool)
// variables. This constructor should only be used by classes that // variables. This constructor should only be used by classes that
// inherit InetAddrMask and create address, netmask themselves, // inherit InetAddrMask and create address, netmask themselves,
// such as Inet6AddrMask // such as Inet6AddrMask
address = NULL; address = nullptr;
netmask = NULL; netmask = nullptr;
broadcast_address = NULL; broadcast_address = nullptr;
network_address = NULL; network_address = nullptr;
last_host = NULL; last_host = nullptr;
} }
InetAddrMask::InetAddrMask() InetAddrMask::InetAddrMask()
@ -146,11 +146,11 @@ InetAddrMask::InetAddrMask(const string &s)
InetAddrMask::~InetAddrMask() InetAddrMask::~InetAddrMask()
{ {
if (address!=NULL) delete address; if (address!=nullptr) delete address;
if (netmask!=NULL) delete netmask; if (netmask!=nullptr) delete netmask;
if (network_address!=NULL) delete network_address; if (network_address!=nullptr) delete network_address;
if (broadcast_address!=NULL) delete broadcast_address; if (broadcast_address!=nullptr) delete broadcast_address;
if (last_host!=NULL) delete last_host; if (last_host!=nullptr) delete last_host;
} }
bool InetAddrMask::isAny() bool InetAddrMask::isAny()

View File

@ -105,7 +105,7 @@ FWObject& Interface::duplicate(const FWObject *x, bool preserve_id)
FWObject::duplicate(x, preserve_id); FWObject::duplicate(x, preserve_id);
const Interface *rx = Interface::constcast(x); const Interface *rx = Interface::constcast(x);
if (rx!=NULL) if (rx!=nullptr)
{ {
bcast_bits = rx->bcast_bits; bcast_bits = rx->bcast_bits;
ostatus = rx->ostatus; ostatus = rx->ostatus;
@ -130,7 +130,7 @@ void Interface::duplicateWithIdMapping(const FWObject *src,
{ {
FWObject *src_obj = *m; FWObject *src_obj = *m;
FWObject *dst_obj_copy = addCopyOf(src_obj, preserve_id); FWObject *dst_obj_copy = addCopyOf(src_obj, preserve_id);
if (src_obj!=NULL && dst_obj_copy!=NULL) if (src_obj!=nullptr && dst_obj_copy!=nullptr)
id_mapping[src_obj->getId()] = dst_obj_copy->getId(); id_mapping[src_obj->getId()] = dst_obj_copy->getId();
} }
@ -140,7 +140,7 @@ void Interface::duplicateWithIdMapping(const FWObject *src,
bool Interface::cmp(const FWObject *obj, bool recursive) bool Interface::cmp(const FWObject *obj, bool recursive)
{ {
const Interface *rx = Interface::constcast(obj); const Interface *rx = Interface::constcast(obj);
if (rx == NULL) return false; if (rx == nullptr) return false;
if (bcast_bits != rx->bcast_bits || if (bcast_bits != rx->bcast_bits ||
ostatus != rx->ostatus || ostatus != rx->ostatus ||
snmp_type != rx->snmp_type) return false; snmp_type != rx->snmp_type) return false;
@ -154,56 +154,56 @@ void Interface::fromXML(xmlNodePtr root)
const char *n; const char *n;
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("security_level"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("security_level")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("security_level",n); setStr("security_level",n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dyn"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dyn")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("dyn",n); setStr("dyn",n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("unnum"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("unnum")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("unnum",n); setStr("unnum",n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("unprotected"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("unprotected")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("unprotected",n); setStr("unprotected",n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dedicated_failover"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dedicated_failover")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("dedicated_failover",n); setStr("dedicated_failover",n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("mgmt"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("mgmt")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("mgmt",n); setStr("mgmt",n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("label"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("label")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("label",n); setStr("label",n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("network_zone"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("network_zone")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("network_zone", n); setStr("network_zone", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
@ -230,19 +230,19 @@ xmlNodePtr Interface::toXML(xmlNodePtr parent)
for(FWObjectTypedChildIterator j1=findByType(IPv4::TYPENAME); for(FWObjectTypedChildIterator j1=findByType(IPv4::TYPENAME);
j1!=j1.end(); ++j1) j1!=j1.end(); ++j1)
{ {
if ((o=(*j1))!=NULL ) if ((o=(*j1))!=nullptr )
o->toXML(me); o->toXML(me);
} }
for(FWObjectTypedChildIterator j1=findByType(IPv6::TYPENAME); for(FWObjectTypedChildIterator j1=findByType(IPv6::TYPENAME);
j1!=j1.end(); ++j1) j1!=j1.end(); ++j1)
{ {
if ((o=(*j1))!=NULL ) if ((o=(*j1))!=nullptr )
o->toXML(me); o->toXML(me);
} }
for(FWObjectTypedChildIterator j2=findByType(physAddress::TYPENAME); for(FWObjectTypedChildIterator j2=findByType(physAddress::TYPENAME);
j2!=j2.end(); ++j2) j2!=j2.end(); ++j2)
{ {
if ((o=(*j2))!=NULL ) if ((o=(*j2))!=nullptr )
o->toXML(me); o->toXML(me);
} }
@ -256,7 +256,7 @@ xmlNodePtr Interface::toXML(xmlNodePtr parent)
for(FWObjectTypedChildIterator j1=findByType(Interface::TYPENAME); for(FWObjectTypedChildIterator j1=findByType(Interface::TYPENAME);
j1!=j1.end(); ++j1) j1!=j1.end(); ++j1)
{ {
if((o=(*j1))!=NULL) if((o=(*j1))!=nullptr)
o->toXML(me); o->toXML(me);
} }
@ -276,14 +276,14 @@ FWOptions* Interface::getOptionsObject()
{ {
FWOptions *iface_opt = FWOptions::cast(getFirstByType(InterfaceOptions::TYPENAME)); FWOptions *iface_opt = FWOptions::cast(getFirstByType(InterfaceOptions::TYPENAME));
if (iface_opt == NULL) if (iface_opt == nullptr)
{ {
iface_opt = FWOptions::cast(getRoot()->create(InterfaceOptions::TYPENAME)); iface_opt = FWOptions::cast(getRoot()->create(InterfaceOptions::TYPENAME));
add(iface_opt); add(iface_opt);
// set default interface options // set default interface options
const FWObject *parent_host = Host::getParentHost(this); const FWObject *parent_host = Host::getParentHost(this);
if (parent_host != NULL) if (parent_host != nullptr)
{ {
const string host_OS = parent_host->getStr("host_OS"); const string host_OS = parent_host->getStr("host_OS");
try try
@ -303,7 +303,7 @@ FWOptions* Interface::getOptionsObject()
FWOptions* Interface::getOptionsObjectConst() const FWOptions* Interface::getOptionsObjectConst() const
{ {
FWOptions *iface_opt = FWOptions::cast(getFirstByType(InterfaceOptions::TYPENAME)); FWOptions *iface_opt = FWOptions::cast(getFirstByType(InterfaceOptions::TYPENAME));
if (iface_opt == NULL) if (iface_opt == nullptr)
cerr << "Interface " cerr << "Interface "
<< getName() << getName()
<< " (" << " ("
@ -437,7 +437,7 @@ physAddress* Interface::getPhysicalAddress () const
void Interface::setPhysicalAddress(const std::string &paddr) void Interface::setPhysicalAddress(const std::string &paddr)
{ {
physAddress *pa=getPhysicalAddress(); physAddress *pa=getPhysicalAddress();
if (pa!=NULL) if (pa!=nullptr)
{ {
pa->setPhysAddress(paddr); pa->setPhysAddress(paddr);
} else } else
@ -461,7 +461,7 @@ void Interface::setLabel(const string& n)
const Address* Interface::getAddressObject() const const Address* Interface::getAddressObject() const
{ {
Address *res = Address::cast(getFirstByType(IPv4::TYPENAME)); Address *res = Address::cast(getFirstByType(IPv4::TYPENAME));
if (res==NULL) if (res==nullptr)
res = Address::cast(getFirstByType(IPv6::TYPENAME)); res = Address::cast(getFirstByType(IPv6::TYPENAME));
return res; return res;
} }
@ -493,7 +493,7 @@ int Interface::countInetAddresses(bool skip_loopback) const
bool Interface::isFailoverInterface() const bool Interface::isFailoverInterface() const
{ {
return getFirstByType(FailoverClusterGroup::TYPENAME) != NULL; return getFirstByType(FailoverClusterGroup::TYPENAME) != nullptr;
} }
void Interface::replaceReferenceInternal(int old_id, int new_id, int &counter) void Interface::replaceReferenceInternal(int old_id, int new_id, int &counter)

View File

@ -63,7 +63,7 @@ InterfaceData::InterfaceData(const InterfaceData& other) : addr_mask()
InetAddrMask *am; InetAddrMask *am;
const InetAddr *ad = (*i)->getAddressPtr(); const InetAddr *ad = (*i)->getAddressPtr();
const InetAddr *nm = (*i)->getNetmaskPtr(); const InetAddr *nm = (*i)->getNetmaskPtr();
if (ad==NULL) continue; if (ad==nullptr) continue;
if (ad->isV6()) if (ad->isV6())
{ {
am = new Inet6AddrMask(); am = new Inet6AddrMask();
@ -109,7 +109,7 @@ InterfaceData::InterfaceData(const Interface &iface) : addr_mask()
isUnnumbered = iface.isUnnumbered(); isUnnumbered = iface.isUnnumbered();
isBridgePort = iface.isBridgePort(); isBridgePort = iface.isBridgePort();
libfwbuilder::physAddress *pa = iface.getPhysicalAddress(); libfwbuilder::physAddress *pa = iface.getPhysicalAddress();
if (pa!=NULL) if (pa!=nullptr)
mac_addr = pa->getPhysAddress(); mac_addr = pa->getPhysAddress();
label = iface.getLabel(); label = iface.getLabel();
networkZone = iface.getStr("network_zone"); networkZone = iface.getStr("network_zone");

View File

@ -184,42 +184,42 @@ void Interval::fromXML(xmlNodePtr root)
const char *n; const char *n;
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_minute"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_minute")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("from_minute", n); setStr("from_minute", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_hour"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_hour")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("from_hour", n); setStr("from_hour", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_day"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_day")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("from_day", n); setStr("from_day", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_month"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_month")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("from_month", n); setStr("from_month", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_year"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_year")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("from_year", n); setStr("from_year", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_weekday"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("from_weekday")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("from_weekday", n); setStr("from_weekday", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
@ -227,49 +227,49 @@ void Interval::fromXML(xmlNodePtr root)
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_minute"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_minute")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("to_minute", n); setStr("to_minute", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_hour"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_hour")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("to_hour", n); setStr("to_hour", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_day"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_day")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("to_day", n); setStr("to_day", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_month"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_month")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("to_month", n); setStr("to_month", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_year"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_year")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("to_year", n); setStr("to_year", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_weekday"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("to_weekday")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("to_weekday", n); setStr("to_weekday", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("days_of_week"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("days_of_week")));
if (n!=NULL) if (n!=nullptr)
{ {
setStr("days_of_week", n); setStr("days_of_week", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);

View File

@ -43,7 +43,7 @@ IntervalGroup::~IntervalGroup() {}
bool IntervalGroup::validateChild(FWObject *o) bool IntervalGroup::validateChild(FWObject *o)
{ {
FWObject *oo = o; FWObject *oo = o;
if (FWObjectReference::cast(o)!=NULL) if (FWObjectReference::cast(o)!=nullptr)
oo = FWObjectReference::cast(o)->getPointer(); oo = FWObjectReference::cast(o)->getPointer();
string otype = oo->getTypeName(); string otype = oo->getTypeName();

View File

@ -49,7 +49,7 @@ bool Library::validateChild(FWObject*)
void Library::fromXML(xmlNodePtr root) void Library::fromXML(xmlNodePtr root)
{ {
const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("color"))); const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("color")));
if(n!=NULL) // color is not a mandatory attribute if(n!=nullptr) // color is not a mandatory attribute
{ {
setStr("color", n); setStr("color", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);

View File

@ -105,7 +105,7 @@ xmlNodePtr Management::toXML(xmlNodePtr parent)
bool Management::cmp(const FWObject *obj, bool recursive) bool Management::cmp(const FWObject *obj, bool recursive)
{ {
if (Management::constcast(obj)==NULL) return false; if (Management::constcast(obj)==nullptr) return false;
if (!FWObject::cmp(obj, recursive)) return false; if (!FWObject::cmp(obj, recursive)) return false;
const Management *o2=Management::constcast(obj); const Management *o2=Management::constcast(obj);
@ -242,7 +242,7 @@ xmlNodePtr PolicyInstallScript::toXML(xmlNodePtr parent)
bool PolicyInstallScript::cmp(const FWObject *obj, bool recursive) bool PolicyInstallScript::cmp(const FWObject *obj, bool recursive)
{ {
if (PolicyInstallScript::constcast(obj)==NULL) return false; if (PolicyInstallScript::constcast(obj)==nullptr) return false;
if (!FWObject::cmp(obj, recursive)) return false; if (!FWObject::cmp(obj, recursive)) return false;
const PolicyInstallScript *o2=PolicyInstallScript::constcast(obj); const PolicyInstallScript *o2=PolicyInstallScript::constcast(obj);
@ -348,7 +348,7 @@ xmlNodePtr SNMPManagement::toXML(xmlNodePtr parent)
bool SNMPManagement::cmp(const FWObject *obj, bool recursive) bool SNMPManagement::cmp(const FWObject *obj, bool recursive)
{ {
if (SNMPManagement::constcast(obj)==NULL) return false; if (SNMPManagement::constcast(obj)==nullptr) return false;
if (!FWObject::cmp(obj, recursive)) return false; if (!FWObject::cmp(obj, recursive)) return false;
const SNMPManagement *o2=SNMPManagement::constcast(obj); const SNMPManagement *o2=SNMPManagement::constcast(obj);
@ -424,12 +424,12 @@ void FWBDManagement::setEnabled(bool v)
void FWBDManagement::fromXML(xmlNodePtr parent) void FWBDManagement::fromXML(xmlNodePtr parent)
{ {
const char *n=FROMXMLCAST(xmlGetProp(parent,TOXMLCAST("identity"))); const char *n=FROMXMLCAST(xmlGetProp(parent,TOXMLCAST("identity")));
assert(n!=NULL); assert(n!=nullptr);
identity_id = n; identity_id = n;
FREEXMLBUFF(n); FREEXMLBUFF(n);
n=FROMXMLCAST(xmlGetProp(parent,TOXMLCAST("port"))); n=FROMXMLCAST(xmlGetProp(parent,TOXMLCAST("port")));
assert(n!=NULL); assert(n!=nullptr);
port = atoi(n); port = atoi(n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
@ -456,7 +456,7 @@ xmlNodePtr FWBDManagement::toXML(xmlNodePtr parent)
bool FWBDManagement::cmp(const FWObject *obj, bool recursive) bool FWBDManagement::cmp(const FWObject *obj, bool recursive)
{ {
if (FWBDManagement::constcast(obj)==NULL) return false; if (FWBDManagement::constcast(obj)==nullptr) return false;
if (!FWObject::cmp(obj, recursive)) return false; if (!FWObject::cmp(obj, recursive)) return false;
const FWBDManagement *o2=FWBDManagement::constcast(obj); const FWBDManagement *o2=FWBDManagement::constcast(obj);

View File

@ -47,7 +47,7 @@ NAT::~NAT() {}
Rule* NAT::createRule() Rule* NAT::createRule()
{ {
FWObjectDatabase* db=getRoot(); FWObjectDatabase* db=getRoot();
assert(db!=NULL); assert(db!=nullptr);
return db->createNATRule(); return db->createNATRule();
} }

View File

@ -64,12 +64,12 @@ void Network::fromXML(xmlNodePtr root)
FWObject::fromXML(root); FWObject::fromXML(root);
const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("address"))); const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("address")));
assert(n!=NULL); assert(n!=nullptr);
setAddress(InetAddr(n)); setAddress(InetAddr(n));
FREEXMLBUFF(n); FREEXMLBUFF(n);
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("netmask"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("netmask")));
assert(n!=NULL); assert(n!=nullptr);
setNetmask(InetAddr(n)); setNetmask(InetAddr(n));
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
@ -120,12 +120,12 @@ const InetAddr* Network::getFirstHostPtr() const
{ {
const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr(); const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr();
if (inet_addr_mask) return inet_addr_mask->getFirstHostPtr(); if (inet_addr_mask) return inet_addr_mask->getFirstHostPtr();
return NULL; return nullptr;
} }
const InetAddr* Network::getLastHostPtr() const const InetAddr* Network::getLastHostPtr() const
{ {
const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr(); const InetAddrMask *inet_addr_mask = getInetAddrMaskObjectPtr();
if (inet_addr_mask) return inet_addr_mask->getLastHostPtr(); if (inet_addr_mask) return inet_addr_mask->getLastHostPtr();
return NULL; return nullptr;
} }

View File

@ -78,12 +78,12 @@ void NetworkIPv6::fromXML(xmlNodePtr root)
FWObject::fromXML(root); FWObject::fromXML(root);
const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("address"))); const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("address")));
assert(n!=NULL); assert(n!=nullptr);
setAddress(InetAddr(AF_INET6, n)); setAddress(InetAddr(AF_INET6, n));
FREEXMLBUFF(n); FREEXMLBUFF(n);
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("netmask"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("netmask")));
assert(n!=NULL); assert(n!=nullptr);
if (strlen(n)) if (strlen(n))
{ {
if (string(n).find(":")!=string::npos) if (string(n).find(":")!=string::npos)

View File

@ -58,14 +58,14 @@ ObjectGroup::~ObjectGroup() {}
bool ObjectGroup::validateChild(FWObject *o) bool ObjectGroup::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
return (FWObject::validateChild(o) && return (FWObject::validateChild(o) &&
Service::cast(o)==NULL && Service::cast(o)==nullptr &&
ServiceGroup::cast(o)==NULL && ServiceGroup::cast(o)==nullptr &&
Interval::cast(o)==NULL && Interval::cast(o)==nullptr &&
FWServiceReference::cast(o)==NULL && FWServiceReference::cast(o)==nullptr &&
RuleSet::cast(o)==NULL); RuleSet::cast(o)==nullptr);
} }
xmlNodePtr ObjectGroup::toXML(xmlNodePtr parent) xmlNodePtr ObjectGroup::toXML(xmlNodePtr parent)

View File

@ -94,7 +94,7 @@ bool ObjectMatcher::complexMatch(Address *obj1, Address *obj2)
} }
void* res = obj1->dispatch(this, obj2); void* res = obj1->dispatch(this, obj2);
return (res != NULL); return (res != nullptr);
} }
/** /**
@ -279,11 +279,11 @@ void* ObjectMatcher::dispatch(Interface* obj1, void* _obj2)
if (obj1->getParent()->getId() == obj2->getId()) return obj1; if (obj1->getParent()->getId() == obj2->getId()) return obj1;
if (!obj1->isRegular()) return NULL; if (!obj1->isRegular()) return nullptr;
if ((obj1->getByType(IPv4::TYPENAME)).size()>1) return NULL; if ((obj1->getByType(IPv4::TYPENAME)).size()>1) return nullptr;
if ((obj1->getByType(IPv6::TYPENAME)).size()>1) return NULL; if ((obj1->getByType(IPv6::TYPENAME)).size()>1) return nullptr;
return (checkComplexMatchForSingleAddress(obj1, obj2)) ? obj1 : NULL; return (checkComplexMatchForSingleAddress(obj1, obj2)) ? obj1 : nullptr;
} }
void* ObjectMatcher::dispatch(Network *obj1, void *_obj2) void* ObjectMatcher::dispatch(Network *obj1, void *_obj2)
@ -306,10 +306,10 @@ void* ObjectMatcher::dispatch(Network *obj1, void *_obj2)
* ranges, and some often used ranges trigger that (like * ranges, and some often used ranges trigger that (like
* "255.255.255.255-255.255.255.255" or "0.0.0.0-0.0.0.0") * "255.255.255.255-255.255.255.255" or "0.0.0.0-0.0.0.0")
*/ */
if (!obj1->getNetmaskPtr()->isHostMask()) return NULL; if (!obj1->getNetmaskPtr()->isHostMask()) return nullptr;
} else } else
return NULL; return nullptr;
return checkComplexMatchForSingleAddress(obj1, obj2) ? obj1 : NULL; return checkComplexMatchForSingleAddress(obj1, obj2) ? obj1 : nullptr;
} }
void* ObjectMatcher::dispatch(NetworkIPv6 *obj1, void *_obj2) void* ObjectMatcher::dispatch(NetworkIPv6 *obj1, void *_obj2)
@ -320,23 +320,23 @@ void* ObjectMatcher::dispatch(NetworkIPv6 *obj1, void *_obj2)
{ {
if (recognize_multicasts && inet_addr->isMulticast() && if (recognize_multicasts && inet_addr->isMulticast() &&
Firewall::isA(obj2)) return obj1; Firewall::isA(obj2)) return obj1;
if (!obj1->getNetmaskPtr()->isHostMask()) return NULL; if (!obj1->getNetmaskPtr()->isHostMask()) return nullptr;
} else } else
return NULL; return nullptr;
return checkComplexMatchForSingleAddress(obj1, obj2) ? obj1 : NULL; return checkComplexMatchForSingleAddress(obj1, obj2) ? obj1 : nullptr;
} }
void* ObjectMatcher::dispatch(IPv4 *obj1, void *_obj2) void* ObjectMatcher::dispatch(IPv4 *obj1, void *_obj2)
{ {
FWObject *obj2 = (FWObject*)(_obj2); FWObject *obj2 = (FWObject*)(_obj2);
return checkComplexMatchForSingleAddress(obj1, obj2) ? obj1 : NULL; return checkComplexMatchForSingleAddress(obj1, obj2) ? obj1 : nullptr;
} }
void* ObjectMatcher::dispatch(IPv6 *obj1, void *_obj2) void* ObjectMatcher::dispatch(IPv6 *obj1, void *_obj2)
{ {
FWObject *obj2 = (FWObject*)(_obj2); FWObject *obj2 = (FWObject*)(_obj2);
return checkComplexMatchForSingleAddress(obj1, obj2) ? obj1 : NULL; return checkComplexMatchForSingleAddress(obj1, obj2) ? obj1 : nullptr;
} }
void* ObjectMatcher::dispatch(physAddress *obj1, void *_obj2) void* ObjectMatcher::dispatch(physAddress *obj1, void *_obj2)
@ -348,7 +348,7 @@ void* ObjectMatcher::dispatch(physAddress *obj1, void *_obj2)
physAddress *iface_pa = physAddress::cast(*i); physAddress *iface_pa = physAddress::cast(*i);
if (obj1->getPhysAddress() == iface_pa->getPhysAddress()) return obj1; if (obj1->getPhysAddress() == iface_pa->getPhysAddress()) return obj1;
} }
return NULL; return nullptr;
} }
void* ObjectMatcher::dispatch(AddressRange *obj1, void *_obj2) void* ObjectMatcher::dispatch(AddressRange *obj1, void *_obj2)
@ -425,14 +425,14 @@ void* ObjectMatcher::dispatch(AddressRange *obj1, void *_obj2)
if (f_b <= 0 && f_e >= 0) return obj1; if (f_b <= 0 && f_e >= 0) return obj1;
} }
} }
return NULL; return nullptr;
bool f_b = checkComplexMatchForSingleAddress(&range_start, obj2); bool f_b = checkComplexMatchForSingleAddress(&range_start, obj2);
bool f_e = checkComplexMatchForSingleAddress(&range_end, obj2); bool f_e = checkComplexMatchForSingleAddress(&range_end, obj2);
if (address_range_match_mode == EXACT && f_b && f_e) return obj1; if (address_range_match_mode == EXACT && f_b && f_e) return obj1;
if (address_range_match_mode == PARTIAL && (f_b || f_e)) return obj1; if (address_range_match_mode == PARTIAL && (f_b || f_e)) return obj1;
return NULL; return nullptr;
} }
/* /*
@ -447,7 +447,7 @@ void* ObjectMatcher::dispatch(MultiAddressRunTime *obj1, void *_obj2)
obj1->getSourceName() == "self" && Firewall::isA(obj2)) obj1->getSourceName() == "self" && Firewall::isA(obj2))
return obj1; return obj1;
return NULL; // never matches in this implementation return nullptr; // never matches in this implementation
} }
void* ObjectMatcher::dispatch(Host *obj1, void *_obj2) void* ObjectMatcher::dispatch(Host *obj1, void *_obj2)
@ -464,7 +464,7 @@ void* ObjectMatcher::dispatch(Host *obj1, void *_obj2)
{ {
res &= checkComplexMatchForSingleAddress(Interface::cast(*it), obj2); res &= checkComplexMatchForSingleAddress(Interface::cast(*it), obj2);
} }
return res ? obj1 : NULL; return res ? obj1 : nullptr;
} }
void* ObjectMatcher::dispatch(Firewall *obj1, void *_obj2) void* ObjectMatcher::dispatch(Firewall *obj1, void *_obj2)
@ -499,7 +499,7 @@ void* ObjectMatcher::dispatch(Cluster *obj1, void *_obj2)
list<Firewall*>::iterator it; list<Firewall*>::iterator it;
for (it=members.begin(); it!=members.end(); ++it) for (it=members.begin(); it!=members.end(); ++it)
{ {
if (dispatch(*it, obj2) != NULL) return obj1; if (dispatch(*it, obj2) != nullptr) return obj1;
} }
/* /*
* match only if all interfaces of obj1 match obj2 * match only if all interfaces of obj1 match obj2

View File

@ -48,7 +48,7 @@ using namespace std;
Service* ObjectMirror::getMirroredService(Service *obj) Service* ObjectMirror::getMirroredService(Service *obj)
{ {
void* res = obj->dispatch(this, (void*)NULL); void* res = obj->dispatch(this, (void*)nullptr);
return Service::cast((FWObject*)(res)); return Service::cast((FWObject*)(res));
} }

View File

@ -50,7 +50,7 @@ Policy::~Policy() {}
Rule* Policy::createRule() Rule* Policy::createRule()
{ {
FWObjectDatabase* db=getRoot(); FWObjectDatabase* db=getRoot();
assert(db!=NULL); assert(db!=nullptr);
return db->createPolicyRule(); return db->createPolicyRule();
} }

View File

@ -59,22 +59,22 @@ using namespace std;
const string Resources::PLATFORM_RES_DIR_NAME = "platform"; const string Resources::PLATFORM_RES_DIR_NAME = "platform";
const string Resources::OS_RES_DIR_NAME = "os"; const string Resources::OS_RES_DIR_NAME = "os";
Resources* Resources::global_res = NULL; Resources* Resources::global_res = nullptr;
map<string,Resources*> Resources::platform_res; map<string,Resources*> Resources::platform_res;
map<string,Resources*> Resources::os_res; map<string,Resources*> Resources::os_res;
Resources::Resources() Resources::Resources()
{ {
doc=NULL; doc=nullptr;
} }
Resources::Resources(const string &_resF) Resources::Resources(const string &_resF)
{ {
doc = NULL; doc = nullptr;
resfile = _resF; resfile = _resF;
if (global_res==NULL) if (global_res==nullptr)
{ {
global_res = this; global_res = this;
loadRes(_resF); loadRes(_resF);
@ -109,7 +109,7 @@ string Resources::getXmlNodeContent(xmlNodePtr node)
{ {
string res; string res;
char* cptr= (char*)( xmlNodeGetContent(node) ); char* cptr= (char*)( xmlNodeGetContent(node) );
if (cptr!=NULL) if (cptr!=nullptr)
{ {
res=cptr; res=cptr;
FREEXMLBUFF(cptr); FREEXMLBUFF(cptr);
@ -121,7 +121,7 @@ string Resources::getXmlNodeProp(xmlNodePtr node,string prop)
{ {
string res; string res;
char* cptr=(char*)( xmlGetProp(node,TOXMLCAST(prop.c_str()))); char* cptr=(char*)( xmlGetProp(node,TOXMLCAST(prop.c_str())));
if (cptr!=NULL) if (cptr!=nullptr)
{ {
res=cptr; res=cptr;
FREEXMLBUFF(cptr); FREEXMLBUFF(cptr);
@ -394,7 +394,7 @@ string Resources::getRuleElementResourceStr(const string &rel,
xmlNodePtr dptr=Resources::global_res->getXmlNode("FWBuilderResources/RuleElements"); xmlNodePtr dptr=Resources::global_res->getXmlNode("FWBuilderResources/RuleElements");
assert (dptr!=NULL); assert (dptr!=nullptr);
for(c=dptr->xmlChildrenNode; c; c=c->next) for(c=dptr->xmlChildrenNode; c; c=c->next)
{ {
@ -463,7 +463,7 @@ string Resources::getTreeIconFileName(const FWObject *o)
void Resources::setDefaultOption(FWObject *o,const string &xml_node) void Resources::setDefaultOption(FWObject *o,const string &xml_node)
{ {
xmlNodePtr pn = XMLTools::getXmlNodeByPath(root,xml_node.c_str()); xmlNodePtr pn = XMLTools::getXmlNodeByPath(root,xml_node.c_str());
if (pn==NULL) return; if (pn==nullptr) return;
string optname=FROMXMLCAST(pn->name); string optname=FROMXMLCAST(pn->name);
string optval =getXmlNodeContent(pn); string optval =getXmlNodeContent(pn);
@ -473,7 +473,7 @@ void Resources::setDefaultOption(FWObject *o,const string &xml_node)
void Resources::setDefaultOptionsAll(FWObject *o,const string &xml_node) void Resources::setDefaultOptionsAll(FWObject *o,const string &xml_node)
{ {
xmlNodePtr pn = XMLTools::getXmlNodeByPath(root , xml_node.c_str() ); xmlNodePtr pn = XMLTools::getXmlNodeByPath(root , xml_node.c_str() );
if (pn==NULL) return; if (pn==nullptr) return;
xmlNodePtr opt; xmlNodePtr opt;
@ -488,11 +488,11 @@ void Resources::setDefaultOptionsAll(FWObject *o,const string &xml_node)
void Resources::setDefaultTargetOptions(const string &target,Firewall *fw) void Resources::setDefaultTargetOptions(const string &target,Firewall *fw)
{ {
FWOptions *opt=fw->getOptionsObject(); FWOptions *opt=fw->getOptionsObject();
Resources *r=NULL; Resources *r=nullptr;
if (platform_res.count(target)!=0) r=platform_res[target]; if (platform_res.count(target)!=0) r=platform_res[target];
if (r==NULL && os_res.count(target)!=0) r=os_res[target]; if (r==nullptr && os_res.count(target)!=0) r=os_res[target];
if (r==NULL) if (r==nullptr)
throw FWException("Support module for target '"+target+"' is not available"); throw FWException("Support module for target '"+target+"' is not available");
r->setDefaultOptionsAll(opt,"/FWBuilderResources/Target/options/default"); r->setDefaultOptionsAll(opt,"/FWBuilderResources/Target/options/default");
@ -502,16 +502,16 @@ void Resources::setDefaultIfaceOptions(const string &target,Interface *iface)
{ {
FWOptions *opt=iface->getOptionsObject(); FWOptions *opt=iface->getOptionsObject();
/* if InterfaceOptions object does not yet exist -> create one */ /* if InterfaceOptions object does not yet exist -> create one */
if (opt == NULL) { if (opt == nullptr) {
iface->add(iface->getRoot()->create(InterfaceOptions::TYPENAME)); iface->add(iface->getRoot()->create(InterfaceOptions::TYPENAME));
opt = iface->getOptionsObject(); opt = iface->getOptionsObject();
} }
Resources *r=NULL; Resources *r=nullptr;
if (platform_res.count(target)!=0) r=platform_res[target]; if (platform_res.count(target)!=0) r=platform_res[target];
if (r==NULL && os_res.count(target)!=0) r=os_res[target]; if (r==nullptr && os_res.count(target)!=0) r=os_res[target];
if (r==NULL) if (r==nullptr)
throw FWException("Support module for target '"+target+"' is not available"); throw FWException("Support module for target '"+target+"' is not available");
r->setDefaultOptionsAll(opt,"/FWBuilderResources/Target/options/interface"); r->setDefaultOptionsAll(opt,"/FWBuilderResources/Target/options/interface");
@ -534,11 +534,11 @@ void Resources::setDefaultProperties(FWObject *obj)
string Resources::getTargetCapabilityStr(const string &target, string Resources::getTargetCapabilityStr(const string &target,
const string &cap_name) const string &cap_name)
{ {
Resources *r=NULL; Resources *r=nullptr;
if (platform_res.count(target)!=0) r=platform_res[target]; if (platform_res.count(target)!=0) r=platform_res[target];
if (r==NULL && os_res.count(target)!=0) r=os_res[target]; if (r==nullptr && os_res.count(target)!=0) r=os_res[target];
if (r==NULL) if (r==nullptr)
throw FWException("Support module for target '"+target+"' is not available"); throw FWException("Support module for target '"+target+"' is not available");
return r->getResourceStr("/FWBuilderResources/Target/capabilities/"+cap_name); return r->getResourceStr("/FWBuilderResources/Target/capabilities/"+cap_name);
@ -574,11 +574,11 @@ string Resources::getActionEditor(const string &target, const string &action)
string Resources::getTargetOptionStr(const string &target, string Resources::getTargetOptionStr(const string &target,
const string &opt_name) const string &opt_name)
{ {
Resources *r=NULL; Resources *r=nullptr;
if (platform_res.count(target)!=0) r=platform_res[target]; if (platform_res.count(target)!=0) r=platform_res[target];
if (r==NULL && os_res.count(target)!=0) r=os_res[target]; if (r==nullptr && os_res.count(target)!=0) r=os_res[target];
if (r==NULL) if (r==nullptr)
throw FWException("Support module for target '"+target+"' is not available"); throw FWException("Support module for target '"+target+"' is not available");
return r->getResourceStr("/FWBuilderResources/Target/options/"+opt_name); return r->getResourceStr("/FWBuilderResources/Target/options/"+opt_name);

View File

@ -50,7 +50,7 @@ Routing::~Routing() {}
Rule* Routing::createRule() Rule* Routing::createRule()
{ {
FWObjectDatabase* db=getRoot(); FWObjectDatabase* db=getRoot();
assert(db!=NULL); assert(db!=nullptr);
return db->createRoutingRule(); return db->createRoutingRule();
} }

View File

@ -63,8 +63,8 @@ void Rule::init(FWObjectDatabase*)
{ {
} }
FWOptions* Rule::getOptionsObject() const { return NULL; } FWOptions* Rule::getOptionsObject() const { return nullptr; }
RuleSet* Rule::getBranch() { return NULL; } RuleSet* Rule::getBranch() { return nullptr; }
void Rule::setPosition(int n) { setInt("position", n); } void Rule::setPosition(int n) { setInt("position", n); }
int Rule::getPosition() const { return getInt("position"); } int Rule::getPosition() const { return getInt("position"); }
void Rule::disable() { setBool("disabled",true); } void Rule::disable() { setBool("disabled",true); }
@ -117,33 +117,33 @@ PolicyRule::PolicyRule()
// setStr("action","Deny"); // setStr("action","Deny");
setAction(PolicyRule::Deny); setAction(PolicyRule::Deny);
src_re = NULL; src_re = nullptr;
dst_re = NULL; dst_re = nullptr;
srv_re = NULL; srv_re = nullptr;
itf_re = NULL; itf_re = nullptr;
when_re = NULL; when_re = nullptr;
} }
void PolicyRule::init(FWObjectDatabase *root) void PolicyRule::init(FWObjectDatabase *root)
{ {
FWObject *re = getFirstByType(RuleElementSrc::TYPENAME); FWObject *re = getFirstByType(RuleElementSrc::TYPENAME);
if (re == NULL) if (re == nullptr)
{ {
// <!ELEMENT PolicyRule (Src,Dst,Srv?,Itf?,When?,PolicyRuleOptions?)> // <!ELEMENT PolicyRule (Src,Dst,Srv?,Itf?,When?,PolicyRuleOptions?)>
re = root->createRuleElementSrc(); assert(re!=NULL); re = root->createRuleElementSrc(); assert(re!=nullptr);
add(re); src_re = RuleElementSrc::cast(re); add(re); src_re = RuleElementSrc::cast(re);
re = root->createRuleElementDst(); assert(re!=NULL); re = root->createRuleElementDst(); assert(re!=nullptr);
add(re); dst_re = RuleElementDst::cast(re); add(re); dst_re = RuleElementDst::cast(re);
re = root->createRuleElementSrv(); assert(re!=NULL); re = root->createRuleElementSrv(); assert(re!=nullptr);
add(re); srv_re = RuleElementSrv::cast(re); add(re); srv_re = RuleElementSrv::cast(re);
re = root->createRuleElementItf(); assert(re!=NULL); re = root->createRuleElementItf(); assert(re!=nullptr);
add(re); itf_re = RuleElementItf::cast(re); add(re); itf_re = RuleElementItf::cast(re);
re = root->createRuleElementInterval(); assert(re!=NULL); re = root->createRuleElementInterval(); assert(re!=nullptr);
add(re); when_re = RuleElementInterval::cast(re); add(re); when_re = RuleElementInterval::cast(re);
add( root->createPolicyRuleOptions() ); add( root->createPolicyRuleOptions() );
@ -158,11 +158,11 @@ FWObject& PolicyRule::shallowDuplicate(const FWObject *x,
setAction(rx->getAction()); setAction(rx->getAction());
setLogging(rx->getLogging()); setLogging(rx->getLogging());
src_re = NULL; src_re = nullptr;
dst_re = NULL; dst_re = nullptr;
srv_re = NULL; srv_re = nullptr;
itf_re = NULL; itf_re = nullptr;
when_re = NULL; when_re = nullptr;
return Rule::shallowDuplicate(x, preserve_id); return Rule::shallowDuplicate(x, preserve_id);
} }
@ -170,7 +170,7 @@ FWObject& PolicyRule::shallowDuplicate(const FWObject *x,
bool PolicyRule::cmp(const FWObject *x, bool recursive) bool PolicyRule::cmp(const FWObject *x, bool recursive)
{ {
const PolicyRule *rx = PolicyRule::constcast(x); const PolicyRule *rx = PolicyRule::constcast(x);
if (rx == NULL) return false; if (rx == nullptr) return false;
if (getDirection() != rx->getDirection() || if (getDirection() != rx->getDirection() ||
getAction() != rx->getAction() || getAction() != rx->getAction() ||
getLogging() != rx->getLogging()) return false; getLogging() != rx->getLogging()) return false;
@ -436,26 +436,26 @@ xmlNodePtr PolicyRule::toXML(xmlNodePtr parent)
* *
<!ELEMENT PolicyRule (Src,Dst,Srv?,Itf?,When?,PolicyRuleOptions?)> <!ELEMENT PolicyRule (Src,Dst,Srv?,Itf?,When?,PolicyRuleOptions?)>
*/ */
if ( (o=getFirstByType( RuleElementSrc::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementSrc::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementDst::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementDst::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementSrv::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementSrv::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementItf::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementItf::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementInterval::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementInterval::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( PolicyRuleOptions::TYPENAME ))!=NULL ) if ( (o=getFirstByType( PolicyRuleOptions::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
// there should be no children Policy objects in v3 // there should be no children Policy objects in v3
if ( (o=getFirstByType( Policy::TYPENAME ))!=NULL ) if ( (o=getFirstByType( Policy::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
return me; return me;
@ -487,10 +487,10 @@ void PolicyRule::updateNonStandardObjectReferences()
RuleSet* PolicyRule::getBranch() RuleSet* PolicyRule::getBranch()
{ {
if (getAction() != PolicyRule::Branch) return NULL; if (getAction() != PolicyRule::Branch) return nullptr;
FWObject *fw = this; FWObject *fw = this;
while (fw && Firewall::cast(fw) == NULL) fw = fw->getParent(); while (fw && Firewall::cast(fw) == nullptr) fw = fw->getParent();
assert(fw!=NULL); assert(fw!=nullptr);
string branch_id = getOptionsObject()->getStr("branch_id"); string branch_id = getOptionsObject()->getStr("branch_id");
if (!branch_id.empty()) if (!branch_id.empty())
{ {
@ -504,7 +504,7 @@ RuleSet* PolicyRule::getBranch()
return RuleSet::cast( return RuleSet::cast(
fw->findObjectByName(Policy::TYPENAME, branch_name)); fw->findObjectByName(Policy::TYPENAME, branch_name));
} else } else
return NULL; return nullptr;
} }
} }
@ -565,7 +565,7 @@ FWObject* PolicyRule::getTagObject()
FWObjectDatabase::getIntId(tagobj_id)); FWObjectDatabase::getIntId(tagobj_id));
} }
} }
return NULL; return nullptr;
} }
string PolicyRule::getTagValue() string PolicyRule::getTagValue()
@ -654,44 +654,44 @@ NATRule::NATRule() : Rule()
rule_type = Unknown; rule_type = Unknown;
setAction(NATRule::Translate); setAction(NATRule::Translate);
osrc_re = NULL; osrc_re = nullptr;
odst_re = NULL; odst_re = nullptr;
osrv_re = NULL; osrv_re = nullptr;
tsrc_re = NULL; tsrc_re = nullptr;
tdst_re = NULL; tdst_re = nullptr;
tsrv_re = NULL; tsrv_re = nullptr;
itf_inb_re = NULL; itf_inb_re = nullptr;
itf_outb_re = NULL; itf_outb_re = nullptr;
when_re = NULL; when_re = nullptr;
} }
void NATRule::init(FWObjectDatabase *root) void NATRule::init(FWObjectDatabase *root)
{ {
FWObject *re = getFirstByType(RuleElementOSrc::TYPENAME); FWObject *re = getFirstByType(RuleElementOSrc::TYPENAME);
if (re == NULL) if (re == nullptr)
{ {
re = root->createRuleElementOSrc(); assert(re!=NULL); re = root->createRuleElementOSrc(); assert(re!=nullptr);
add(re); osrc_re = RuleElementOSrc::cast(re); add(re); osrc_re = RuleElementOSrc::cast(re);
re = root->createRuleElementODst(); assert(re!=NULL); re = root->createRuleElementODst(); assert(re!=nullptr);
add(re); odst_re = RuleElementODst::cast(re); add(re); odst_re = RuleElementODst::cast(re);
re = root->createRuleElementOSrv(); assert(re!=NULL); re = root->createRuleElementOSrv(); assert(re!=nullptr);
add(re); osrv_re = RuleElementOSrv::cast(re); add(re); osrv_re = RuleElementOSrv::cast(re);
re = root->createRuleElementTSrc(); assert(re!=NULL); re = root->createRuleElementTSrc(); assert(re!=nullptr);
add(re); tsrc_re = RuleElementTSrc::cast(re); add(re); tsrc_re = RuleElementTSrc::cast(re);
re = root->createRuleElementTDst(); assert(re!=NULL); re = root->createRuleElementTDst(); assert(re!=nullptr);
add(re); tdst_re = RuleElementTDst::cast(re); add(re); tdst_re = RuleElementTDst::cast(re);
re = root->createRuleElementTSrv(); assert(re!=NULL); re = root->createRuleElementTSrv(); assert(re!=nullptr);
add(re); tsrv_re = RuleElementTSrv::cast(re); add(re); tsrv_re = RuleElementTSrv::cast(re);
re = root->createRuleElementItfInb(); assert(re!=NULL); re = root->createRuleElementItfInb(); assert(re!=nullptr);
add(re); itf_inb_re = RuleElementItfInb::cast(re); add(re); itf_inb_re = RuleElementItfInb::cast(re);
re = root->createRuleElementItfOutb(); assert(re!=NULL); re = root->createRuleElementItfOutb(); assert(re!=nullptr);
add(re); itf_outb_re = RuleElementItfOutb::cast(re); add(re); itf_outb_re = RuleElementItfOutb::cast(re);
add( root->createNATRuleOptions() ); add( root->createNATRuleOptions() );
@ -876,37 +876,37 @@ xmlNodePtr NATRule::toXML(xmlNodePtr parent)
FWObject *o; FWObject *o;
if ( (o=getFirstByType( RuleElementOSrc::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementOSrc::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementODst::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementODst::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementOSrv::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementOSrv::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementTSrc::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementTSrc::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementTDst::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementTDst::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementTSrv::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementTSrv::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementItfInb::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementItfInb::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementItfOutb::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementItfOutb::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementInterval::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementInterval::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( NATRuleOptions::TYPENAME ))!=NULL ) if ( (o=getFirstByType( NATRuleOptions::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( NAT::TYPENAME ))!=NULL ) if ( (o=getFirstByType( NAT::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
return me; return me;
@ -919,9 +919,9 @@ FWOptions* NATRule::getOptionsObject() const
RuleSet* NATRule::getBranch() RuleSet* NATRule::getBranch()
{ {
if (getAction() != NATRule::Branch) return NULL; if (getAction() != NATRule::Branch) return nullptr;
FWObject *fw = getParent()->getParent(); FWObject *fw = getParent()->getParent();
assert(fw!=NULL); assert(fw!=nullptr);
string branch_id = getOptionsObject()->getStr("branch_id"); string branch_id = getOptionsObject()->getStr("branch_id");
if (!branch_id.empty()) if (!branch_id.empty())
{ {
@ -934,7 +934,7 @@ RuleSet* NATRule::getBranch()
return RuleSet::cast(fw->findObjectByName(NAT::TYPENAME, return RuleSet::cast(fw->findObjectByName(NAT::TYPENAME,
branch_name)); branch_name));
else else
return NULL; return nullptr;
} }
} }
@ -979,18 +979,18 @@ FWObject& NATRule::shallowDuplicate(const FWObject *x,
bool preserve_id) bool preserve_id)
{ {
const NATRule *rx = NATRule::constcast(x); const NATRule *rx = NATRule::constcast(x);
if (rx!=NULL) rule_type = rx->rule_type; if (rx!=nullptr) rule_type = rx->rule_type;
setAction(rx->getAction()); setAction(rx->getAction());
osrc_re = NULL; osrc_re = nullptr;
odst_re = NULL; odst_re = nullptr;
osrv_re = NULL; osrv_re = nullptr;
tsrc_re = NULL; tsrc_re = nullptr;
tdst_re = NULL; tdst_re = nullptr;
tsrv_re = NULL; tsrv_re = nullptr;
itf_inb_re = NULL; itf_inb_re = nullptr;
itf_outb_re = NULL; itf_outb_re = nullptr;
when_re = NULL; when_re = nullptr;
return Rule::shallowDuplicate(x, preserve_id); return Rule::shallowDuplicate(x, preserve_id);
} }
@ -998,7 +998,7 @@ FWObject& NATRule::shallowDuplicate(const FWObject *x,
bool NATRule::cmp(const FWObject *x, bool recursive) bool NATRule::cmp(const FWObject *x, bool recursive)
{ {
const NATRule *rx = NATRule::constcast(x); const NATRule *rx = NATRule::constcast(x);
if (rx == NULL) return false; if (rx == nullptr) return false;
if (getAction() != rx->getAction()) return false; if (getAction() != rx->getAction()) return false;
return Rule::cmp(x, recursive); return Rule::cmp(x, recursive);
} }
@ -1017,11 +1017,11 @@ RoutingRule::RoutingRule() : Rule()
void RoutingRule::init(FWObjectDatabase *root) void RoutingRule::init(FWObjectDatabase *root)
{ {
FWObject *re = getFirstByType(RuleElementRDst::TYPENAME); FWObject *re = getFirstByType(RuleElementRDst::TYPENAME);
if (re == NULL) if (re == nullptr)
{ {
re = root->createRuleElementRDst(); assert(re!=NULL); add(re); re = root->createRuleElementRDst(); assert(re!=nullptr); add(re);
re = root->createRuleElementRGtw(); assert(re!=NULL); add(re); re = root->createRuleElementRGtw(); assert(re!=nullptr); add(re);
re = root->createRuleElementRItf(); assert(re!=NULL); add(re); re = root->createRuleElementRItf(); assert(re!=nullptr); add(re);
add( root->createRoutingRuleOptions() ); add( root->createRoutingRuleOptions() );
} }
} }
@ -1117,19 +1117,19 @@ xmlNodePtr RoutingRule::toXML(xmlNodePtr parent)
FWObject *o; FWObject *o;
if ( (o=getFirstByType( RuleElementRDst::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementRDst::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementRGtw::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementRGtw::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RuleElementRItf::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleElementRItf::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( RoutingRuleOptions::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RoutingRuleOptions::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
if ( (o=getFirstByType( Routing::TYPENAME ))!=NULL ) if ( (o=getFirstByType( Routing::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
return me; return me;
@ -1143,7 +1143,7 @@ FWOptions* RoutingRule::getOptionsObject() const
RuleSet* RoutingRule::getBranch() RuleSet* RoutingRule::getBranch()
{ {
FWObject *fw = getParent()->getParent(); FWObject *fw = getParent()->getParent();
assert(fw!=NULL); assert(fw!=nullptr);
string branch_id = getOptionsObject()->getStr("branch_id"); string branch_id = getOptionsObject()->getStr("branch_id");
if (!branch_id.empty()) if (!branch_id.empty())
{ {
@ -1156,7 +1156,7 @@ RuleSet* RoutingRule::getBranch()
return RuleSet::cast(fw->findObjectByName(Routing::TYPENAME, return RuleSet::cast(fw->findObjectByName(Routing::TYPENAME,
branch_name)); branch_name));
else else
return NULL; return nullptr;
} }
} }
@ -1185,7 +1185,7 @@ FWObject& RoutingRule::duplicate(const FWObject *x,
{ {
Rule::duplicate(x,preserve_id); Rule::duplicate(x,preserve_id);
const RoutingRule *rx = RoutingRule::constcast(x); const RoutingRule *rx = RoutingRule::constcast(x);
if (rx!=NULL) if (rx!=nullptr)
{ {
rule_type = rx->rule_type; rule_type = rx->rule_type;
sorted_dst_ids = rx->sorted_dst_ids; sorted_dst_ids = rx->sorted_dst_ids;

View File

@ -73,7 +73,7 @@ void RuleElement::init(FWObjectDatabase *root)
*/ */
int any_id = getAnyElementId(); int any_id = getAnyElementId();
FWObject *any_obj = getById(any_id); FWObject *any_obj = getById(any_id);
if (any_obj == NULL) if (any_obj == nullptr)
{ {
any_obj = root->checkIndex( any_id ); any_obj = root->checkIndex( any_id );
if (any_obj) FWObject::addRef( any_obj ); if (any_obj) FWObject::addRef( any_obj );
@ -117,14 +117,14 @@ FWObject& RuleElement::shallowDuplicate(const FWObject *other,
void RuleElement::addRef(FWObject *obj) void RuleElement::addRef(FWObject *obj)
{ {
FWObject *o=NULL; FWObject *o=nullptr;
if (isAny()) if (isAny())
{ {
o=(*(begin())); o=(*(begin()));
o=(FWReference::cast(o))->getPointer(); o=(FWReference::cast(o))->getPointer();
} }
FWObject::addRef(obj); FWObject::addRef(obj);
if (o!=NULL) removeRef(o); if (o!=nullptr) removeRef(o);
} }
void RuleElement::removeRef(FWObject *obj) void RuleElement::removeRef(FWObject *obj)
@ -185,7 +185,7 @@ xmlNodePtr RuleElementSrc::toXML(xmlNodePtr parent)
bool RuleElementSrc::validateChild(FWObject *o) bool RuleElementSrc::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
return ObjectGroup::validateChild(o); return ObjectGroup::validateChild(o);
} }
@ -228,7 +228,7 @@ xmlNodePtr RuleElementDst::toXML(xmlNodePtr parent)
bool RuleElementDst::validateChild(FWObject *o) bool RuleElementDst::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
return ObjectGroup::validateChild(o); return ObjectGroup::validateChild(o);
} }
@ -271,7 +271,7 @@ xmlNodePtr RuleElementSrv::toXML(xmlNodePtr parent)
bool RuleElementSrv::validateChild(FWObject *o) bool RuleElementSrv::validateChild(FWObject *o)
{ {
if (FWServiceReference::cast(o)!=NULL) return true; if (FWServiceReference::cast(o)!=nullptr) return true;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
return ServiceGroup::validateChild(o); return ServiceGroup::validateChild(o);
} }
@ -314,13 +314,13 @@ xmlNodePtr RuleElementItf::toXML(xmlNodePtr parent)
bool RuleElementItf::validateChild(FWObject *o) bool RuleElementItf::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
if (o->getId() == getAnyElementId()) return true; if (o->getId() == getAnyElementId()) return true;
if (Interface::cast(o)!=NULL) return true; if (Interface::cast(o)!=nullptr) return true;
if (ObjectGroup::cast(o)!=NULL && o->size() > 0) if (ObjectGroup::cast(o)!=nullptr && o->size() > 0)
{ {
bool all_intf = true; bool all_intf = true;
for (FWObject::iterator i=o->begin(); i!=o->end(); ++i) for (FWObject::iterator i=o->begin(); i!=o->end(); ++i)
@ -376,7 +376,7 @@ bool RuleElementItf::isDummy() const
*/ */
bool RuleElementItf::checkItfChildOfThisFw(FWObject *o) bool RuleElementItf::checkItfChildOfThisFw(FWObject *o)
{ {
if (Group::cast(o) != NULL) if (Group::cast(o) != nullptr)
{ {
for (FWObject::iterator i=o->begin(); i!=o->end(); ++i) for (FWObject::iterator i=o->begin(); i!=o->end(); ++i)
{ {
@ -390,11 +390,11 @@ bool RuleElementItf::checkItfChildOfThisFw(FWObject *o)
FWObject* o_tmp2 = getRoot()->findInIndex(this->getId()); FWObject* o_tmp2 = getRoot()->findInIndex(this->getId());
FWObject *fw1 = o_tmp; FWObject *fw1 = o_tmp;
while (fw1 && Firewall::cast(fw1) == NULL) fw1 = fw1->getParent(); while (fw1 && Firewall::cast(fw1) == nullptr) fw1 = fw1->getParent();
FWObject *fw2 = o_tmp2; FWObject *fw2 = o_tmp2;
while (fw2 && Firewall::cast(fw2) == NULL) fw2 = fw2->getParent(); while (fw2 && Firewall::cast(fw2) == nullptr) fw2 = fw2->getParent();
return (fw1 != NULL && fw1 == fw2); return (fw1 != nullptr && fw1 == fw2);
} }
const char *RuleElementItfInb::TYPENAME={"ItfInb"}; const char *RuleElementItfInb::TYPENAME={"ItfInb"};
@ -425,7 +425,7 @@ xmlNodePtr RuleElementOSrc::toXML(xmlNodePtr parent)
bool RuleElementOSrc::validateChild(FWObject *o) bool RuleElementOSrc::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
return ObjectGroup::validateChild(o); return ObjectGroup::validateChild(o);
} }
@ -452,7 +452,7 @@ xmlNodePtr RuleElementODst::toXML(xmlNodePtr parent)
bool RuleElementODst::validateChild(FWObject *o) bool RuleElementODst::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
return ObjectGroup::validateChild(o); return ObjectGroup::validateChild(o);
} }
@ -479,7 +479,7 @@ xmlNodePtr RuleElementOSrv::toXML(xmlNodePtr parent)
bool RuleElementOSrv::validateChild(FWObject *o) bool RuleElementOSrv::validateChild(FWObject *o)
{ {
if (FWServiceReference::cast(o)!=NULL) return true; if (FWServiceReference::cast(o)!=nullptr) return true;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
return ServiceGroup::validateChild(o); return ServiceGroup::validateChild(o);
} }
@ -508,7 +508,7 @@ xmlNodePtr RuleElementTSrc::toXML(xmlNodePtr parent)
bool RuleElementTSrc::validateChild(FWObject *o) bool RuleElementTSrc::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
return ObjectGroup::validateChild(o); return ObjectGroup::validateChild(o);
} }
@ -535,7 +535,7 @@ xmlNodePtr RuleElementTDst::toXML(xmlNodePtr parent)
bool RuleElementTDst::validateChild(FWObject *o) bool RuleElementTDst::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
return ObjectGroup::validateChild(o); return ObjectGroup::validateChild(o);
} }
@ -562,13 +562,13 @@ xmlNodePtr RuleElementTSrv::toXML(xmlNodePtr parent)
bool RuleElementTSrv::validateChild(FWObject *o) bool RuleElementTSrv::validateChild(FWObject *o)
{ {
if (FWServiceReference::cast(o)!=NULL) return true; if (FWServiceReference::cast(o)!=nullptr) return true;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
// TagService is not allowed in translated service // TagService is not allowed in translated service
if (TagService::isA(o)) return false; if (TagService::isA(o)) return false;
if (ServiceGroup::cast(o)!=NULL) if (ServiceGroup::cast(o)!=nullptr)
{ {
for (FWObject::iterator i=o->begin(); i!=o->end(); ++i) for (FWObject::iterator i=o->begin(); i!=o->end(); ++i)
{ {
@ -603,9 +603,9 @@ xmlNodePtr RuleElementInterval::toXML(xmlNodePtr parent)
bool RuleElementInterval::validateChild(FWObject *o) bool RuleElementInterval::validateChild(FWObject *o)
{ {
if (FWIntervalReference::cast(o)!=NULL) return true; if (FWIntervalReference::cast(o)!=nullptr) return true;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
return (Interval::cast(o)!=NULL || IntervalGroup::cast(o)!=NULL); return (Interval::cast(o)!=nullptr || IntervalGroup::cast(o)!=nullptr);
} }
@ -630,7 +630,7 @@ xmlNodePtr RuleElementRDst::toXML(xmlNodePtr parent)
bool RuleElementRDst::validateChild(FWObject *o) bool RuleElementRDst::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
return ObjectGroup::validateChild(o); return ObjectGroup::validateChild(o);
} }
@ -657,7 +657,7 @@ xmlNodePtr RuleElementRGtw::toXML(xmlNodePtr parent)
bool RuleElementRGtw::validateChild(FWObject *o) bool RuleElementRGtw::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
if( getChildrenCount() > 0 && !isAny()) return false; if( getChildrenCount() > 0 && !isAny()) return false;
return checkSingleIPAdress(o); return checkSingleIPAdress(o);
} }
@ -665,7 +665,7 @@ bool RuleElementRGtw::validateChild(FWObject *o)
// check if the gateway has only one interface with only one ipv4 adress // check if the gateway has only one interface with only one ipv4 adress
bool RuleElementRGtw::checkSingleIPAdress(FWObject *o) bool RuleElementRGtw::checkSingleIPAdress(FWObject *o)
{ {
if( Host::cast(o) != NULL) if( Host::cast(o) != nullptr)
{ {
list<FWObject*> obj_list = o->getByType("Interface"); list<FWObject*> obj_list = o->getByType("Interface");
if( obj_list.size() == 1) if( obj_list.size() == 1)
@ -676,7 +676,7 @@ bool RuleElementRGtw::checkSingleIPAdress(FWObject *o)
return true; return true;
} else return false; } else return false;
} else return false; } else return false;
} else if( Interface::cast(o) != NULL) } else if( Interface::cast(o) != nullptr)
{ {
list<FWObject*> obj_list = o->getByType("IPv4"); list<FWObject*> obj_list = o->getByType("IPv4");
if( obj_list.size() == 1) if( obj_list.size() == 1)
@ -686,7 +686,7 @@ bool RuleElementRGtw::checkSingleIPAdress(FWObject *o)
} }
return ( o->getId() == getAnyElementId() || return ( o->getId() == getAnyElementId() ||
(FWObject::validateChild(o) && (FWObject::validateChild(o) &&
(IPv4::cast(o)!=NULL || FWObjectReference::cast(o)!=NULL))); (IPv4::cast(o)!=nullptr || FWObjectReference::cast(o)!=nullptr)));
} }
const char *RuleElementRItf::TYPENAME={"RItf"}; const char *RuleElementRItf::TYPENAME={"RItf"};
@ -694,12 +694,12 @@ RuleElementRItf::RuleElementRItf() {}
bool RuleElementRItf::validateChild(FWObject *o) bool RuleElementRItf::validateChild(FWObject *o)
{ {
if (FWObjectReference::cast(o)!=NULL) return true; if (FWObjectReference::cast(o)!=nullptr) return true;
if (getChildrenCount() > 0 && !isAny()) return false; if (getChildrenCount() > 0 && !isAny()) return false;
if ( o->getId() == getAnyElementId()) return true; if ( o->getId() == getAnyElementId()) return true;
return (Interface::cast(o)!=NULL); return (Interface::cast(o)!=nullptr);
} }

View File

@ -50,7 +50,7 @@ RuleSet::RuleSet()
void RuleSet::init(FWObjectDatabase *root) void RuleSet::init(FWObjectDatabase *root)
{ {
FWObject *opt = getFirstByType(RuleSetOptions::TYPENAME); FWObject *opt = getFirstByType(RuleSetOptions::TYPENAME);
if (opt == NULL) add(root->createRuleSetOptions()); if (opt == nullptr) add(root->createRuleSetOptions());
} }
RuleSet::~RuleSet() {} RuleSet::~RuleSet() {}
@ -67,21 +67,21 @@ void RuleSet::fromXML(xmlNodePtr root)
// avoid having to increment DTD version number) // avoid having to increment DTD version number)
n=FROMXMLCAST(xmlGetProp(root, TOXMLCAST("ipv4_rule_set"))); n=FROMXMLCAST(xmlGetProp(root, TOXMLCAST("ipv4_rule_set")));
if (n!=NULL) if (n!=nullptr)
{ {
ipv4 = (string(n)=="True" || string(n)=="true"); ipv4 = (string(n)=="True" || string(n)=="true");
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root, TOXMLCAST("ipv6_rule_set"))); n=FROMXMLCAST(xmlGetProp(root, TOXMLCAST("ipv6_rule_set")));
if (n!=NULL) if (n!=nullptr)
{ {
ipv6 = (string(n)=="True" || string(n)=="true"); ipv6 = (string(n)=="True" || string(n)=="true");
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("top_rule_set"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("top_rule_set")));
if (n!=NULL) if (n!=nullptr)
{ {
top = (string(n)=="True" || string(n)=="true"); top = (string(n)=="True" || string(n)=="true");
FREEXMLBUFF(n); FREEXMLBUFF(n);
@ -106,11 +106,11 @@ xmlNodePtr RuleSet::toXML(xmlNodePtr parent)
// First all rules, skip options // First all rules, skip options
for(list<FWObject*>::const_iterator j=begin(); j!=end(); ++j) for(list<FWObject*>::const_iterator j=begin(); j!=end(); ++j)
{ {
if (FWOptions::cast(*j) == NULL) (*j)->toXML(me); if (FWOptions::cast(*j) == nullptr) (*j)->toXML(me);
} }
FWObject *o; FWObject *o;
if ( (o=getFirstByType( RuleSetOptions::TYPENAME ))!=NULL ) if ( (o=getFirstByType( RuleSetOptions::TYPENAME ))!=nullptr )
o->toXML(me); o->toXML(me);
return me; return me;
@ -137,7 +137,7 @@ FWObject& RuleSet::shallowDuplicate(const FWObject *o, bool preserve_id)
bool RuleSet::cmp(const FWObject *obj, bool recursive) bool RuleSet::cmp(const FWObject *obj, bool recursive)
{ {
const RuleSet *other = RuleSet::constcast(obj); const RuleSet *other = RuleSet::constcast(obj);
if (other == NULL) return false; if (other == nullptr) return false;
if (ipv4 != other->ipv4 || ipv6 != other->ipv6 || top != other->top) if (ipv4 != other->ipv4 || ipv6 != other->ipv6 || top != other->top)
return false; return false;
return FWObject::cmp(obj, recursive); return FWObject::cmp(obj, recursive);
@ -171,7 +171,7 @@ Rule* RuleSet::insertRuleBefore(int rule_n)
{ {
Rule *old_rule = getRuleByNum(rule_n); Rule *old_rule = getRuleByNum(rule_n);
Rule *r = createRule(); Rule *r = createRule();
if (old_rule==NULL) add(r); if (old_rule==nullptr) add(r);
else insert_before(old_rule, r); else insert_before(old_rule, r);
renumberRules(); renumberRules();
return(r); return(r);
@ -183,7 +183,7 @@ Rule* RuleSet::appendRuleAtBottom(bool hidden_rule)
r->setHidden(hidden_rule); r->setHidden(hidden_rule);
int last_rule_position; int last_rule_position;
Rule *last_rule = Rule::cast(back()); Rule *last_rule = Rule::cast(back());
if (last_rule != NULL) if (last_rule != nullptr)
{ {
last_rule_position = last_rule->getPosition() + 1000; last_rule_position = last_rule->getPosition() + 1000;
} else } else
@ -198,7 +198,7 @@ Rule* RuleSet::appendRuleAfter(int rule_n)
{ {
Rule *old_rule = getRuleByNum(rule_n); Rule *old_rule = getRuleByNum(rule_n);
Rule *r = createRule(); Rule *r = createRule();
if (old_rule==NULL) add(r); if (old_rule==nullptr) add(r);
else insert_after(old_rule,r); else insert_after(old_rule,r);
renumberRules(); renumberRules();
return(r); return(r);
@ -211,7 +211,7 @@ bool RuleSet::deleteRule(int rule_n)
bool RuleSet::deleteRule(Rule *r) bool RuleSet::deleteRule(Rule *r)
{ {
if (r!=NULL) if (r!=nullptr)
{ {
remove(r, true); // and delete the rule if ref counter == 0 remove(r, true); // and delete the rule if ref counter == 0
renumberRules(); renumberRules();
@ -284,12 +284,12 @@ bool RuleSet::moveRule(int src_rule_n, int dst_rule_n)
FWObject* src =getRuleByNum( src_rule_n ); FWObject* src =getRuleByNum( src_rule_n );
FWObject* dst =getRuleByNum( dst_rule_n ); FWObject* dst =getRuleByNum( dst_rule_n );
if (src!=NULL && dst!=NULL && src!=dst ) { if (src!=nullptr && dst!=nullptr && src!=dst ) {
FWObject *o; FWObject *o;
list<FWObject*>::iterator m, m1, m2; list<FWObject*>::iterator m, m1, m2;
for (m=begin(); m!=end(); ++m) { for (m=begin(); m!=end(); ++m) {
if ( (o=(*m))!=NULL ) { if ( (o=(*m))!=nullptr ) {
if ( o==src ) m1=m; if ( o==src ) m1=m;
if ( o==dst ) m2=m; if ( o==dst ) m2=m;
} }
@ -354,14 +354,14 @@ Rule* RuleSet::getRuleByNum(int n)
for(list<FWObject*>::iterator m=begin(); m!=end(); ++m) for(list<FWObject*>::iterator m=begin(); m!=end(); ++m)
{ {
FWObject *o; FWObject *o;
if ( (o=(*m))!=NULL ) if ( (o=(*m))!=nullptr )
{ {
Rule *r = Rule::cast(o); Rule *r = Rule::cast(o);
if (r && r->getPosition()==n) if (r && r->getPosition()==n)
return r; return r;
} }
} }
return NULL; return nullptr;
} }
int RuleSet::getRuleSetSize() int RuleSet::getRuleSetSize()
@ -374,7 +374,7 @@ void RuleSet::assignUniqueRuleIds()
for (FWObject::iterator it=begin(); it!=end(); ++it) for (FWObject::iterator it=begin(); it!=end(); ++it)
{ {
Rule *r = Rule::cast(*it); Rule *r = Rule::cast(*it);
if (r != NULL && r->getUniqueId().empty()) if (r != nullptr && r->getUniqueId().empty())
r->setUniqueId(FWObjectDatabase::getStringId((*it)->getId()) ); r->setUniqueId(FWObjectDatabase::getStringId((*it)->getId()) );
} }

View File

@ -59,14 +59,14 @@ ServiceGroup::~ServiceGroup() {}
bool ServiceGroup::validateChild(FWObject *o) bool ServiceGroup::validateChild(FWObject *o)
{ {
if (FWServiceReference::cast(o)!=NULL) return true; if (FWServiceReference::cast(o)!=nullptr) return true;
return (FWObject::validateChild(o) && return (FWObject::validateChild(o) &&
Address::cast(o)==NULL && Address::cast(o)==nullptr &&
ObjectGroup::cast(o)==NULL && ObjectGroup::cast(o)==nullptr &&
Interval::cast(o)==NULL && Interval::cast(o)==nullptr &&
FWObjectReference::cast(o)==NULL && FWObjectReference::cast(o)==nullptr &&
RuleSet::cast(o)==NULL); RuleSet::cast(o)==nullptr);
} }
FWReference* ServiceGroup::createRef() FWReference* ServiceGroup::createRef()

View File

@ -81,7 +81,7 @@ void TCPService::fromXML(xmlNodePtr root)
const char *n; const char *n;
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("established"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("established")));
if(n!=NULL) if(n!=nullptr)
{ {
setStr("established", n); setStr("established", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
@ -91,7 +91,7 @@ void TCPService::fromXML(xmlNodePtr root)
for (i=flags.begin(); i!=flags.end(); ++i) for (i=flags.begin(); i!=flags.end(); ++i)
{ {
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST( (i->second).c_str() ))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST( (i->second).c_str() )));
if(n!=NULL) if(n!=nullptr)
{ {
setStr( i->second , n); setStr( i->second , n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
@ -101,7 +101,7 @@ void TCPService::fromXML(xmlNodePtr root)
for (i=flags_masks.begin(); i!=flags_masks.end(); ++i) for (i=flags_masks.begin(); i!=flags_masks.end(); ++i)
{ {
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST( (i->second).c_str() ))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST( (i->second).c_str() )));
if(n!=NULL) if(n!=nullptr)
{ {
setStr( i->second , n); setStr( i->second , n);
FREEXMLBUFF(n); FREEXMLBUFF(n);

View File

@ -56,28 +56,28 @@ void TCPUDPService::fromXML(xmlNodePtr root)
const char *n; const char *n;
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("src_range_start"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("src_range_start")));
if(n!=NULL) if(n!=nullptr)
{ {
src_range_start = atol(n); src_range_start = atol(n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("src_range_end"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("src_range_end")));
if(n!=NULL) if(n!=nullptr)
{ {
src_range_end = atol(n); src_range_end = atol(n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dst_range_start"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dst_range_start")));
if(n!=NULL) if(n!=nullptr)
{ {
dst_range_start = atol(n); dst_range_start = atol(n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }
n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dst_range_end"))); n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("dst_range_end")));
if(n!=NULL) if(n!=nullptr)
{ {
dst_range_end = atol(n); dst_range_end = atol(n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
@ -121,7 +121,7 @@ FWObject& TCPUDPService::shallowDuplicate(const FWObject *obj,
bool TCPUDPService::cmp(const FWObject *obj, bool recursive) bool TCPUDPService::cmp(const FWObject *obj, bool recursive)
{ {
const TCPUDPService *other = TCPUDPService::constcast(obj); const TCPUDPService *other = TCPUDPService::constcast(obj);
if (other == NULL) return false; if (other == nullptr) return false;
if (src_range_start != other->src_range_start || if (src_range_start != other->src_range_start ||
src_range_end != other->src_range_end || src_range_end != other->src_range_end ||
dst_range_start != other->dst_range_start || dst_range_start != other->dst_range_start ||

View File

@ -62,7 +62,7 @@ void TagService::fromXML(xmlNodePtr root)
FWObject::fromXML(root); FWObject::fromXML(root);
const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("tagcode"))); const char *n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("tagcode")));
assert(n!=NULL); assert(n!=nullptr);
setStr("tagcode", n); setStr("tagcode", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);

View File

@ -68,7 +68,7 @@ void Mutex::unlock() const
Cond::Cond() Cond::Cond()
{ {
pthread_cond_init( &cond, NULL ); pthread_cond_init( &cond, nullptr );
} }
Cond::~Cond() Cond::~Cond()

View File

@ -68,7 +68,7 @@ char *cxx_strdup(const string &x)
char *cxx_strdup(const char *x) char *cxx_strdup(const char *x)
{ {
if(!x) if(!x)
return (char*)NULL; return (char*)nullptr;
char *res=new char[strlen(x)+1]; char *res=new char[strlen(x)+1];
strcpy(res,x); strcpy(res,x);
@ -130,10 +130,10 @@ list<string> getDirList(const std::string &dir,
#ifndef _WIN32 #ifndef _WIN32
DIR *d=opendir(dir.c_str()); DIR *d=opendir(dir.c_str());
if (d!=NULL) if (d!=nullptr)
{ {
struct dirent *de; struct dirent *de;
while ( (de=readdir(d))!=NULL ) while ( (de=readdir(d))!=nullptr )
{ {
if (strcmp(de->d_name,".")==SAME || strcmp(de->d_name,"..")==SAME) if (strcmp(de->d_name,".")==SAME || strcmp(de->d_name,"..")==SAME)
continue; continue;

View File

@ -76,7 +76,7 @@ xmlNodePtr UserService::toXML(xmlNodePtr parent)
bool UserService::cmp(const FWObject *obj, bool recursive) bool UserService::cmp(const FWObject *obj, bool recursive)
{ {
if (UserService::constcast(obj)==NULL) return false; if (UserService::constcast(obj)==nullptr) return false;
if (!FWObject::cmp(obj, recursive)) return false; if (!FWObject::cmp(obj, recursive)) return false;
const UserService *user_serv = UserService::constcast(obj); const UserService *user_serv = UserService::constcast(obj);

View File

@ -98,7 +98,7 @@ static void xslt_error_handler(void *ctx, const char *msg, ...)
char buf[4096]; char buf[4096];
va_list args; va_list args;
assert(ctx!=NULL); assert(ctx!=nullptr);
va_start(args, msg); va_start(args, msg);
#ifdef _WIN32 #ifdef _WIN32
@ -125,7 +125,7 @@ xmlNodePtr XMLTools::getXmlChildNode(xmlNodePtr r,const char *child_name)
if (strcmp(child_name,FROMXMLCAST(cur->name))==SAME) if (strcmp(child_name,FROMXMLCAST(cur->name))==SAME)
return cur; return cur;
} }
return NULL; return nullptr;
} }
@ -140,7 +140,7 @@ xmlNodePtr XMLTools::getXmlNodeByPath(xmlNodePtr r, const char *path)
char *path_copy; char *path_copy;
xmlNodePtr cur, res; xmlNodePtr cur, res;
res=NULL; res=nullptr;
path_copy= cxx_strdup( path ); path_copy= cxx_strdup( path );
@ -155,7 +155,7 @@ xmlNodePtr XMLTools::getXmlNodeByPath(xmlNodePtr r, const char *path)
} }
cptr=strchr(s1,'/'); cptr=strchr(s1,'/');
if (cptr!=NULL) { if (cptr!=nullptr) {
*cptr='\0'; *cptr='\0';
cptr++; cptr++;
} }
@ -177,14 +177,14 @@ xmlNodePtr XMLTools::getXmlNodeByPath(xmlNodePtr r, const char *path)
} }
xmlExternalEntityLoader XMLTools::defaultLoader = NULL; xmlExternalEntityLoader XMLTools::defaultLoader = nullptr;
/** /**
* This is global variable used in 'fwbExternalEntityLoader' * This is global variable used in 'fwbExternalEntityLoader'
* parser callback. It is protected by 'xml_parser_mutex'. * parser callback. It is protected by 'xml_parser_mutex'.
*/ */
static char* current_template_dir=NULL; static char* current_template_dir=nullptr;
xmlParserInputPtr fwbExternalEntityLoader(const char *URL, xmlParserInputPtr fwbExternalEntityLoader(const char *URL,
const char *ID, const char *ID,
@ -213,7 +213,7 @@ xmlParserInputPtr fwbExternalEntityLoader(const char *URL,
else if(XMLTools::defaultLoader) else if(XMLTools::defaultLoader)
return XMLTools::defaultLoader(URL, ID, ctxt); return XMLTools::defaultLoader(URL, ID, ctxt);
else else
return NULL; return nullptr;
} }
void XMLTools::initXMLTools() void XMLTools::initXMLTools()
@ -249,7 +249,7 @@ string XMLTools::readFile(const std::string &rfile)
} }
gzFile gzf = gzopen(rfile.c_str(), "rb9"); gzFile gzf = gzopen(rfile.c_str(), "rb9");
if (gzf == NULL) throw FWException("Could not read file "+rfile); if (gzf == nullptr) throw FWException("Could not read file "+rfile);
int chunk_size = 65536; int chunk_size = 65536;
char *chunk = (char*)malloc(chunk_size); char *chunk = (char*)malloc(chunk_size);
@ -284,7 +284,7 @@ xmlDocPtr XMLTools::parseFile(const string &file_name,
{ {
xml_parser_mutex.lock(); xml_parser_mutex.lock();
if (current_template_dir!=NULL) delete[] current_template_dir; if (current_template_dir!=nullptr) delete[] current_template_dir;
current_template_dir = cxx_strdup(template_dir.c_str()); current_template_dir = cxx_strdup(template_dir.c_str());
xmlDoValidityCheckingDefaultValue = use_dtd ? 1 : 0; xmlDoValidityCheckingDefaultValue = use_dtd ? 1 : 0;
@ -296,7 +296,7 @@ xmlDocPtr XMLTools::parseFile(const string &file_name,
xmlDocPtr doc = xmlParseMemory(buffer.c_str(), buffer.length()); xmlDocPtr doc = xmlParseMemory(buffer.c_str(), buffer.length());
xmlSetGenericErrorFunc(NULL, NULL); xmlSetGenericErrorFunc(nullptr, nullptr);
xml_parser_mutex.unlock(); xml_parser_mutex.unlock();
if (!doc || errors.length()) if (!doc || errors.length())
@ -422,7 +422,7 @@ in the same directory with extension '.bak'. Are you sure you want to open it?";
throw; throw;
} }
} }
assert(doc!=NULL); assert(doc!=nullptr);
xmlFreeDoc(doc); xmlFreeDoc(doc);
//xmlCleanupParser(); //xmlCleanupParser();
@ -443,7 +443,7 @@ void XMLTools::setDTD(xmlDocPtr doc,
xmlCreateIntSubset(doc, STRTOXMLCAST(type_name), xmlCreateIntSubset(doc, STRTOXMLCAST(type_name),
NULL, nullptr,
STRTOXMLCAST(dtd_file) STRTOXMLCAST(dtd_file)
); );
@ -477,12 +477,12 @@ void XMLTools::setDTD(xmlDocPtr doc,
if(xmlValidateDocument(&vctxt, doc)!=1) if(xmlValidateDocument(&vctxt, doc)!=1)
throw FWException(string("DTD validation stage 2 failed with following errors:\n")+errors); throw FWException(string("DTD validation stage 2 failed with following errors:\n")+errors);
*/ */
xmlSetGenericErrorFunc (NULL, NULL); xmlSetGenericErrorFunc (nullptr, nullptr);
xml_parser_mutex.unlock(); xml_parser_mutex.unlock();
} catch(...) } catch(...)
{ {
xmlSetGenericErrorFunc (NULL, NULL); xmlSetGenericErrorFunc (nullptr, nullptr);
xml_parser_mutex.unlock(); xml_parser_mutex.unlock();
throw; throw;
} }
@ -527,7 +527,7 @@ void XMLTools::transformFileToFile(const string &src_file,
const string &dst_file) const string &dst_file)
{ {
string xslt_errors; string xslt_errors;
xsltStylesheetPtr ss = NULL; xsltStylesheetPtr ss = nullptr;
xmlDocPtr doc, res; xmlDocPtr doc, res;
@ -547,12 +547,12 @@ void XMLTools::transformFileToFile(const string &src_file,
if(!ss) if(!ss)
{ {
xsltSetGenericErrorFunc(NULL, NULL); xsltSetGenericErrorFunc(nullptr, nullptr);
xmlSetGenericErrorFunc (NULL, NULL); xmlSetGenericErrorFunc (nullptr, nullptr);
// Following line is workaround for bug #73088 in Gnome // Following line is workaround for bug #73088 in Gnome
// bugzilla. To be removed than it will be fixed. // bugzilla. To be removed than it will be fixed.
xsltSetGenericDebugFunc (NULL, NULL); xsltSetGenericDebugFunc (nullptr, nullptr);
xml_parser_mutex.unlock(); xml_parser_mutex.unlock();
xslt_processor_mutex.unlock(); xslt_processor_mutex.unlock();
throw FWException("File conversion error: Error loading stylesheet: " + throw FWException("File conversion error: Error loading stylesheet: " +
@ -568,12 +568,12 @@ void XMLTools::transformFileToFile(const string &src_file,
res = xsltApplyStylesheet(ss, doc, params); res = xsltApplyStylesheet(ss, doc, params);
xsltSaveResultToFilename(dst_file.c_str(), res, ss, 0); xsltSaveResultToFilename(dst_file.c_str(), res, ss, 0);
xsltSetGenericErrorFunc(NULL, NULL); xsltSetGenericErrorFunc(nullptr, nullptr);
xmlSetGenericErrorFunc (NULL, NULL); xmlSetGenericErrorFunc (nullptr, nullptr);
// Following line is workaround for bug #73088 in Gnome // Following line is workaround for bug #73088 in Gnome
// bugzilla. To be removed than it will be fixed. // bugzilla. To be removed than it will be fixed.
xsltSetGenericDebugFunc (NULL, NULL); xsltSetGenericDebugFunc (nullptr, nullptr);
xml_parser_mutex.unlock(); xml_parser_mutex.unlock();
xslt_processor_mutex.unlock(); xslt_processor_mutex.unlock();
@ -628,12 +628,12 @@ void XMLTools::transformDocumentToFile(xmlDocPtr doc,
if (!ss) if (!ss)
{ {
xsltSetGenericErrorFunc(NULL, NULL); xsltSetGenericErrorFunc(nullptr, nullptr);
xmlSetGenericErrorFunc (NULL, NULL); xmlSetGenericErrorFunc (nullptr, nullptr);
// Following line is workaround for bug #73088 in Gnome // Following line is workaround for bug #73088 in Gnome
// bugzilla. To be removed than it will be fixed. // bugzilla. To be removed than it will be fixed.
xsltSetGenericDebugFunc (NULL, NULL); xsltSetGenericDebugFunc (nullptr, nullptr);
xml_parser_mutex.unlock(); xml_parser_mutex.unlock();
xslt_processor_mutex.unlock(); xslt_processor_mutex.unlock();
throw FWException("File conversion error: Error loading stylesheet: " + throw FWException("File conversion error: Error loading stylesheet: " +
@ -645,12 +645,12 @@ void XMLTools::transformDocumentToFile(xmlDocPtr doc,
xmlDocPtr res = xsltApplyStylesheet(ss, doc, params); xmlDocPtr res = xsltApplyStylesheet(ss, doc, params);
xsltSetGenericErrorFunc(NULL, NULL); xsltSetGenericErrorFunc(nullptr, nullptr);
xmlSetGenericErrorFunc (NULL, NULL); xmlSetGenericErrorFunc (nullptr, nullptr);
// Following line is workaround for bug #73088 in Gnome // Following line is workaround for bug #73088 in Gnome
// bugzilla. To be removed than it will be fixed. // bugzilla. To be removed than it will be fixed.
xsltSetGenericDebugFunc (NULL, NULL); xsltSetGenericDebugFunc (nullptr, nullptr);
xml_parser_mutex.unlock(); xml_parser_mutex.unlock();
xslt_processor_mutex.unlock(); xslt_processor_mutex.unlock();
@ -700,11 +700,11 @@ xmlDocPtr XMLTools::transformDocument(xmlDocPtr doc,
if (!ss) if (!ss)
{ {
xsltSetGenericErrorFunc(NULL, NULL); xsltSetGenericErrorFunc(nullptr, nullptr);
xmlSetGenericErrorFunc (NULL, NULL); xmlSetGenericErrorFunc (nullptr, nullptr);
// Following line is workaround for bug #73088 in Gnome // Following line is workaround for bug #73088 in Gnome
// bugzilla. To be removed than it will be fixed. // bugzilla. To be removed than it will be fixed.
xsltSetGenericDebugFunc (NULL, NULL); xsltSetGenericDebugFunc (nullptr, nullptr);
xml_parser_mutex.unlock(); xml_parser_mutex.unlock();
xslt_processor_mutex.unlock(); xslt_processor_mutex.unlock();
@ -716,11 +716,11 @@ xmlDocPtr XMLTools::transformDocument(xmlDocPtr doc,
xmlDocPtr res = xsltApplyStylesheet(ss, doc, params); xmlDocPtr res = xsltApplyStylesheet(ss, doc, params);
xsltFreeStylesheet(ss); xsltFreeStylesheet(ss);
xsltSetGenericErrorFunc(NULL, NULL); xsltSetGenericErrorFunc(nullptr, nullptr);
xmlSetGenericErrorFunc (NULL, NULL); xmlSetGenericErrorFunc (nullptr, nullptr);
// Following line is workaround for bug #73088 in Gnome // Following line is workaround for bug #73088 in Gnome
// bugzilla. To be removed than it will be fixed. // bugzilla. To be removed than it will be fixed.
xsltSetGenericDebugFunc (NULL, NULL); xsltSetGenericDebugFunc (nullptr, nullptr);
xml_parser_mutex.unlock(); xml_parser_mutex.unlock();
xslt_processor_mutex.unlock(); xslt_processor_mutex.unlock();
@ -741,7 +741,7 @@ xmlDocPtr XMLTools::convert(xmlDocPtr doc,
const string &template_dir, const string &template_dir,
const string &current_version) const string &current_version)
{ {
xmlDocPtr res = NULL; xmlDocPtr res = nullptr;
xmlNodePtr root = xmlDocGetRootElement(doc); xmlNodePtr root = xmlDocGetRootElement(doc);
if (!root || !root->name || type_name!=FROMXMLCAST(root->name)) if (!root || !root->name || type_name!=FROMXMLCAST(root->name))
@ -753,7 +753,7 @@ xmlDocPtr XMLTools::convert(xmlDocPtr doc,
string vers; string vers;
const char *v = FROMXMLCAST(xmlGetProp(root,TOXMLCAST("version"))); const char *v = FROMXMLCAST(xmlGetProp(root,TOXMLCAST("version")));
if (v==NULL) if (v==nullptr)
{ {
// no version. // no version.
v="0.8.7"; // at this version attribute has been introduced v="0.8.7"; // at this version attribute has been introduced
@ -817,7 +817,7 @@ xmlDocPtr XMLTools::convert(xmlDocPtr doc,
try try
{ {
res = transformDocument(doc, fname, NULL); res = transformDocument(doc, fname, nullptr);
} catch(FWException &ex) } catch(FWException &ex)
{ {
ex.getProperties()["failed_transformation"]=fname; ex.getProperties()["failed_transformation"]=fname;
@ -839,7 +839,7 @@ xmlDocPtr XMLTools::convert(xmlDocPtr doc,
} }
v = FROMXMLCAST(xmlGetProp(root, TOXMLCAST("version"))); v = FROMXMLCAST(xmlGetProp(root, TOXMLCAST("version")));
if (v==NULL) if (v==nullptr)
{ {
xmlFreeDoc(doc); xmlFreeDoc(doc);
//xmlCleanupParser(); //xmlCleanupParser();

View File

@ -58,14 +58,14 @@ using namespace libfwbuilder;
#undef DEBUG_DNS #undef DEBUG_DNS
Mutex *DNS::gethostbyname_mutex = NULL; Mutex *DNS::gethostbyname_mutex = nullptr;
Mutex *DNS::gethostbyaddr_mutex = NULL; Mutex *DNS::gethostbyaddr_mutex = nullptr;
// use this function for delayed initialization // use this function for delayed initialization
void DNS::init() void DNS::init()
{ {
if (gethostbyname_mutex==NULL) gethostbyname_mutex = new Mutex(); if (gethostbyname_mutex==nullptr) gethostbyname_mutex = new Mutex();
if (gethostbyaddr_mutex==NULL) gethostbyaddr_mutex = new Mutex(); if (gethostbyaddr_mutex==nullptr) gethostbyaddr_mutex = new Mutex();
} }
/* /*
@ -94,7 +94,7 @@ HostEnt DNS::getHostByAddr(const InetAddr &addr, int type)
type); type);
} }
if(hp==NULL) if(hp==nullptr)
{ {
gethostbyaddr_mutex->unlock(); gethostbyaddr_mutex->unlock();
free(tmphstbuf); free(tmphstbuf);
@ -118,14 +118,14 @@ list<InetAddr> DNS::getHostByName(const string &name, int type)
list<InetAddr> v; list<InetAddr> v;
struct addrinfo *aiList = NULL; struct addrinfo *aiList = nullptr;
int retVal; int retVal;
#ifdef DEBUG_DNS #ifdef DEBUG_DNS
cerr << "DNS::getHostByName " << name << " type=" << type << endl; cerr << "DNS::getHostByName " << name << " type=" << type << endl;
#endif #endif
if ((retVal = getaddrinfo(name.c_str(), NULL, NULL, &aiList)) != 0) if ((retVal = getaddrinfo(name.c_str(), nullptr, nullptr, &aiList)) != 0)
{ {
std::ostringstream strerr; std::ostringstream strerr;
strerr << "Host or network '" + name + "' not found; last error: "; strerr << "Host or network '" + name + "' not found; last error: ";
@ -140,7 +140,7 @@ list<InetAddr> DNS::getHostByName(const string &name, int type)
struct addrinfo *ai; struct addrinfo *ai;
try try
{ {
for (ai=aiList; ai!=NULL; ai=ai->ai_next) for (ai=aiList; ai!=nullptr; ai=ai->ai_next)
{ {
#ifdef DEBUG_DNS #ifdef DEBUG_DNS
cerr << "DNS::getHostByName " << name cerr << "DNS::getHostByName " << name

View File

@ -50,7 +50,7 @@ void physAddress::fromXML(xmlNodePtr root)
FWObject::fromXML(root); FWObject::fromXML(root);
const char* n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("address"))); const char* n=FROMXMLCAST(xmlGetProp(root,TOXMLCAST("address")));
assert(n!=NULL); assert(n!=nullptr);
setStr("address", n); setStr("address", n);
FREEXMLBUFF(n); FREEXMLBUFF(n);
} }

View File

@ -82,7 +82,7 @@ void Compiler::epilog()
void Compiler::abort(const string &errstr) void Compiler::abort(const string &errstr)
{ {
BaseCompiler::abort(fw, source_ruleset, NULL, errstr); BaseCompiler::abort(fw, source_ruleset, nullptr, errstr);
} }
void Compiler::abort(FWObject *rule, const string &errstr) void Compiler::abort(FWObject *rule, const string &errstr)
@ -92,7 +92,7 @@ void Compiler::abort(FWObject *rule, const string &errstr)
void Compiler::error(const string &errstr) void Compiler::error(const string &errstr)
{ {
BaseCompiler::error(fw, source_ruleset, NULL, errstr); BaseCompiler::error(fw, source_ruleset, nullptr, errstr);
} }
void Compiler::error(FWObject *rule, const string &errstr) void Compiler::error(FWObject *rule, const string &errstr)
@ -102,7 +102,7 @@ void Compiler::error(FWObject *rule, const string &errstr)
void Compiler::warning(const string &errstr) void Compiler::warning(const string &errstr)
{ {
BaseCompiler::warning(fw, source_ruleset, NULL, errstr); BaseCompiler::warning(fw, source_ruleset, nullptr, errstr);
} }
void Compiler::warning(FWObject *rule, const string &errstr) void Compiler::warning(FWObject *rule, const string &errstr)
@ -136,9 +136,9 @@ void Compiler::_init(FWObjectDatabase *_db, Firewall *_fw)
{ {
initialized = false; initialized = false;
_cntr_ = 1; _cntr_ = 1;
group_registry = NULL; group_registry = nullptr;
temp_ruleset = NULL; temp_ruleset = nullptr;
debug = 0; debug = 0;
debug_rule = -1; debug_rule = -1;
@ -148,13 +148,13 @@ void Compiler::_init(FWObjectDatabase *_db, Firewall *_fw)
single_rule_ruleset_name = ""; single_rule_ruleset_name = "";
single_rule_position = -1; single_rule_position = -1;
dbcopy = NULL; dbcopy = nullptr;
persistent_objects = NULL; persistent_objects = nullptr;
fw = NULL; fw = nullptr;
fwopt = NULL; fwopt = nullptr;
fw_id = -1; fw_id = -1;
if (_db != NULL && _fw != NULL) if (_db != nullptr && _fw != nullptr)
{ {
assert(_fw->getRoot() == _db); assert(_fw->getRoot() == _db);
@ -174,40 +174,40 @@ void Compiler::_init(FWObjectDatabase *_db, Firewall *_fw)
Compiler::Compiler(FWObjectDatabase *_db, Firewall *fw, bool ipv6_policy) Compiler::Compiler(FWObjectDatabase *_db, Firewall *fw, bool ipv6_policy)
{ {
source_ruleset = NULL; source_ruleset = nullptr;
ruleSetName = ""; ruleSetName = "";
osconfigurator = NULL; osconfigurator = nullptr;
countIPv6Rules = 0; countIPv6Rules = 0;
ipv6 = ipv6_policy; ipv6 = ipv6_policy;
persistent_objects = NULL; persistent_objects = nullptr;
_init(_db, fw); _init(_db, fw);
} }
Compiler::Compiler(FWObjectDatabase *_db, Firewall *fw, bool ipv6_policy, Compiler::Compiler(FWObjectDatabase *_db, Firewall *fw, bool ipv6_policy,
OSConfigurator *_oscnf) OSConfigurator *_oscnf)
{ {
source_ruleset = NULL; source_ruleset = nullptr;
ruleSetName = ""; ruleSetName = "";
osconfigurator = _oscnf; osconfigurator = _oscnf;
countIPv6Rules = 0; countIPv6Rules = 0;
ipv6 = ipv6_policy; ipv6 = ipv6_policy;
persistent_objects = NULL; persistent_objects = nullptr;
_init(_db, fw); _init(_db, fw);
} }
// this constructor is used by class Preprocessor, it does not call _init // this constructor is used by class Preprocessor, it does not call _init
Compiler::Compiler(FWObjectDatabase*, bool ipv6_policy) Compiler::Compiler(FWObjectDatabase*, bool ipv6_policy)
{ {
source_ruleset = NULL; source_ruleset = nullptr;
ruleSetName = ""; ruleSetName = "";
osconfigurator = NULL; osconfigurator = nullptr;
countIPv6Rules = 0; countIPv6Rules = 0;
ipv6 = ipv6_policy; ipv6 = ipv6_policy;
initialized = false; initialized = false;
_cntr_ = 1; _cntr_ = 1;
persistent_objects = NULL; persistent_objects = nullptr;
fw = NULL; fw = nullptr;
temp_ruleset = NULL; temp_ruleset = nullptr;
debug = 0; debug = 0;
debug_rule = -1; debug_rule = -1;
rule_debug_on = false; rule_debug_on = false;
@ -218,7 +218,7 @@ Compiler::Compiler(FWObjectDatabase*, bool ipv6_policy)
Compiler::~Compiler() Compiler::~Compiler()
{ {
deleteRuleProcessors(); deleteRuleProcessors();
dbcopy = NULL; dbcopy = nullptr;
} }
void Compiler::setPersistentObjects(Library* po) void Compiler::setPersistentObjects(Library* po)
@ -291,8 +291,8 @@ void Compiler::_expand_group_recursive(FWObject *o, list<FWObject*> &ol)
*/ */
MultiAddress *adt = MultiAddress::cast(o); MultiAddress *adt = MultiAddress::cast(o);
if ((Group::cast(o)!=NULL && adt==NULL) || if ((Group::cast(o)!=nullptr && adt==nullptr) ||
(adt!=NULL && adt->isCompileTime())) (adt!=nullptr && adt->isCompileTime()))
{ {
for (FWObject::iterator i2=o->begin(); i2!=o->end(); ++i2) for (FWObject::iterator i2=o->begin(); i2!=o->end(); ++i2)
{ {
@ -406,7 +406,7 @@ void Compiler::_expand_addr_recursive(Rule *rule, FWObject *s,
} }
if (o->getId() == FWObjectDatabase::ANY_ADDRESS_ID || if (o->getId() == FWObjectDatabase::ANY_ADDRESS_ID ||
MultiAddress::cast(o)!=NULL || MultiAddress::cast(o)!=nullptr ||
Interface::cast(o) || Interface::cast(o) ||
physAddress::cast(o)) physAddress::cast(o))
{ {
@ -417,7 +417,7 @@ void Compiler::_expand_addr_recursive(Rule *rule, FWObject *s,
if (addrlist.empty()) if (addrlist.empty())
{ {
if (RuleElement::cast(s)==NULL) ol.push_back(s); if (RuleElement::cast(s)==nullptr) ol.push_back(s);
} }
else else
{ {
@ -480,15 +480,15 @@ void Compiler::_expand_interface(Rule *rule,
FWObject *p = Host::getParentHost(iface); FWObject *p = Host::getParentHost(iface);
//FWObject *p = iface->getParentHost(); //FWObject *p = iface->getParentHost();
Host *hp = Host::cast(p); Host *hp = Host::cast(p);
if (hp==NULL) return; // something is very broken if (hp==nullptr) return; // something is very broken
FWOptions *hopt = hp->getOptionsObject(); FWOptions *hopt = hp->getOptionsObject();
bool use_mac = (hopt!=NULL && hopt->getBool("use_mac_addr_filter")); bool use_mac = (hopt!=nullptr && hopt->getBool("use_mac_addr_filter"));
for (FWObject::iterator i1=iface->begin(); i1!=iface->end(); ++i1) for (FWObject::iterator i1=iface->begin(); i1!=iface->end(); ++i1)
{ {
FWObject *o= *i1; FWObject *o= *i1;
if (physAddress::cast(o)!=NULL) if (physAddress::cast(o)!=nullptr)
{ {
if (use_mac) ol.push_back(o); if (use_mac) ol.push_back(o);
continue; continue;
@ -504,7 +504,7 @@ void Compiler::_expand_interface(Rule *rule,
} }
if ( ! iface->isUnnumbered() && if ( ! iface->isUnnumbered() &&
Address::cast(o)!=NULL && Address::cast(o)!=nullptr &&
MatchesAddressFamily(o)) ol.push_back(o); MatchesAddressFamily(o)) ol.push_back(o);
} }
@ -540,7 +540,7 @@ bool compare_addresses(FWObject *o1, FWObject *o2)
{ {
Address *a1 = Address::cast(o1); Address *a1 = Address::cast(o1);
Address *a2 = Address::cast(o2); Address *a2 = Address::cast(o2);
if (a1 == NULL || a2 == NULL) if (a1 == nullptr || a2 == nullptr)
{ {
// one or both could be MultiAddress objects (e.g. DNSName) // one or both could be MultiAddress objects (e.g. DNSName)
return o1->getName() < o2->getName(); return o1->getName() < o2->getName();
@ -548,8 +548,8 @@ bool compare_addresses(FWObject *o1, FWObject *o2)
const InetAddr *addr1 = a1->getAddressPtr(); const InetAddr *addr1 = a1->getAddressPtr();
const InetAddr *addr2 = a2->getAddressPtr(); const InetAddr *addr2 = a2->getAddressPtr();
if (addr1 == NULL) return true; if (addr1 == nullptr) return true;
if (addr2 == NULL) return false; if (addr2 == nullptr) return false;
return *addr1 < *addr2; return *addr1 < *addr2;
} }
@ -594,7 +594,7 @@ void Compiler::_expandAddressRanges(Rule *rule, FWObject *re)
for (FWObject::iterator i1=re->begin(); i1!=re->end(); ++i1) for (FWObject::iterator i1=re->begin(); i1!=re->end(); ++i1)
{ {
FWObject *o = FWReference::getObject(*i1); FWObject *o = FWReference::getObject(*i1);
assert(o!=NULL); assert(o!=nullptr);
// if this is address range, check if it matches current address // if this is address range, check if it matches current address
// family. If it is not address range, put it back into the rule element // family. If it is not address range, put it back into the rule element
@ -628,7 +628,7 @@ void Compiler::_expandAddressRanges(Rule *rule, FWObject *re)
cl.push_back(h); cl.push_back(h);
// see GroupRegistry::registerGroupObject() // see GroupRegistry::registerGroupObject()
if (group_registry != NULL) if (group_registry != nullptr)
{ {
group_registry->setGroupRegistryKey( group_registry->setGroupRegistryKey(
h, group_registry->getGroupRegistryKey(aro)); h, group_registry->getGroupRegistryKey(aro));
@ -659,7 +659,7 @@ void Compiler::debugRule()
i!=source_ruleset->end(); i++) i!=source_ruleset->end(); i++)
{ {
Rule *rule = Rule::cast( *i ); Rule *rule = Rule::cast( *i );
if (rule == NULL) continue; if (rule == nullptr) continue;
if (rule_debug_on && rule->getPosition()==debug_rule ) if (rule_debug_on && rule->getPosition()==debug_rule )
{ {
info(debugPrintRule(rule)); info(debugPrintRule(rule));
@ -687,7 +687,7 @@ string Compiler::debugPrintRule(libfwbuilder::Rule *rule)
void Compiler::add(BasicRuleProcessor* rp) void Compiler::add(BasicRuleProcessor* rp)
{ {
rule_processors.push_back(rp); rule_processors.push_back(rp);
if (rule_debug_on && dynamic_cast<simplePrintProgress*>(rp)==NULL) if (rule_debug_on && dynamic_cast<simplePrintProgress*>(rp)==nullptr)
rule_processors.push_back(new Debug()); rule_processors.push_back(new Debug());
} }
@ -728,14 +728,14 @@ Compiler::Begin::Begin(const std::string &n) : BasicRuleProcessor(n)
bool Compiler::Begin::processNext() bool Compiler::Begin::processNext()
{ {
assert(compiler!=NULL); assert(compiler!=nullptr);
if (!init) if (!init)
{ {
for (FWObject::iterator i=compiler->source_ruleset->begin(); for (FWObject::iterator i=compiler->source_ruleset->begin();
i!=compiler->source_ruleset->end(); ++i) i!=compiler->source_ruleset->end(); ++i)
{ {
Rule *rule = Rule::cast(*i); Rule *rule = Rule::cast(*i);
if (rule == NULL) continue; if (rule == nullptr) continue;
if (rule->isDisabled()) continue; if (rule->isDisabled()) continue;
if (rule->isDummyRule()) { if (rule->isDummyRule()) {
compiler->warning(rule, "Rule contains dummy object and is not parsed."); compiler->warning(rule, "Rule contains dummy object and is not parsed.");
@ -759,8 +759,8 @@ bool Compiler::Begin::processNext()
bool Compiler::printTotalNumberOfRules::processNext() bool Compiler::printTotalNumberOfRules::processNext()
{ {
assert(compiler!=NULL); assert(compiler!=nullptr);
assert(prev_processor!=NULL); assert(prev_processor!=nullptr);
slurp(); slurp();
if (tmp_queue.size()==0) return false; if (tmp_queue.size()==0) return false;
@ -775,8 +775,8 @@ bool Compiler::printTotalNumberOfRules::processNext()
bool Compiler::createNewCompilerPass::processNext() bool Compiler::createNewCompilerPass::processNext()
{ {
assert(compiler!=NULL); assert(compiler!=nullptr);
assert(prev_processor!=NULL); assert(prev_processor!=nullptr);
slurp(); slurp();
if (tmp_queue.size()==0) return false; if (tmp_queue.size()==0) return false;
@ -786,8 +786,8 @@ bool Compiler::createNewCompilerPass::processNext()
bool Compiler::Debug::processNext() bool Compiler::Debug::processNext()
{ {
assert(compiler!=NULL); assert(compiler!=nullptr);
assert(prev_processor!=NULL); assert(prev_processor!=nullptr);
slurp(); slurp();
if (tmp_queue.size()==0) return false; if (tmp_queue.size()==0) return false;
@ -813,10 +813,10 @@ bool Compiler::Debug::processNext()
bool Compiler::singleRuleFilter::processNext() bool Compiler::singleRuleFilter::processNext()
{ {
assert(compiler!=NULL); assert(compiler!=nullptr);
assert(prev_processor!=NULL); assert(prev_processor!=nullptr);
Rule *rule = prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule = prev_processor->getNextRule(); if (rule==nullptr) return false;
if (!compiler->single_rule_mode) if (!compiler->single_rule_mode)
{ {
@ -833,7 +833,7 @@ bool Compiler::singleRuleFilter::processNext()
bool Compiler::simplePrintProgress::processNext() bool Compiler::simplePrintProgress::processNext()
{ {
Rule *rule=prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule=prev_processor->getNextRule(); if (rule==nullptr) return false;
std::string rl=rule->getLabel(); std::string rl=rule->getLabel();
if (rl!=current_rule_label) { if (rl!=current_rule_label) {
@ -856,7 +856,7 @@ bool Compiler::simplePrintProgress::processNext()
*/ */
bool Compiler::splitIfRuleElementMatchesFW::processNext() bool Compiler::splitIfRuleElementMatchesFW::processNext()
{ {
Rule *rule=prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule=prev_processor->getNextRule(); if (rule==nullptr) return false;
RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type)); RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type));
int nre = re->size(); int nre = re->size();
@ -867,7 +867,7 @@ bool Compiler::splitIfRuleElementMatchesFW::processNext()
{ {
FWObject *obj = FWReference::getObject(*i1); FWObject *obj = FWReference::getObject(*i1);
Address *a = Address::cast(obj); Address *a = Address::cast(obj);
assert(a!=NULL); assert(a!=nullptr);
if (a->getId() == compiler->fw->getId() || if (a->getId() == compiler->fw->getId() ||
a->getInt("parent_cluster_id") == compiler->fw->getId() || a->getInt("parent_cluster_id") == compiler->fw->getId() ||
@ -911,7 +911,7 @@ bool Compiler::splitIfRuleElementMatchesFW::processNext()
bool Compiler::ReplaceFirewallObjectWithSelfInRE::processNext() bool Compiler::ReplaceFirewallObjectWithSelfInRE::processNext()
{ {
Rule *rule = prev_processor->getNextRule(); Rule *rule = prev_processor->getNextRule();
if (rule==NULL) return false; if (rule==nullptr) return false;
RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type)); RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type));
for (list<FWObject*>::iterator i1=re->begin(); i1!=re->end(); ++i1) for (list<FWObject*>::iterator i1=re->begin(); i1!=re->end(); ++i1)
@ -922,7 +922,7 @@ bool Compiler::ReplaceFirewallObjectWithSelfInRE::processNext()
DNSName *self = DNSName::cast( DNSName *self = DNSName::cast(
compiler->persistent_objects->findObjectByName( compiler->persistent_objects->findObjectByName(
DNSName::TYPENAME, "self")); DNSName::TYPENAME, "self"));
if (self == NULL) if (self == nullptr)
{ {
self = compiler->dbcopy->createDNSName(); self = compiler->dbcopy->createDNSName();
self->setName("self"); self->setName("self");
@ -944,16 +944,16 @@ bool Compiler::ReplaceFirewallObjectWithSelfInRE::processNext()
bool Compiler::RegisterGroupsAndTablesInRE::processNext() bool Compiler::RegisterGroupsAndTablesInRE::processNext()
{ {
Rule *rule = prev_processor->getNextRule(); Rule *rule = prev_processor->getNextRule();
if (rule==NULL) return false; if (rule==nullptr) return false;
if (compiler->group_registry != NULL) if (compiler->group_registry != nullptr)
{ {
RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type)); RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type));
for (FWObject::iterator i=re->begin(); i!=re->end(); i++) for (FWObject::iterator i=re->begin(); i!=re->end(); i++)
{ {
FWObject *obj = FWReference::getObject(*i); FWObject *obj = FWReference::getObject(*i);
if (ObjectGroup::cast(obj)!=NULL && obj->size() > 0) if (ObjectGroup::cast(obj)!=nullptr && obj->size() > 0)
{ {
compiler->registerGroupObject(re, ObjectGroup::cast(obj)); compiler->registerGroupObject(re, ObjectGroup::cast(obj));
} }
@ -966,7 +966,7 @@ bool Compiler::RegisterGroupsAndTablesInRE::processNext()
void Compiler::registerGroupObject(RuleElement *re, ObjectGroup *grp) void Compiler::registerGroupObject(RuleElement *re, ObjectGroup *grp)
{ {
assert(group_registry!=NULL); assert(group_registry!=nullptr);
list<FWObject*> objects; list<FWObject*> objects;
expandGroup(grp, objects); expandGroup(grp, objects);
group_registry->registerGroup(grp, objects); group_registry->registerGroup(grp, objects);
@ -980,7 +980,7 @@ bool Compiler::equalObj::operator()(FWObject *o)
bool Compiler::singleObjectNegation::processNext() bool Compiler::singleObjectNegation::processNext()
{ {
Rule *rule = prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule = prev_processor->getNextRule(); if (rule==nullptr) return false;
RuleElement *rel = RuleElement::cast(rule->getFirstByType(re_type)); RuleElement *rel = RuleElement::cast(rule->getFirstByType(re_type));
assert(rel); assert(rel);
@ -996,7 +996,7 @@ bool Compiler::singleObjectNegation::processNext()
} else } else
{ {
FWObject *o = rel->front(); FWObject *o = rel->front();
if (FWReference::cast(o)!=NULL) o=FWReference::cast(o)->getPointer(); if (FWReference::cast(o)!=nullptr) o=FWReference::cast(o)->getPointer();
Address *reladdr = Address::cast(o); Address *reladdr = Address::cast(o);
if ( reladdr && reladdr->countInetAddresses(true)==1 && if ( reladdr && reladdr->countInetAddresses(true)==1 &&
!compiler->complexMatch(reladdr, compiler->fw)) !compiler->complexMatch(reladdr, compiler->fw))
@ -1031,10 +1031,10 @@ bool Compiler::singleObjectNegation::processNext()
*/ */
bool Compiler::fullInterfaceNegationInRE::processNext() bool Compiler::fullInterfaceNegationInRE::processNext()
{ {
Rule *rule = prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule = prev_processor->getNextRule(); if (rule==nullptr) return false;
RuleElement *itfre = RuleElement::cast(rule->getFirstByType(re_type)); RuleElement *itfre = RuleElement::cast(rule->getFirstByType(re_type));
if (itfre==NULL) if (itfre==nullptr)
compiler->abort(rule, "Missing interface rule element"); compiler->abort(rule, "Missing interface rule element");
FWOptions *fwopt = compiler->getCachedFwOpt(); FWOptions *fwopt = compiler->getCachedFwOpt();
@ -1051,7 +1051,7 @@ bool Compiler::fullInterfaceNegationInRE::processNext()
for (FWObject::iterator i=all_interfaces.begin(); i!=all_interfaces.end(); ++i) for (FWObject::iterator i=all_interfaces.begin(); i!=all_interfaces.end(); ++i)
{ {
Interface *intf = Interface::cast(*i); Interface *intf = Interface::cast(*i);
if (intf == NULL) continue; if (intf == nullptr) continue;
if (intf->isUnprotected()) continue; if (intf->isUnprotected()) continue;
if (intf->isLoopback()) continue; if (intf->isLoopback()) continue;
@ -1066,7 +1066,7 @@ bool Compiler::fullInterfaceNegationInRE::processNext()
{ {
// Only interface objects are allowed in the "Interface" rule element // Only interface objects are allowed in the "Interface" rule element
Interface *rule_iface = Interface::cast(FWReference::getObject(*i)); Interface *rule_iface = Interface::cast(FWReference::getObject(*i));
if (rule_iface == NULL) continue; if (rule_iface == nullptr) continue;
// If this interface belongs to a cluster (which can only happen // If this interface belongs to a cluster (which can only happen
// if the rule set belongs to a cluster), then replace it with // if the rule set belongs to a cluster), then replace it with
// corresponding interface of the member // corresponding interface of the member
@ -1097,21 +1097,21 @@ bool Compiler::fullInterfaceNegationInRE::processNext()
*/ */
bool Compiler::replaceClusterInterfaceInItfRE::processNext() bool Compiler::replaceClusterInterfaceInItfRE::processNext()
{ {
Rule *rule = prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule = prev_processor->getNextRule(); if (rule==nullptr) return false;
RuleElement *itfre = RuleElement::cast(rule->getFirstByType(re_type)); RuleElement *itfre = RuleElement::cast(rule->getFirstByType(re_type));
if (itfre==NULL) if (itfre==nullptr)
compiler->abort(rule, "Missing interface rule element"); compiler->abort(rule, "Missing interface rule element");
map<FWObject*, FWObject*> interface_replacement; map<FWObject*, FWObject*> interface_replacement;
for (FWObject::iterator i=itfre->begin(); i!=itfre->end(); ++i) for (FWObject::iterator i=itfre->begin(); i!=itfre->end(); ++i)
{ {
Interface *member_iface = NULL; Interface *member_iface = nullptr;
// Only interface objects are allowed in the "Interface" rule element // Only interface objects are allowed in the "Interface" rule element
FWObject *o = FWReference::getObject(*i); FWObject *o = FWReference::getObject(*i);
Interface *rule_iface = Interface::cast(o); Interface *rule_iface = Interface::cast(o);
if (rule_iface == NULL) continue; if (rule_iface == nullptr) continue;
// If this interface belongs to a cluster (which can only happen // If this interface belongs to a cluster (which can only happen
// if the rule set belongs to a cluster), then replace it with // if the rule set belongs to a cluster), then replace it with
// corresponding interface of the member // corresponding interface of the member
@ -1143,9 +1143,9 @@ bool Compiler::replaceClusterInterfaceInItfRE::processNext()
bool Compiler::eliminateDuplicatesInRE::processNext() bool Compiler::eliminateDuplicatesInRE::processNext()
{ {
Rule *rule=prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule=prev_processor->getNextRule(); if (rule==nullptr) return false;
if (comparator==NULL) comparator = new equalObj(); if (comparator==nullptr) comparator = new equalObj();
RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type)); RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type));
@ -1154,7 +1154,7 @@ bool Compiler::eliminateDuplicatesInRE::processNext()
for(list<FWObject*>::iterator i=re->begin(); i!=re->end(); ++i) for(list<FWObject*>::iterator i=re->begin(); i!=re->end(); ++i)
{ {
FWObject *obj = FWReference::getObject(*i); FWObject *obj = FWReference::getObject(*i);
if (obj == NULL) continue; if (obj == nullptr) continue;
comparator->set(obj); comparator->set(obj);
@ -1183,7 +1183,7 @@ void Compiler::recursiveGroupsInRE::isRecursiveGroup(int grid, FWObject *obj)
for (FWObject::iterator i=obj->begin(); i!=obj->end(); i++) for (FWObject::iterator i=obj->begin(); i!=obj->end(); i++)
{ {
FWObject *o = FWReference::getObject(*i); FWObject *o = FWReference::getObject(*i);
if (Group::cast(o)!=NULL) if (Group::cast(o)!=nullptr)
{ {
if (o->getId()==grid || obj->getId()==o->getId()) if (o->getId()==grid || obj->getId()==o->getId())
{ {
@ -1199,10 +1199,10 @@ void Compiler::recursiveGroupsInRE::isRecursiveGroup(int grid, FWObject *obj)
bool Compiler::recursiveGroupsInRE::processNext() bool Compiler::recursiveGroupsInRE::processNext()
{ {
Rule *rule=prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule=prev_processor->getNextRule(); if (rule==nullptr) return false;
RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type)); RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type));
if (re == NULL || re->isAny()) if (re == nullptr || re->isAny())
{ {
tmp_queue.push_back(rule); tmp_queue.push_back(rule);
return true; return true;
@ -1212,7 +1212,7 @@ bool Compiler::recursiveGroupsInRE::processNext()
for (FWObject::iterator i=re->begin(); i!=re->end(); i++) for (FWObject::iterator i=re->begin(); i!=re->end(); i++)
{ {
FWObject *o = FWReference::getObject(*i); FWObject *o = FWReference::getObject(*i);
if (Group::cast(o)!=NULL) isRecursiveGroup(o->getId(),o); if (Group::cast(o)!=nullptr) isRecursiveGroup(o->getId(),o);
} }
tmp_queue.push_back(rule); tmp_queue.push_back(rule);
@ -1240,11 +1240,11 @@ int Compiler::emptyGroupsInRE::countChildren(FWObject *obj)
// have some addresses at run time. So we just count it as a // have some addresses at run time. So we just count it as a
// regular object. // regular object.
if (MultiAddress::cast(o)!=NULL && MultiAddress::cast(o)->isRunTime()) if (MultiAddress::cast(o)!=nullptr && MultiAddress::cast(o)->isRunTime())
n++; n++;
else else
{ {
if (Group::cast(o)!=NULL) n += countChildren(o); if (Group::cast(o)!=nullptr) n += countChildren(o);
else n++; // but if it is not a group, then we count it. else n++; // but if it is not a group, then we count it.
} }
} }
@ -1253,10 +1253,10 @@ int Compiler::emptyGroupsInRE::countChildren(FWObject *obj)
bool Compiler::emptyGroupsInRE::processNext() bool Compiler::emptyGroupsInRE::processNext()
{ {
Rule *rule=prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule=prev_processor->getNextRule(); if (rule==nullptr) return false;
RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type)); RuleElement *re = RuleElement::cast(rule->getFirstByType(re_type));
if (re == NULL || re->isAny()) if (re == nullptr || re->isAny())
{ {
tmp_queue.push_back(rule); tmp_queue.push_back(rule);
return true; return true;
@ -1267,10 +1267,10 @@ bool Compiler::emptyGroupsInRE::processNext()
{ {
FWObject *o = FWReference::getObject(*i); FWObject *o = FWReference::getObject(*i);
if ( MultiAddress::cast(o)!=NULL && MultiAddress::cast(o)->isRunTime()) if ( MultiAddress::cast(o)!=nullptr && MultiAddress::cast(o)->isRunTime())
continue; continue;
if (Group::cast(o)!=NULL && countChildren(o)==0) if (Group::cast(o)!=nullptr && countChildren(o)==0)
cl.push_back(o); cl.push_back(o);
} }
@ -1335,10 +1335,10 @@ bool Compiler::emptyGroupsInRE::processNext()
*/ */
bool Compiler::swapMultiAddressObjectsInRE::processNext() bool Compiler::swapMultiAddressObjectsInRE::processNext()
{ {
Rule *rule=prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule=prev_processor->getNextRule(); if (rule==nullptr) return false;
RuleElement *re=RuleElement::cast( rule->getFirstByType(re_type) ); RuleElement *re=RuleElement::cast( rule->getFirstByType(re_type) );
if (re == NULL || re->isAny()) if (re == nullptr || re->isAny())
{ {
tmp_queue.push_back(rule); tmp_queue.push_back(rule);
return true; return true;
@ -1348,7 +1348,7 @@ bool Compiler::swapMultiAddressObjectsInRE::processNext()
for (FWObject::iterator i=re->begin(); i!=re->end(); i++) for (FWObject::iterator i=re->begin(); i!=re->end(); i++)
{ {
FWObject *o = FWReference::getObject(*i); FWObject *o = FWReference::getObject(*i);
if (MultiAddress::cast(o)!=NULL && MultiAddress::cast(o)->isRunTime()) if (MultiAddress::cast(o)!=nullptr && MultiAddress::cast(o)->isRunTime())
cl.push_back(MultiAddress::cast(o)); cl.push_back(MultiAddress::cast(o));
} }
@ -1369,7 +1369,7 @@ bool Compiler::swapMultiAddressObjectsInRE::processNext()
int mart_id = FWObjectDatabase::registerStringId(mart_id_str); int mart_id = FWObjectDatabase::registerStringId(mart_id_str);
MultiAddressRunTime *mart = MultiAddressRunTime::cast( MultiAddressRunTime *mart = MultiAddressRunTime::cast(
compiler->dbcopy->findInIndex(mart_id)); compiler->dbcopy->findInIndex(mart_id));
if (mart==NULL) if (mart==nullptr)
{ {
mart = new MultiAddressRunTime(ma); mart = new MultiAddressRunTime(ma);
@ -1396,7 +1396,7 @@ bool Compiler::swapMultiAddressObjectsInRE::processNext()
bool Compiler::expandMultipleAddressesInRE::processNext() bool Compiler::expandMultipleAddressesInRE::processNext()
{ {
Rule *rule = prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule = prev_processor->getNextRule(); if (rule==nullptr) return false;
RuleElement *re = RuleElement::cast( rule->getFirstByType(re_type) ); RuleElement *re = RuleElement::cast( rule->getFirstByType(re_type) );
if (re) compiler->_expand_addr(rule, re, true); if (re) compiler->_expand_addr(rule, re, true);
tmp_queue.push_back(rule); tmp_queue.push_back(rule);
@ -1406,12 +1406,12 @@ bool Compiler::expandMultipleAddressesInRE::processNext()
bool Compiler::checkForObjectsWithErrors::processNext() bool Compiler::checkForObjectsWithErrors::processNext()
{ {
Rule *rule = prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule = prev_processor->getNextRule(); if (rule==nullptr) return false;
for (FWObject::iterator it1=rule->begin(); it1!=rule->end(); it1++) for (FWObject::iterator it1=rule->begin(); it1!=rule->end(); it1++)
{ {
RuleElement *re = RuleElement::cast(*it1); RuleElement *re = RuleElement::cast(*it1);
if (re == NULL || re->isAny()) continue; if (re == nullptr || re->isAny()) continue;
for (FWObject::iterator it2=re->begin(); it2!=re->end(); it2++) for (FWObject::iterator it2=re->begin(); it2!=re->end(); it2++)
{ {
FWObject *obj = FWReference::getObject(*it2); FWObject *obj = FWReference::getObject(*it2);
@ -1435,10 +1435,10 @@ bool Compiler::checkForObjectsWithErrors::processNext()
bool Compiler::replaceFailoverInterfaceInRE::processNext() bool Compiler::replaceFailoverInterfaceInRE::processNext()
{ {
Rule *rule = prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule = prev_processor->getNextRule(); if (rule==nullptr) return false;
RuleElement *re = RuleElement::cast( rule->getFirstByType(re_type) ); RuleElement *re = RuleElement::cast( rule->getFirstByType(re_type) );
if (re == NULL || re->isAny()) if (re == nullptr || re->isAny())
{ {
tmp_queue.push_back(rule); tmp_queue.push_back(rule);
return true; return true;
@ -1449,7 +1449,7 @@ bool Compiler::replaceFailoverInterfaceInRE::processNext()
for (FWObject::iterator i=re->begin(); i!=re->end(); i++) for (FWObject::iterator i=re->begin(); i!=re->end(); i++)
{ {
Interface *intf = Interface::cast(FWReference::getObject(*i)); Interface *intf = Interface::cast(FWReference::getObject(*i));
if (intf==NULL) continue; if (intf==nullptr) continue;
if (intf->isFailoverInterface()) cl.push_back(intf); if (intf->isFailoverInterface()) cl.push_back(intf);
else else
@ -1500,7 +1500,7 @@ bool Compiler::replaceFailoverInterfaceInRE::processNext()
bool Compiler::FindAddressFamilyInRE(FWObject *parent, bool ipv6) bool Compiler::FindAddressFamilyInRE(FWObject *parent, bool ipv6)
{ {
Address *addr = Address::cast(parent); Address *addr = Address::cast(parent);
if (addr!=NULL) if (addr!=nullptr)
{ {
const InetAddr *inet_addr = addr->getAddressPtr(); const InetAddr *inet_addr = addr->getAddressPtr();
if (ipv6) if (ipv6)
@ -1559,7 +1559,7 @@ bool Compiler::dropRuleWithEmptyRE::isREEmpty(Rule *rule,
*/ */
bool Compiler::dropRuleWithEmptyRE::processNext() bool Compiler::dropRuleWithEmptyRE::processNext()
{ {
Rule *rule = prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule = prev_processor->getNextRule(); if (rule==nullptr) return false;
if (PolicyRule::cast(rule) && if (PolicyRule::cast(rule) &&
(isREEmpty(rule, RuleElementSrc::TYPENAME) || (isREEmpty(rule, RuleElementSrc::TYPENAME) ||
@ -1607,7 +1607,7 @@ void Compiler::DropByServiceTypeInRE(RuleElement *rel, bool drop_ipv6)
Service *svc = Service::cast(o); Service *svc = Service::cast(o);
if (svc == NULL) if (svc == nullptr)
{ {
cerr << endl; cerr << endl;
cerr << "Rule " << Rule::cast(rel->getParent())->getLabel() cerr << "Rule " << Rule::cast(rel->getParent())->getLabel()
@ -1641,7 +1641,7 @@ bool Compiler::catchUnnumberedIfaceInRE(RuleElement *re)
for (FWObject::iterator i=re->begin(); i!=re->end(); i++) for (FWObject::iterator i=re->begin(); i!=re->end(); i++)
{ {
FWObject *o = FWReference::getObject(*i); FWObject *o = FWReference::getObject(*i);
if (o==NULL) if (o==nullptr)
{ {
//Rule *rule = Rule::cast(re->getParent()); //Rule *rule = Rule::cast(re->getParent());
FWReference *refo = FWReference::cast(*i); FWReference *refo = FWReference::cast(*i);
@ -1651,7 +1651,7 @@ bool Compiler::catchUnnumberedIfaceInRE(RuleElement *re)
FWObjectDatabase::getStringId(refo->getPointerId()); FWObjectDatabase::getStringId(refo->getPointerId());
abort(re->getParent(), errmsg); abort(re->getParent(), errmsg);
} }
err |= ((iface=Interface::cast(o))!=NULL && err |= ((iface=Interface::cast(o))!=nullptr &&
(iface->isUnnumbered() || iface->isBridgePort()) (iface->isUnnumbered() || iface->isBridgePort())
); );
} }
@ -1682,7 +1682,7 @@ Service* Compiler::getFirstSrv(PolicyRule *rule)
Interval* Compiler::getFirstWhen(PolicyRule *rule) Interval* Compiler::getFirstWhen(PolicyRule *rule)
{ {
RuleElementInterval *when = rule->getWhen(); RuleElementInterval *when = rule->getWhen();
if (when==NULL) return NULL; // when is optional element if (when==nullptr) return nullptr; // when is optional element
FWObject *o = FWReference::getObject(when->front()); FWObject *o = FWReference::getObject(when->front());
return Interval::cast(o); return Interval::cast(o);
} }
@ -1690,7 +1690,7 @@ Interval* Compiler::getFirstWhen(PolicyRule *rule)
Interface* Compiler::getFirstItf(PolicyRule *rule) Interface* Compiler::getFirstItf(PolicyRule *rule)
{ {
RuleElementItf *itf = rule->getItf(); RuleElementItf *itf = rule->getItf();
if (itf==NULL || itf->size()==0) return NULL; // itf is optional element if (itf==nullptr || itf->size()==0) return nullptr; // itf is optional element
FWObject *o = FWReference::getObject(itf->front()); FWObject *o = FWReference::getObject(itf->front());
return Interface::cast(o); return Interface::cast(o);
} }
@ -1698,7 +1698,7 @@ Interface* Compiler::getFirstItf(PolicyRule *rule)
Address* Compiler::getFirstOSrc(NATRule *rule) Address* Compiler::getFirstOSrc(NATRule *rule)
{ {
RuleElementOSrc *osrc = rule->getOSrc(); RuleElementOSrc *osrc = rule->getOSrc();
assert(osrc!=NULL); assert(osrc!=nullptr);
FWObject *o = FWReference::getObject(osrc->front()); FWObject *o = FWReference::getObject(osrc->front());
return Address::cast(o); return Address::cast(o);
} }
@ -1706,7 +1706,7 @@ Address* Compiler::getFirstOSrc(NATRule *rule)
Address* Compiler::getFirstODst(NATRule *rule) Address* Compiler::getFirstODst(NATRule *rule)
{ {
RuleElementODst *odst = rule->getODst(); RuleElementODst *odst = rule->getODst();
assert(odst!=NULL); assert(odst!=nullptr);
FWObject *o = FWReference::getObject(odst->front()); FWObject *o = FWReference::getObject(odst->front());
return Address::cast(o); return Address::cast(o);
} }
@ -1714,7 +1714,7 @@ Address* Compiler::getFirstODst(NATRule *rule)
Service* Compiler::getFirstOSrv(NATRule *rule) Service* Compiler::getFirstOSrv(NATRule *rule)
{ {
RuleElementOSrv *osrv = rule->getOSrv(); RuleElementOSrv *osrv = rule->getOSrv();
assert(osrv!=NULL); assert(osrv!=nullptr);
FWObject *o = FWReference::getObject(osrv->front()); FWObject *o = FWReference::getObject(osrv->front());
return Service::cast(o); return Service::cast(o);
} }
@ -1722,7 +1722,7 @@ Service* Compiler::getFirstOSrv(NATRule *rule)
Address* Compiler::getFirstTSrc(NATRule *rule) Address* Compiler::getFirstTSrc(NATRule *rule)
{ {
RuleElementTSrc *tsrc = rule->getTSrc(); RuleElementTSrc *tsrc = rule->getTSrc();
assert(tsrc!=NULL); assert(tsrc!=nullptr);
FWObject *o = FWReference::getObject(tsrc->front()); FWObject *o = FWReference::getObject(tsrc->front());
return Address::cast(o); return Address::cast(o);
} }
@ -1730,7 +1730,7 @@ Address* Compiler::getFirstTSrc(NATRule *rule)
Address* Compiler::getFirstTDst(NATRule *rule) Address* Compiler::getFirstTDst(NATRule *rule)
{ {
RuleElementTDst *tdst = rule->getTDst(); RuleElementTDst *tdst = rule->getTDst();
assert(tdst!=NULL); assert(tdst!=nullptr);
FWObject *o = FWReference::getObject(tdst->front()); FWObject *o = FWReference::getObject(tdst->front());
return Address::cast(o); return Address::cast(o);
} }
@ -1738,7 +1738,7 @@ Address* Compiler::getFirstTDst(NATRule *rule)
Service* Compiler::getFirstTSrv(NATRule *rule) Service* Compiler::getFirstTSrv(NATRule *rule)
{ {
RuleElementTSrv *tsrv = rule->getTSrv(); RuleElementTSrv *tsrv = rule->getTSrv();
assert(tsrv!=NULL); assert(tsrv!=nullptr);
FWObject *o = FWReference::getObject(tsrv->front()); FWObject *o = FWReference::getObject(tsrv->front());
return Service::cast(o); return Service::cast(o);
} }
@ -1842,21 +1842,21 @@ Address* Compiler::correctForCluster(Address *addr)
*/ */
bool Compiler::DropRulesByAddressFamilyAndServiceType::processNext() bool Compiler::DropRulesByAddressFamilyAndServiceType::processNext()
{ {
Rule *rule = prev_processor->getNextRule(); if (rule==NULL) return false; Rule *rule = prev_processor->getNextRule(); if (rule==nullptr) return false;
for(FWObject::iterator it=rule->begin(); it!=rule->end(); ++it) for(FWObject::iterator it=rule->begin(); it!=rule->end(); ++it)
{ {
RuleElement *re = RuleElement::cast(*it); RuleElement *re = RuleElement::cast(*it);
if (re == NULL) continue; // probably RuleOptions object if (re == nullptr) continue; // probably RuleOptions object
bool orig_any = re->isAny(); bool orig_any = re->isAny();
if (orig_any) continue; if (orig_any) continue;
FWObject *first_object = FWReference::getObject(re->front()); FWObject *first_object = FWReference::getObject(re->front());
if (Address::cast(first_object) != NULL) if (Address::cast(first_object) != nullptr)
compiler->DropAddressFamilyInRE(re, drop_ipv6); compiler->DropAddressFamilyInRE(re, drop_ipv6);
if (Service::cast(first_object) != NULL) if (Service::cast(first_object) != nullptr)
compiler->DropByServiceTypeInRE(re, drop_ipv6); compiler->DropByServiceTypeInRE(re, drop_ipv6);
if (!orig_any && re->isAny()) if (!orig_any && re->isAny())

View File

@ -56,7 +56,7 @@ AddressRangeDialog::AddressRangeDialog(QWidget *parent):
{ {
m_dialog = new Ui::AddressRangeDialog_q; m_dialog = new Ui::AddressRangeDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -70,7 +70,7 @@ void AddressRangeDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
AddressRange *s = dynamic_cast<AddressRange*>(obj); AddressRange *s = dynamic_cast<AddressRange*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init=true; init=true;
@ -99,7 +99,7 @@ void AddressRangeDialog::validate(bool *res)
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; } if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
AddressRange *s = dynamic_cast<AddressRange*>(obj); AddressRange *s = dynamic_cast<AddressRange*>(obj);
assert(s!=NULL); assert(s!=nullptr);
try try
{ {
InetAddr range_start(AF_UNSPEC, m_dialog->rangeStart->text().toLatin1().constData()); InetAddr range_start(AF_UNSPEC, m_dialog->rangeStart->text().toLatin1().constData());
@ -118,13 +118,13 @@ void AddressRangeDialog::validate(bool *res)
{ {
*res = false; *res = false;
// show warning dialog only if app has focus // show warning dialog only if app has focus
if (QApplication::focusWidget() != NULL) if (QApplication::focusWidget() != nullptr)
{ {
blockSignals(true); blockSignals(true);
QMessageBox::critical( QMessageBox::critical(
this, "Firewall Builder", this, "Firewall Builder",
QString::fromUtf8(ex.toString().c_str()), QString::fromUtf8(ex.toString().c_str()),
tr("&Continue"), 0, 0, tr("&Continue"), nullptr, nullptr,
0 ); 0 );
blockSignals(false); blockSignals(false);
} }
@ -138,7 +138,7 @@ void AddressRangeDialog::applyChanges()
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
AddressRange *s = dynamic_cast<AddressRange*>(new_state); AddressRange *s = dynamic_cast<AddressRange*>(new_state);
assert(s!=NULL); assert(s!=nullptr);
string oldname = obj->getName(); string oldname = obj->getName();
new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) ); new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) );

View File

@ -66,7 +66,7 @@ AddressTableDialog::AddressTableDialog(QWidget *parent) : BaseObjectDialog(paren
{ {
m_dialog = new Ui::AddressTableDialog_q; m_dialog = new Ui::AddressTableDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -80,7 +80,7 @@ void AddressTableDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
AddressTable *s = dynamic_cast<AddressTable*>(obj); AddressTable *s = dynamic_cast<AddressTable*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init = true; init = true;
@ -116,7 +116,7 @@ void AddressTableDialog::validate(bool *res)
{ {
*res=true; *res=true;
AddressTable *s = dynamic_cast<AddressTable*>(obj); AddressTable *s = dynamic_cast<AddressTable*>(obj);
assert(s!=NULL); assert(s!=nullptr);
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; } if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
} }
@ -127,7 +127,7 @@ void AddressTableDialog::applyChanges()
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
AddressTable *s = dynamic_cast<AddressTable*>(new_state); AddressTable *s = dynamic_cast<AddressTable*>(new_state);
assert(s!=NULL); assert(s!=nullptr);
string oldname = obj->getName(); string oldname = obj->getName();
new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) ); new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) );

View File

@ -41,7 +41,7 @@ FWObject *AskLibForCopyDialog::askLibForCopyDialog( QWidget *parent,
AskLibForCopyDialog dlg(parent, db, curr); AskLibForCopyDialog dlg(parent, db, curr);
if ( dlg.exec() == QDialog::Accepted ) if ( dlg.exec() == QDialog::Accepted )
return dlg.getChoosenLib(); return dlg.getChoosenLib();
return 0; return nullptr;
} }
AskLibForCopyDialog::~AskLibForCopyDialog() AskLibForCopyDialog::~AskLibForCopyDialog()
@ -110,5 +110,5 @@ FWObject *AskLibForCopyDialog::getChoosenLib()
int ind = m_dialog->libs->currentIndex(); int ind = m_dialog->libs->currentIndex();
if (0 <= ind) if (0 <= ind)
return idxToLibs[ind]; return idxToLibs[ind];
return 0; return nullptr;
} }

View File

@ -59,7 +59,7 @@ AttachedNetworksDialog::AttachedNetworksDialog(QWidget *parent) : BaseObjectDial
{ {
m_dialog = new Ui::AttachedNetworksDialog_q; m_dialog = new Ui::AttachedNetworksDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -70,7 +70,7 @@ void AttachedNetworksDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
AttachedNetworks *s = dynamic_cast<AttachedNetworks*>(obj); AttachedNetworks *s = dynamic_cast<AttachedNetworks*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init=true; init=true;
@ -129,7 +129,7 @@ void AttachedNetworksDialog::validate(bool *result)
*result = true; *result = true;
AttachedNetworks *s = dynamic_cast<AttachedNetworks*>(obj); AttachedNetworks *s = dynamic_cast<AttachedNetworks*>(obj);
assert(s!=NULL); assert(s!=nullptr);
if (!validateName(this, obj, m_dialog->obj_name->text())) if (!validateName(this, obj, m_dialog->obj_name->text()))
{ {
@ -144,7 +144,7 @@ void AttachedNetworksDialog::applyChanges()
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
AttachedNetworks *s = dynamic_cast<AttachedNetworks*>(new_state); AttachedNetworks *s = dynamic_cast<AttachedNetworks*>(new_state);
assert(s!=NULL); assert(s!=nullptr);
string oldname = obj->getName(); string oldname = obj->getName();
new_state->setName(string(m_dialog->obj_name->text().toUtf8().constData())); new_state->setName(string(m_dialog->obj_name->text().toUtf8().constData()));

View File

@ -58,7 +58,7 @@ ClusterGroupDialog::ClusterGroupDialog(QWidget *parent)
{ {
m_dialog = new Ui::ClusterGroupDialog_q; m_dialog = new Ui::ClusterGroupDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj = NULL; obj = nullptr;
reload = false; reload = false;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
@ -68,7 +68,7 @@ void ClusterGroupDialog::loadFWObject(FWObject *o)
{ {
obj = o; obj = o;
ClusterGroup *g = dynamic_cast<ClusterGroup*>(obj); ClusterGroup *g = dynamic_cast<ClusterGroup*>(obj);
assert(g != NULL); assert(g != nullptr);
init = true; init = true;
@ -76,7 +76,7 @@ void ClusterGroupDialog::loadFWObject(FWObject *o)
// Parent is either 'Cluster' or 'Interface', call getParent() approprietly // Parent is either 'Cluster' or 'Interface', call getParent() approprietly
FWObject *parent = obj; FWObject *parent = obj;
while (parent && !Cluster::isA(parent)) parent = parent->getParent(); while (parent && !Cluster::isA(parent)) parent = parent->getParent();
if (parent == NULL) if (parent == nullptr)
{ {
throw FWException("ClusterGroupDialog: parent is NULL!"); throw FWException("ClusterGroupDialog: parent is NULL!");
} }
@ -199,7 +199,7 @@ void ClusterGroupDialog::saveGroupType(FWObject *group)
void ClusterGroupDialog::addIcon(FWObject *o, bool master) void ClusterGroupDialog::addIcon(FWObject *o, bool master)
{ {
FWObject *iface = o; FWObject *iface = o;
assert(Interface::cast(iface)!=NULL); assert(Interface::cast(iface)!=nullptr);
FWObject *fw = Host::getParentHost(iface); FWObject *fw = Host::getParentHost(iface);
// FWObject *fw = Interface::cast(iface)->getParentHost(); // because iface can be subinterface // FWObject *fw = Interface::cast(iface)->getParentHost(); // because iface can be subinterface
bool valid = cluster->validateMember(Firewall::cast(fw)); bool valid = cluster->validateMember(Firewall::cast(fw));
@ -280,7 +280,7 @@ void ClusterGroupDialog::applyChanges()
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
ClusterGroup *g = dynamic_cast<ClusterGroup*>(new_state); ClusterGroup *g = dynamic_cast<ClusterGroup*>(new_state);
assert(g != NULL); assert(g != nullptr);
QString oldname = obj->getName().c_str(); QString oldname = obj->getName().c_str();
new_state->setName(string(m_dialog->obj_name->text().toUtf8().constData())); new_state->setName(string(m_dialog->obj_name->text().toUtf8().constData()));
@ -304,12 +304,12 @@ void ClusterGroupDialog::openClusterConfDialog()
try try
{ {
QWidget *w = DialogFactory::createClusterConfDialog(this, obj); QWidget *w = DialogFactory::createClusterConfDialog(this, obj);
if (w == NULL) if (w == nullptr)
{ {
return; // some dialogs may not be implemented yet return; // some dialogs may not be implemented yet
} }
QDialog *d = dynamic_cast<QDialog*>(w); QDialog *d = dynamic_cast<QDialog*>(w);
assert(d != NULL); assert(d != nullptr);
// connect obj changed signal // connect obj changed signal
//connect(d, SIGNAL(membersChanged()), this, SLOT(objectChanged())); //connect(d, SIGNAL(membersChanged()), this, SLOT(objectChanged()));
@ -343,10 +343,10 @@ void ClusterGroupDialog::openClusterConfDialog()
void ClusterGroupDialog::openObject(QTreeWidgetItem *item) void ClusterGroupDialog::openObject(QTreeWidgetItem *item)
{ {
ObjectListViewItem *otvi = dynamic_cast<ObjectListViewItem*>(item); ObjectListViewItem *otvi = dynamic_cast<ObjectListViewItem*>(item);
assert(otvi != NULL); assert(otvi != nullptr);
FWObject *o = otvi->getFWObject(); FWObject *o = otvi->getFWObject();
if (o != NULL) if (o != nullptr)
{ {
QCoreApplication::postEvent( QCoreApplication::postEvent(
mw, new showObjectInTreeEvent(o->getRoot()->getFileName().c_str(), mw, new showObjectInTreeEvent(o->getRoot()->getFileName().c_str(),

View File

@ -145,7 +145,7 @@ bool ClusterInterfaceWidget::setCurrentInterface(const QString& name)
foreach(QTreeWidgetItem *item, list.list->findItems(name, Qt::MatchCaseSensitive | Qt::MatchExactly | Qt::MatchRecursive)) foreach(QTreeWidgetItem *item, list.list->findItems(name, Qt::MatchCaseSensitive | Qt::MatchExactly | Qt::MatchRecursive))
{ {
Interface *iface = item->data(0, Qt::UserRole).value<Interface*>(); Interface *iface = item->data(0, Qt::UserRole).value<Interface*>();
if (iface == NULL) continue; if (iface == nullptr) continue;
if ( item == roots[list.list] ) continue; // skip firewall object if ( item == roots[list.list] ) continue; // skip firewall object
if ( interfaceSelectable(iface) ) // interface is good for use in cluster if ( interfaceSelectable(iface) ) // interface is good for use in cluster
{ {
@ -195,7 +195,7 @@ bool ClusterInterfaceWidget::interfaceSelectable(Interface* iface)
Resources* os_res = Resources::os_res[os.toStdString()]; Resources* os_res = Resources::os_res[os.toStdString()];
string os_family = os.toStdString(); string os_family = os.toStdString();
if (os_res!=NULL) if (os_res!=nullptr)
os_family = os_res->getResourceStr("/FWBuilderResources/Target/family"); os_family = os_res->getResourceStr("/FWBuilderResources/Target/family");
unique_ptr<interfaceProperties> int_prop( unique_ptr<interfaceProperties> int_prop(

View File

@ -55,7 +55,7 @@ CommentEditorPanel::CommentEditorPanel(QWidget *p) : BaseObjectDialog(p)
{ {
m_widget = new Ui::CommentEditorPanel_q; m_widget = new Ui::CommentEditorPanel_q;
m_widget->setupUi(this); m_widget->setupUi(this);
rule=NULL; rule=nullptr;
} }
QString CommentEditorPanel::text() QString CommentEditorPanel::text()

View File

@ -60,6 +60,6 @@ CompilerDriver* CompilerDriverFactory::createCompilerDriver(Firewall *fw)
return new CompilerDriver_pix(fw->getRoot()); return new CompilerDriver_pix(fw->getRoot());
if (platform == "procurve_acl") if (platform == "procurve_acl")
return new CompilerDriver_procurve_acl(fw->getRoot()); return new CompilerDriver_procurve_acl(fw->getRoot());
return NULL; return nullptr;
} }

View File

@ -132,7 +132,7 @@ void CompilerOutputPanel::loadFWObject(FWObject *obj)
//m_widget->compiler_output_panel->clear(); //m_widget->compiler_output_panel->clear();
if (dr == NULL) if (dr == nullptr)
{ {
// we have no compiler for this platform or unknown platform // we have no compiler for this platform or unknown platform
format = error_format; format = error_format;

View File

@ -107,7 +107,7 @@ void ConfirmDeleteObjectDialog::findForObject(FWObject *obj)
foreach(FWObject *o, simplified_holders) foreach(FWObject *o, simplified_holders)
{ {
QTreeWidgetItem *item = FindWhereUsedWidget::createQTWidgetItem(obj, o); QTreeWidgetItem *item = FindWhereUsedWidget::createQTWidgetItem(obj, o);
if (item==NULL) continue; if (item==nullptr) continue;
m_dialog->objectsView->addTopLevelItem(item); m_dialog->objectsView->addTopLevelItem(item);
itemCounter++; itemCounter++;
} }

View File

@ -57,7 +57,7 @@ CustomServiceDialog::CustomServiceDialog(QWidget *parent) : BaseObjectDialog(par
{ {
m_dialog = new Ui::CustomServiceDialog_q; m_dialog = new Ui::CustomServiceDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -71,7 +71,7 @@ void CustomServiceDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
CustomService *s = dynamic_cast<CustomService*>(obj); CustomService *s = dynamic_cast<CustomService*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init=true; init=true;
@ -202,7 +202,7 @@ void CustomServiceDialog::applyChanges()
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
CustomService *s = dynamic_cast<CustomService*>(new_state); CustomService *s = dynamic_cast<CustomService*>(new_state);
assert(s!=NULL); assert(s!=nullptr);
string oldname = obj->getName(); string oldname = obj->getName();
new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) ); new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) );

View File

@ -349,7 +349,7 @@ void DynamicGroupDialog::gotItemDoubleClicked(QTreeWidgetItem *item, int)
{ {
int objId = item->data(0, Qt::UserRole).toInt(); int objId = item->data(0, Qt::UserRole).toInt();
FWObject *o = m_project->db()->findInIndex(objId); FWObject *o = m_project->db()->findInIndex(objId);
if (o == 0) return; if (o == nullptr) return;
QCoreApplication::postEvent(m_project, new showObjectInTreeEvent(o->getRoot()->getFileName().c_str(), objId)); QCoreApplication::postEvent(m_project, new showObjectInTreeEvent(o->getRoot()->getFileName().c_str(), objId));
QCoreApplication::postEvent(mw, new openObjectInEditorEvent(o->getRoot()->getFileName().c_str(), objId)); QCoreApplication::postEvent(mw, new openObjectInEditorEvent(o->getRoot()->getFileName().c_str(), objId));

View File

@ -118,7 +118,7 @@ void FWCmdAddObject::prepareStatesForRedo()
// remove it but increment reference counter. // remove it but increment reference counter.
FWObject* grp = getObject(); FWObject* grp = getObject();
FWObject *new_grp = getNewState(); FWObject *new_grp = getNewState();
if (member == NULL) if (member == nullptr)
{ {
// Find new object among children of newState. member can be // Find new object among children of newState. member can be
// NULL if FWCmdAddObject object is created before the new // NULL if FWCmdAddObject object is created before the new
@ -272,7 +272,7 @@ FWCmdAddLibrary::FWCmdAddLibrary(ProjectPanel *project,
QUndoCommand* macro): QUndoCommand* macro):
FWCmdAddObject(project, root, lib, text, macro) FWCmdAddObject(project, root, lib, text, macro)
{ {
assert(FWObjectDatabase::cast(root)!=NULL); assert(FWObjectDatabase::cast(root)!=nullptr);
if (text.isEmpty()) if (text.isEmpty())
{ {

View File

@ -75,7 +75,7 @@ FWCmdMoveObject::FWCmdMoveObject(
{ {
old_parent = old_p; old_parent = old_p;
new_parent = new_p; new_parent = new_p;
current_parent = NULL; current_parent = nullptr;
obj = o; obj = o;
if (text.isEmpty()) if (text.isEmpty())
@ -258,7 +258,7 @@ void FWCmdMoveObject::notify()
QCoreApplication::postEvent( QCoreApplication::postEvent(
mw, new dataModifiedEvent(filename, new_parent->getId())); mw, new dataModifiedEvent(filename, new_parent->getId()));
FWObject *new_obj = NULL; FWObject *new_obj = nullptr;
if (current_parent->getId()==FWObjectDatabase::DELETED_OBJECTS_ID) if (current_parent->getId()==FWObjectDatabase::DELETED_OBJECTS_ID)
{ {
if (Library::isA(obj)) if (Library::isA(obj))
@ -277,13 +277,13 @@ void FWCmdMoveObject::notify()
{ {
// new_obj = old_parent; // this does not work! // new_obj = old_parent; // this does not work!
new_obj = project->m_panel->om->getNextUserLib(obj); new_obj = project->m_panel->om->getNextUserLib(obj);
if (new_obj == NULL) if (new_obj == nullptr)
{ {
// no user libraries left, show "Standard" // no user libraries left, show "Standard"
new_obj = old_parent->getRoot()->findInIndex( new_obj = old_parent->getRoot()->findInIndex(
FWObjectDatabase::getIntId("syslib000")); FWObjectDatabase::getIntId("syslib000"));
} }
if (new_obj == NULL) if (new_obj == nullptr)
new_obj = old_parent->getRoot()->front(); new_obj = old_parent->getRoot()->front();
if (fwbdebug) qDebug() << "FWCmdMoveObject::notify() new_obj=" if (fwbdebug) qDebug() << "FWCmdMoveObject::notify() new_obj="
<< new_obj; << new_obj;

View File

@ -37,18 +37,18 @@
using namespace std; using namespace std;
using namespace libfwbuilder; using namespace libfwbuilder;
FWObjectClipboard* FWObjectClipboard::obj_clipboard=NULL; FWObjectClipboard* FWObjectClipboard::obj_clipboard=nullptr;
FWObjectClipboard::FWObjectClipboard() FWObjectClipboard::FWObjectClipboard()
{ {
assert(obj_clipboard==NULL); assert(obj_clipboard==nullptr);
obj_clipboard=this; obj_clipboard=this;
} }
FWObjectClipboard::~FWObjectClipboard() FWObjectClipboard::~FWObjectClipboard()
{ {
clear(); clear();
obj_clipboard=NULL; obj_clipboard=nullptr;
} }
void FWObjectClipboard::clear() void FWObjectClipboard::clear()
@ -115,7 +115,7 @@ FWObject* FWObjectClipboard::getObject()
pair<int,ProjectPanel*> p = ids.back(); pair<int,ProjectPanel*> p = ids.back();
return p.second->db()->findInIndex( p.first ); return p.second->db()->findInIndex( p.first );
} else } else
return NULL; return nullptr;
} }
FWObject* FWObjectClipboard::getObjectByIdx (int idx) FWObject* FWObjectClipboard::getObjectByIdx (int idx)
@ -125,6 +125,6 @@ FWObject* FWObjectClipboard::getObjectByIdx (int idx)
pair<int,ProjectPanel*> p = ids[idx]; pair<int,ProjectPanel*> p = ids[idx];
return p.second->db()->findInIndex( p.first ); return p.second->db()->findInIndex( p.first );
} else } else
return NULL; return nullptr;
} }

View File

@ -69,7 +69,7 @@ FWObjectDropArea::FWObjectDropArea(QWidget*p, const char * n, Qt::WindowFlags f)
setWindowFlags( f ); setWindowFlags( f );
m_objectDropArea = new Ui::FWObjectDropArea_q; m_objectDropArea = new Ui::FWObjectDropArea_q;
m_objectDropArea->setupUi(this); m_objectDropArea->setupUi(this);
object=NULL; object=nullptr;
helperText = tr("Drop object here."); helperText = tr("Drop object here.");
} }
@ -93,7 +93,7 @@ void FWObjectDropArea::paintEvent(QPaintEvent *)
tp.drawLine(0,h-1,0,0); tp.drawLine(0,h-1,0,0);
tp.fillRect(1, 1, w-2, h-2, Qt::white); tp.fillRect(1, 1, w-2, h-2, Qt::white);
if (object!=NULL) if (object!=nullptr)
{ {
QPixmap pm; QPixmap pm;
@ -147,7 +147,7 @@ void FWObjectDropArea::insertObject(libfwbuilder::FWObject *o)
void FWObjectDropArea::deleteObject() void FWObjectDropArea::deleteObject()
{ {
object=NULL; object=nullptr;
update(); update();
emit objectDeleted(); emit objectDeleted();
} }
@ -166,9 +166,9 @@ void FWObjectDropArea::contextMenuEvent (QContextMenuEvent * e)
popup->addSeparator(); popup->addSeparator();
QAction *dlAct = popup->addAction( tr("Delete") , this , SLOT( deleteObject( )) ); QAction *dlAct = popup->addAction( tr("Delete") , this , SLOT( deleteObject( )) );
sitAct->setEnabled(object!=NULL); sitAct->setEnabled(object!=nullptr);
editAct->setEnabled(object!=NULL); editAct->setEnabled(object!=nullptr);
dlAct->setEnabled(object!=NULL); dlAct->setEnabled(object!=nullptr);
psAct->setEnabled(FWObjectClipboard::obj_clipboard->size()>0); psAct->setEnabled(FWObjectClipboard::obj_clipboard->size()>0);
popup->exec(e->globalPos ()); popup->exec(e->globalPos ());
@ -239,7 +239,7 @@ void FWObjectDropArea::pasteObject()
void FWObjectDropArea::showInTreeObject() void FWObjectDropArea::showInTreeObject()
{ {
ProjectPanel * pp = mw->activeProject(); ProjectPanel * pp = mw->activeProject();
if (pp!=NULL) if (pp!=nullptr)
{ {
QCoreApplication::postEvent( QCoreApplication::postEvent(
pp, new showObjectInTreeEvent(pp->getFileName(), object->getId())); pp, new showObjectInTreeEvent(pp->getFileName(), object->getId()));
@ -249,9 +249,9 @@ void FWObjectDropArea::showInTreeObject()
void FWObjectDropArea::editObject() void FWObjectDropArea::editObject()
{ {
ProjectPanel * pp = mw->activeProject(); ProjectPanel * pp = mw->activeProject();
if (pp!=NULL) if (pp!=nullptr)
{ {
if (RuleSet::cast(object)!=NULL) if (RuleSet::cast(object)!=nullptr)
QCoreApplication::postEvent( QCoreApplication::postEvent(
pp, new openRulesetEvent(pp->getFileName(), object->getId())); pp, new openRulesetEvent(pp->getFileName(), object->getId()));
@ -264,5 +264,5 @@ void FWObjectDropArea::editObject()
void FWObjectDropArea::mouseDoubleClickEvent(QMouseEvent *) void FWObjectDropArea::mouseDoubleClickEvent(QMouseEvent *)
{ {
if (object!=NULL) editObject(); if (object!=nullptr) editObject();
} }

View File

@ -159,11 +159,11 @@ QString FWObjectPropertiesFactory::getObjectPropertiesBrief(FWObject *obj)
str << "/"; str << "/";
str << QString("%1").arg(n->getNetmaskPtr()->getLength()); str << QString("%1").arg(n->getNetmaskPtr()->getLength());
} else if (ClusterGroup::cast(obj)!=NULL) } else if (ClusterGroup::cast(obj)!=nullptr)
{ {
ClusterGroup *g = ClusterGroup::cast(obj); ClusterGroup *g = ClusterGroup::cast(obj);
str << QObject::tr("type: ") << g->getStr("type").c_str(); str << QObject::tr("type: ") << g->getStr("type").c_str();
} else if (Group::cast(obj)!=NULL) // just any group } else if (Group::cast(obj)!=nullptr) // just any group
{ {
Group *g=Group::cast(obj); Group *g=Group::cast(obj);
str << g->size() << " " << QObject::tr(" objects"); str << g->size() << " " << QObject::tr(" objects");
@ -255,7 +255,7 @@ QString FWObjectPropertiesFactory::getObjectPropertiesBrief(FWObject *obj)
{ {
const UserService* user_srv = UserService::constcast(obj); const UserService* user_srv = UserService::constcast(obj);
str << "User id: \"" << user_srv->getUserId().c_str() << "\"" ; str << "User id: \"" << user_srv->getUserId().c_str() << "\"" ;
} else if (RuleSet::cast(obj) != NULL) } else if (RuleSet::cast(obj) != nullptr)
{ {
QStringList attrs; QStringList attrs;
RuleSet *rs = RuleSet::cast(obj); RuleSet *rs = RuleSet::cast(obj);
@ -356,10 +356,10 @@ QString FWObjectPropertiesFactory::getObjectProperties(FWObject *obj)
str << "(no ip address)"; str << "(no ip address)";
FWObject *co=obj->getFirstByType("Interface"); FWObject *co=obj->getFirstByType("Interface");
if (co!=NULL) if (co!=nullptr)
{ {
physAddress *paddr=(Interface::cast(co))->getPhysicalAddress(); physAddress *paddr=(Interface::cast(co))->getPhysicalAddress();
if (paddr!=NULL) if (paddr!=nullptr)
str << " " << paddr->getPhysAddress().c_str(); str << " " << paddr->getPhysAddress().c_str();
} }
@ -377,7 +377,7 @@ QString FWObjectPropertiesFactory::getObjectProperties(FWObject *obj)
.arg(n->getAddressPtr()->toString().c_str()) .arg(n->getAddressPtr()->toString().c_str())
.arg(n->getNetmaskPtr()->getLength()); .arg(n->getNetmaskPtr()->getLength());
} else if (ClusterGroup::cast(obj)!=NULL) } else if (ClusterGroup::cast(obj)!=nullptr)
{ {
ClusterGroup *g = ClusterGroup::cast(obj); ClusterGroup *g = ClusterGroup::cast(obj);
str << QObject::tr("Type: ") << g->getStr("type").c_str() << " "; str << QObject::tr("Type: ") << g->getStr("type").c_str() << " ";
@ -399,10 +399,10 @@ QString FWObjectPropertiesFactory::getObjectProperties(FWObject *obj)
members.push_front(QObject::tr("Members:")); members.push_front(QObject::tr("Members:"));
str << members.join(" "); str << members.join(" ");
} }
} else if (DynamicGroup::cast(obj) != 0) { } else if (DynamicGroup::cast(obj) != nullptr) {
DynamicGroup *objGroup = DynamicGroup::cast(obj); DynamicGroup *objGroup = DynamicGroup::cast(obj);
str << QObject::tr("%1 filters").arg(objGroup->getFilter().size()); str << QObject::tr("%1 filters").arg(objGroup->getFilter().size());
} else if (Group::cast(obj)!=NULL) // just any group } else if (Group::cast(obj)!=nullptr) // just any group
{ {
Group *g=Group::cast(obj); Group *g=Group::cast(obj);
str << QObject::tr("%1 objects").arg(g->size()); str << QObject::tr("%1 objects").arg(g->size());
@ -696,7 +696,7 @@ QString FWObjectPropertiesFactory::getObjectPropertiesDetailed(FWObject *obj,
str += n->getAddressPtr()->toString().c_str(); str += n->getAddressPtr()->toString().c_str();
str += "/"; str += "/";
str += QString("%1").arg(n->getNetmaskPtr()->getLength()); str += QString("%1").arg(n->getNetmaskPtr()->getLength());
} else if (ClusterGroup::cast(obj)!=NULL) } else if (ClusterGroup::cast(obj)!=nullptr)
{ {
if (showPath && !tooltip) str += "<b>Path: </b>" + path + "<br>\n"; if (showPath && !tooltip) str += "<b>Path: </b>" + path + "<br>\n";
ClusterGroup *g = ClusterGroup::cast(obj); ClusterGroup *g = ClusterGroup::cast(obj);
@ -712,10 +712,10 @@ QString FWObjectPropertiesFactory::getObjectPropertiesDetailed(FWObject *obj,
arg(fw->getName().c_str()).arg(obj->getName().c_str()); arg(fw->getName().c_str()).arg(obj->getName().c_str());
} }
} }
} else if (DynamicGroup::cast(obj) != 0) { } else if (DynamicGroup::cast(obj) != nullptr) {
DynamicGroup *objGroup = DynamicGroup::cast(obj); DynamicGroup *objGroup = DynamicGroup::cast(obj);
str += QObject::tr("%1 filters<br>\n").arg(objGroup->getFilter().size()); str += QObject::tr("%1 filters<br>\n").arg(objGroup->getFilter().size());
} else if (Group::cast(obj)!=NULL) // just any group } else if (Group::cast(obj)!=nullptr) // just any group
{ {
if (showPath && !tooltip) str += "<b>Path: </b>" + path + "<br>\n"; if (showPath && !tooltip) str += "<b>Path: </b>" + path + "<br>\n";
Group *g = Group::cast(obj); Group *g = Group::cast(obj);
@ -733,7 +733,7 @@ QString FWObjectPropertiesFactory::getObjectPropertiesDetailed(FWObject *obj,
} else } else
{ {
FWObject *o1=*i; FWObject *o1=*i;
if (FWReference::cast(o1)!=NULL) if (FWReference::cast(o1)!=nullptr)
o1=FWReference::cast(o1)->getPointer(); o1=FWReference::cast(o1)->getPointer();
str += QString(o1->getTypeName().c_str()) str += QString(o1->getTypeName().c_str())
+ " <b>" + QString::fromUtf8(o1->getName().c_str()) + "</b><br>\n"; + " <b>" + QString::fromUtf8(o1->getName().c_str()) + "</b><br>\n";
@ -791,10 +791,10 @@ QString FWObjectPropertiesFactory::getObjectPropertiesDetailed(FWObject *obj,
do do
{ {
parent_host = parent_host->getParent(); parent_host = parent_host->getParent();
if (parent_host == NULL) break; if (parent_host == nullptr) break;
short_path.push_front(QString::fromUtf8(parent_host->getName().c_str())); short_path.push_front(QString::fromUtf8(parent_host->getName().c_str()));
} }
while (Host::cast(parent_host) == NULL); while (Host::cast(parent_host) == nullptr);
str += QString("<b>Parent: </b>%1<br>\n").arg(short_path.join("/")); str += QString("<b>Parent: </b>%1<br>\n").arg(short_path.join("/"));
@ -824,7 +824,7 @@ QString FWObjectPropertiesFactory::getObjectPropertiesDetailed(FWObject *obj,
} }
physAddress *paddr = intf->getPhysicalAddress(); physAddress *paddr = intf->getPhysicalAddress();
if (paddr!=NULL) if (paddr!=nullptr)
{ {
str += "MAC: "; str += "MAC: ";
str += paddr->getPhysAddress().c_str() ; str += paddr->getPhysAddress().c_str() ;
@ -837,8 +837,8 @@ QString FWObjectPropertiesFactory::getObjectPropertiesDetailed(FWObject *obj,
if (intf->isBridgePort()) q=" bridge port"; if (intf->isBridgePort()) q=" bridge port";
FWObject *p=obj; FWObject *p=obj;
while (p!=NULL && !Firewall::cast(p)) p=p->getParent(); while (p!=nullptr && !Firewall::cast(p)) p=p->getParent();
if (p!=NULL && (p->getStr("platform")=="pix" || p->getStr("platform")=="fwsm")) if (p!=nullptr && (p->getStr("platform")=="pix" || p->getStr("platform")=="fwsm"))
{ {
int sl = intf->getSecurityLevel(); int sl = intf->getSecurityLevel();
q=q+QString("sec.level %1").arg(sl); q=q+QString("sec.level %1").arg(sl);
@ -932,13 +932,13 @@ QString FWObjectPropertiesFactory::getRuleActionProperties(Rule *rule)
{ {
QString par = ""; QString par = "";
if (rule!=NULL) if (rule!=nullptr)
{ {
QString act = getRuleAction(rule); QString act = getRuleAction(rule);
FWObject *o = rule; FWObject *o = rule;
while (o!=NULL && Firewall::cast(o)==NULL) o=o->getParent(); while (o!=nullptr && Firewall::cast(o)==nullptr) o=o->getParent();
if (o==NULL) return ""; if (o==nullptr) return "";
Firewall *f=Firewall::cast(o); Firewall *f=Firewall::cast(o);
string platform=f->getStr("platform"); string platform=f->getStr("platform");
@ -1003,8 +1003,8 @@ QString FWObjectPropertiesFactory::getRuleActionProperties(Rule *rule)
QString FWObjectPropertiesFactory::getRuleActionPropertiesRich(Rule *rule) QString FWObjectPropertiesFactory::getRuleActionPropertiesRich(Rule *rule)
{ {
FWObject *p=rule; FWObject *p=rule;
while (p!=NULL && !Firewall::cast(p)) p=p->getParent(); while (p!=nullptr && !Firewall::cast(p)) p=p->getParent();
if (p==NULL) if (p==nullptr)
{ {
qDebug() << "FWObjectPropertiesFactory::getRuleActionPropertiesRich(): " qDebug() << "FWObjectPropertiesFactory::getRuleActionPropertiesRich(): "
<< "Can not locate parent firewall for the rule:"; << "Can not locate parent firewall for the rule:";
@ -1025,14 +1025,14 @@ QString FWObjectPropertiesFactory::getRuleActionPropertiesRich(Rule *rule)
QString FWObjectPropertiesFactory::getPolicyRuleOptions(Rule *rule) QString FWObjectPropertiesFactory::getPolicyRuleOptions(Rule *rule)
{ {
if (rule == NULL) return ""; if (rule == nullptr) return "";
QList<QPair<QString,QString> > options; QList<QPair<QString,QString> > options;
PolicyRule *prule = PolicyRule::cast(rule); PolicyRule *prule = PolicyRule::cast(rule);
FWObject *o = rule; FWObject *o = rule;
while (o!=NULL && Firewall::cast(o)==NULL) o = o->getParent(); while (o!=nullptr && Firewall::cast(o)==nullptr) o = o->getParent();
assert(o!=NULL); assert(o!=nullptr);
Firewall *f = Firewall::cast(o); Firewall *f = Firewall::cast(o);
string platform = f->getStr("platform"); string platform = f->getStr("platform");
FWOptions *ropt = rule->getOptionsObject(); FWOptions *ropt = rule->getOptionsObject();
@ -1317,12 +1317,12 @@ QString FWObjectPropertiesFactory::getNATRuleOptions(Rule *rule)
{ {
QString res; QString res;
if (rule!=NULL) if (rule!=nullptr)
{ {
res=""; res="";
FWObject *o = rule; FWObject *o = rule;
while (o!=NULL && Firewall::cast(o)==NULL) o=o->getParent(); while (o!=nullptr && Firewall::cast(o)==nullptr) o=o->getParent();
assert(o!=NULL); assert(o!=nullptr);
Firewall *f=Firewall::cast(o); Firewall *f=Firewall::cast(o);
string platform=f->getStr("platform"); string platform=f->getStr("platform");
FWOptions *ropt = rule->getOptionsObject(); FWOptions *ropt = rule->getOptionsObject();
@ -1357,7 +1357,7 @@ QString FWObjectPropertiesFactory::getNATRuleOptions(Rule *rule)
QString FWObjectPropertiesFactory::getInterfaceNameExamplesForHostOS(const QString &host_os) QString FWObjectPropertiesFactory::getInterfaceNameExamplesForHostOS(const QString &host_os)
{ {
Resources *os_resources = Resources::os_res[host_os.toStdString()]; Resources *os_resources = Resources::os_res[host_os.toStdString()];
if (os_resources == NULL) return ""; if (os_resources == nullptr) return "";
string os_family = os_resources-> getResourceStr("/FWBuilderResources/Target/family"); string os_family = os_resources-> getResourceStr("/FWBuilderResources/Target/family");
if (os_family == "linux24" || if (os_family == "linux24" ||

View File

@ -30,8 +30,8 @@ using namespace libfwbuilder;
FWObjectSelectionModel::FWObjectSelectionModel() FWObjectSelectionModel::FWObjectSelectionModel()
{ {
selectedObject = 0; selectedObject = nullptr;
selectedObjectOld = 0; selectedObjectOld = nullptr;
} }
void FWObjectSelectionModel::setSelected(FWObject * so, const QModelIndex &index) void FWObjectSelectionModel::setSelected(FWObject * so, const QModelIndex &index)
@ -56,5 +56,5 @@ void FWObjectSelectionModel::restore()
void FWObjectSelectionModel::reset() void FWObjectSelectionModel::reset()
{ {
QModelIndex index; QModelIndex index;
setSelected(NULL, index); setSelected(nullptr, index);
} }

View File

@ -63,7 +63,7 @@ using namespace libfwbuilder;
*/ */
bool FWWindow::isEditorVisible() bool FWWindow::isEditorVisible()
{ {
return oe != NULL && m_mainWindow->editorDockWidget->isVisible() && return oe != nullptr && m_mainWindow->editorDockWidget->isVisible() &&
m_mainWindow->editorPanelTabWidget->currentIndex() == EDITOR_PANEL_EDITOR_TAB; m_mainWindow->editorPanelTabWidget->currentIndex() == EDITOR_PANEL_EDITOR_TAB;
} }
@ -109,7 +109,7 @@ void FWWindow::clearEditorAndSearchPanels()
{ {
findWhereUsedWidget->clear(); findWhereUsedWidget->clear();
findObjectWidget->clear(); findObjectWidget->clear();
if (oe != NULL) oe->blank(); if (oe != nullptr) oe->blank();
} }
void FWWindow::openEditorPanel() void FWWindow::openEditorPanel()
@ -146,7 +146,7 @@ void FWWindow::openEditor(FWObject *obj)
current_focus_widget && current_focus_widget &&
m_mainWindow->editorDockWidget->isAncestorOf(current_focus_widget)); m_mainWindow->editorDockWidget->isAncestorOf(current_focus_widget));
QLineEdit *line_edit = dynamic_cast<QLineEdit*>(current_focus_widget); QLineEdit *line_edit = dynamic_cast<QLineEdit*>(current_focus_widget);
bool restore_line_edit_selection = line_edit != NULL && line_edit->hasSelectedText(); bool restore_line_edit_selection = line_edit != nullptr && line_edit->hasSelectedText();
if (fwbdebug) if (fwbdebug)
{ {
@ -184,13 +184,13 @@ void FWWindow::openEditor(FWObject *obj)
qDebug() << "parent firewall:" << parent_fw qDebug() << "parent firewall:" << parent_fw
<< QString((parent_fw)? parent_fw->getName().c_str() : ""); << QString((parent_fw)? parent_fw->getName().c_str() : "");
if (parent_fw != NULL) // this includes Cluster if (parent_fw != nullptr) // this includes Cluster
{ {
RuleSetView* rsv = activeProject()->getCurrentRuleSetView(); RuleSetView* rsv = activeProject()->getCurrentRuleSetView();
if (rsv) if (rsv)
{ {
RuleSet* current_ruleset = NULL; RuleSet* current_ruleset = nullptr;
RuleSetModel* md = NULL; RuleSetModel* md = nullptr;
if (rsv) if (rsv)
{ {
md = (RuleSetModel*)rsv->model(); md = (RuleSetModel*)rsv->model();
@ -202,10 +202,10 @@ void FWWindow::openEditor(FWObject *obj)
activeProject()->m_panel->om->findRuleSetInHistoryByParentFw( activeProject()->m_panel->om->findRuleSetInHistoryByParentFw(
parent_fw); parent_fw);
if (old_rs == NULL) if (old_rs == nullptr)
old_rs = parent_fw->getFirstByType(Policy::TYPENAME); old_rs = parent_fw->getFirstByType(Policy::TYPENAME);
if (old_rs != NULL) if (old_rs != nullptr)
QCoreApplication::postEvent( QCoreApplication::postEvent(
activeProject(), new openRulesetImmediatelyEvent( activeProject(), new openRulesetImmediatelyEvent(
activeProject()->getFileName(), old_rs->getId())); activeProject()->getFileName(), old_rs->getId()));
@ -273,8 +273,8 @@ void FWWindow::buildEditorTitleAndIcon(libfwbuilder::FWObject *obj,
QStringList editor_title; QStringList editor_title;
FWObject *o = obj; FWObject *o = obj;
Rule *rule = NULL; Rule *rule = nullptr;
FWObject *ruleset = NULL; FWObject *ruleset = nullptr;
while (o) while (o)
{ {
if (Rule::cast(o)) if (Rule::cast(o))

View File

@ -417,7 +417,7 @@ QString FWWindow::getCurrentFileName()
RCS * FWWindow::getRCS() RCS * FWWindow::getRCS()
{ {
if (activeProject()) return activeProject()->getRCS(); if (activeProject()) return activeProject()->getRCS();
return 0; return nullptr;
} }
/* /*
@ -433,14 +433,14 @@ FWObject* FWWindow::getCurrentLib()
{ {
if (activeProject()) if (activeProject())
return activeProject()->getCurrentLib(); return activeProject()->getCurrentLib();
return 0; return nullptr;
} }
FWObject* FWWindow::createObject(const QString &objType, FWObject* FWWindow::createObject(const QString &objType,
const QString &objName, const QString &objName,
FWObject *copyFrom) FWObject *copyFrom)
{ {
FWObject *res = NULL; FWObject *res = nullptr;
if (activeProject()) if (activeProject())
{ {
res = activeProject()->createObject(objType, objName, copyFrom); res = activeProject()->createObject(objType, objName, copyFrom);
@ -453,7 +453,7 @@ FWObject* FWWindow::createObject(FWObject *parent,
const QString &objName, const QString &objName,
FWObject *copyFrom) FWObject *copyFrom)
{ {
FWObject *res = NULL; FWObject *res = nullptr;
if (activeProject()) if (activeProject())
{ {
res = activeProject()->createObject(parent, objType, res = activeProject()->createObject(parent, objType,
@ -481,7 +481,7 @@ void FWWindow::moveObject(const QString &targetLibName, FWObject *obj)
ObjectTreeView* FWWindow::getCurrentObjectTree() ObjectTreeView* FWWindow::getCurrentObjectTree()
{ {
if (activeProject()) return activeProject()->getCurrentObjectTree(); if (activeProject()) return activeProject()->getCurrentObjectTree();
return 0; return nullptr;
} }
void FWWindow::findAllFirewalls (std::list<Firewall *> &fws) void FWWindow::findAllFirewalls (std::list<Firewall *> &fws)
@ -508,7 +508,7 @@ void FWWindow::unselect()
FWObjectDatabase* FWWindow::db() FWObjectDatabase* FWWindow::db()
{ {
if (activeProject()) return activeProject()->db(); if (activeProject()) return activeProject()->db();
return NULL; return nullptr;
} }
QString FWWindow::printHeader() QString FWWindow::printHeader()

View File

@ -140,7 +140,7 @@ void FindObjectWidget::disableAll()
void FindObjectWidget::objectInserted() void FindObjectWidget::objectInserted()
{ {
FWObject *o = m_widget->findDropArea->getObject(); FWObject *o = m_widget->findDropArea->getObject();
if (o == NULL) return; if (o == nullptr) return;
// disableAll(); // see #1757 // disableAll(); // see #1757
@ -160,7 +160,7 @@ void FindObjectWidget::objectInserted()
void FindObjectWidget::reset() void FindObjectWidget::reset()
{ {
lastFound = NULL; lastFound = nullptr;
lastAttrSearch = ""; lastAttrSearch = "";
found_objects.clear(); found_objects.clear();
} }
@ -169,7 +169,7 @@ void FindObjectWidget::clear()
{ {
m_widget->findDropArea->deleteObject(); m_widget->findDropArea->deleteObject();
m_widget->replaceDropArea->deleteObject(); m_widget->replaceDropArea->deleteObject();
lastFound = NULL; lastFound = nullptr;
lastAttrSearch = ""; lastAttrSearch = "";
found_objects.clear(); found_objects.clear();
} }
@ -283,7 +283,7 @@ bool FindObjectWidget::matchAttr(FWObject *obj)
} }
Address *a = Address::cast(obj); Address *a = Address::cast(obj);
if (a!=NULL) if (a!=nullptr)
{ {
const InetAddr *inet_addr = a->getAddressPtr(); const InetAddr *inet_addr = a->getAddressPtr();
if (inet_addr) if (inet_addr)
@ -301,7 +301,7 @@ bool FindObjectWidget::matchAttr(FWObject *obj)
} }
case 2: // port case 2: // port
if (TCPService::cast(obj)!=NULL || UDPService::cast(obj)!=NULL) if (TCPService::cast(obj)!=nullptr || UDPService::cast(obj)!=nullptr)
{ {
if (m_widget->useRegexp->isChecked()) if (m_widget->useRegexp->isChecked())
{ {
@ -332,7 +332,7 @@ bool FindObjectWidget::matchAttr(FWObject *obj)
break; break;
case 3: // protocol num. case 3: // protocol num.
if (IPService::cast(obj)!=NULL) if (IPService::cast(obj)!=nullptr)
{ {
if (m_widget->useRegexp->isChecked()) if (m_widget->useRegexp->isChecked())
{ {
@ -350,7 +350,7 @@ bool FindObjectWidget::matchAttr(FWObject *obj)
break; break;
case 4: // icmp type case 4: // icmp type
if (ICMPService::cast(obj)!=NULL) if (ICMPService::cast(obj)!=nullptr)
{ {
if (m_widget->useRegexp->isChecked()) if (m_widget->useRegexp->isChecked())
{ {
@ -381,7 +381,7 @@ void FindObjectWidget::_findAll()
{ {
FWObject *o = *treeSeeker; FWObject *o = *treeSeeker;
if( RuleElement::cast(o->getParent())!=NULL) if( RuleElement::cast(o->getParent())!=nullptr)
{ {
if (m_widget->srScope->currentIndex()==3) // scope == selected firewalls if (m_widget->srScope->currentIndex()==3) // scope == selected firewalls
{ {
@ -398,7 +398,7 @@ void FindObjectWidget::_findAll()
} }
FWObject *obj = o; FWObject *obj = o;
if (FWReference::cast(o)!=NULL) if (FWReference::cast(o)!=nullptr)
{ {
FWReference *r = FWReference::cast(o); FWReference *r = FWReference::cast(o);
obj = r->getPointer(); obj = r->getPointer();
@ -435,7 +435,7 @@ void FindObjectWidget::findNext()
if (m_widget->findAttr->count()>MAX_SEARCH_ITEMS_COUNT) if (m_widget->findAttr->count()>MAX_SEARCH_ITEMS_COUNT)
m_widget->findAttr->removeItem(0); m_widget->findAttr->removeItem(0);
FWObject *o = NULL; FWObject *o = nullptr;
// if scope is "policies of opened firewall" then we need to get // if scope is "policies of opened firewall" then we need to get
// pointer to the currently opened firewall object // pointer to the currently opened firewall object
@ -443,7 +443,7 @@ void FindObjectWidget::findNext()
if (current_rule_set) if (current_rule_set)
selectedFirewall = Firewall::cast(current_rule_set->getParent()); selectedFirewall = Firewall::cast(current_rule_set->getParent());
else else
selectedFirewall = NULL; selectedFirewall = nullptr;
if (fwbdebug) qDebug() << "selectedFirewall: " << selectedFirewall; if (fwbdebug) qDebug() << "selectedFirewall: " << selectedFirewall;
@ -485,7 +485,7 @@ loop:
o = *found_objects_iter; o = *found_objects_iter;
++found_objects_iter; ++found_objects_iter;
assert(o!=NULL); assert(o!=nullptr);
lastFound = o; lastFound = o;
if (fwbdebug) if (fwbdebug)
@ -526,19 +526,19 @@ bool FindObjectWidget::validateReplaceObject()
} }
bool obj_1_address = bool obj_1_address =
Address::cast(findObj)!=NULL || Address::cast(findObj)!=nullptr ||
MultiAddress::cast(findObj)!=NULL || MultiAddress::cast(findObj)!=nullptr ||
ObjectGroup::cast(findObj)!=NULL; ObjectGroup::cast(findObj)!=nullptr;
bool obj_2_address = bool obj_2_address =
Address::cast(replObj)!=NULL || Address::cast(replObj)!=nullptr ||
MultiAddress::cast(replObj)!=NULL || MultiAddress::cast(replObj)!=nullptr ||
ObjectGroup::cast(replObj)!=NULL; ObjectGroup::cast(replObj)!=nullptr;
bool obj_1_service = bool obj_1_service =
Service::cast(findObj)!=NULL || ServiceGroup::cast(findObj); Service::cast(findObj)!=nullptr || ServiceGroup::cast(findObj);
bool obj_2_service = bool obj_2_service =
Service::cast(replObj)!=NULL || ServiceGroup::cast(replObj); Service::cast(replObj)!=nullptr || ServiceGroup::cast(replObj);
if ((obj_1_address && obj_2_address) || (obj_1_service && obj_2_service)) if ((obj_1_address && obj_2_address) || (obj_1_service && obj_2_service))
return true; return true;
@ -554,7 +554,7 @@ void FindObjectWidget::replace()
{ {
if (!validateReplaceObject()) return; if (!validateReplaceObject()) return;
if (lastFound==NULL) if (lastFound==nullptr)
{ {
find(); find();
return; return;
@ -587,9 +587,9 @@ void FindObjectWidget::replaceAll()
if (current_rule_set) if (current_rule_set)
selectedFirewall = Firewall::cast(current_rule_set->getParent()); selectedFirewall = Firewall::cast(current_rule_set->getParent());
else else
selectedFirewall = NULL; selectedFirewall = nullptr;
if (selectedFirewall == NULL) if (selectedFirewall == nullptr)
{ {
QMessageBox::critical(this, QMessageBox::critical(this,
"Firewall Builder", "Firewall Builder",
@ -633,8 +633,8 @@ void FindObjectWidget::_replaceCurrent()
FWObject *o = lastFound; FWObject *o = lastFound;
FWObject *p = lastFound->getParent(); FWObject *p = lastFound->getParent();
if (p==NULL || o==NULL) return; if (p==nullptr || o==nullptr) return;
if (FWReference::cast(o)==NULL) return; if (FWReference::cast(o)==nullptr) return;
if (p->isReadOnly()) if (p->isReadOnly())
{ {
@ -679,7 +679,7 @@ void FindObjectWidget::_replaceCurrent()
// check for duplicates -------- // check for duplicates --------
if (RuleElement::cast(new_state)==NULL || if (RuleElement::cast(new_state)==nullptr ||
!RuleElement::cast(new_state)->isAny()) !RuleElement::cast(new_state)->isAny())
{ {
// avoid duplicates // avoid duplicates
@ -692,7 +692,7 @@ void FindObjectWidget::_replaceCurrent()
{ {
oo = *j; oo = *j;
if (cp_id==oo->getId() || if (cp_id==oo->getId() ||
((ref=FWReference::cast(oo))!=NULL && ((ref=FWReference::cast(oo))!=nullptr &&
cp_id==ref->getPointerId())) cp_id==ref->getPointerId()))
{ {
// replacement object is already a member of this // replacement object is already a member of this
@ -718,8 +718,8 @@ void FindObjectWidget::_replaceCurrent()
bool FindObjectWidget::inSelectedFirewall( RuleElement* r) bool FindObjectWidget::inSelectedFirewall( RuleElement* r)
{ {
FWObject *f=r; FWObject *f=r;
while (f!=NULL && Firewall::cast(f)==NULL) f=f->getParent(); while (f!=nullptr && Firewall::cast(f)==nullptr) f=f->getParent();
if (f==NULL) return false; if (f==nullptr) return false;
return selectedFirewall==(Firewall::cast(f)); return selectedFirewall==(Firewall::cast(f));
} }
@ -750,7 +750,7 @@ void FindObjectWidget::showObject(FWObject* o)
o->getName().c_str(), o->getParent()->getName().c_str()); o->getName().c_str(), o->getParent()->getName().c_str());
FWReference* ref = FWReference::cast(o); FWReference* ref = FWReference::cast(o);
if (ref!=NULL && RuleElement::cast(o->getParent())!=NULL) if (ref!=nullptr && RuleElement::cast(o->getParent())!=nullptr)
{ {
// found object in rules // found object in rules
QCoreApplication::sendEvent( QCoreApplication::sendEvent(
@ -760,7 +760,7 @@ void FindObjectWidget::showObject(FWObject* o)
} }
if (!FWBTree().isStandardFolder(o) && if (!FWBTree().isStandardFolder(o) &&
Group::cast(o->getParent())!=NULL && Group::cast(o->getParent())!=nullptr &&
!FWBTree().isStandardFolder(o->getParent())) !FWBTree().isStandardFolder(o->getParent()))
{ {
QCoreApplication::sendEvent( QCoreApplication::sendEvent(
@ -781,7 +781,7 @@ void FindObjectWidget::init()
void FindObjectWidget::firewallOpened(Firewall *f) void FindObjectWidget::firewallOpened(Firewall *f)
{ {
if (f==NULL) return; if (f==nullptr) return;
selectedFirewall = f; selectedFirewall = f;
m_widget->srScope->setItemText( m_widget->srScope->setItemText(
3, tr("Policy of firewall '")+f->getName().c_str()+"'" ); 3, tr("Policy of firewall '")+f->getName().c_str()+"'" );

View File

@ -123,7 +123,7 @@ void FindWhereUsedWidget::itemActivated(QTreeWidgetItem* item, int)
{ {
FWObject *container = (FWObject*)(item->data(1, Qt::UserRole).value<void*>()); FWObject *container = (FWObject*)(item->data(1, Qt::UserRole).value<void*>());
if (flShowObject && container!=NULL) if (flShowObject && container!=nullptr)
{ {
showObject(container); showObject(container);
} }
@ -140,7 +140,7 @@ void FindWhereUsedWidget::itemActivated(QTreeWidgetItem* item, int)
void FindWhereUsedWidget::itemClicked(QTreeWidgetItem* item, int) void FindWhereUsedWidget::itemClicked(QTreeWidgetItem* item, int)
{ {
FWObject *container = (FWObject*)(item->data(1, Qt::UserRole).value<void*>()); FWObject *container = (FWObject*)(item->data(1, Qt::UserRole).value<void*>());
if (flShowObject && container!=NULL) if (flShowObject && container!=nullptr)
{ {
showObject(container); showObject(container);
} }
@ -171,7 +171,7 @@ void FindWhereUsedWidget::_find(FWObject *obj)
<< " project_panel " << " project_panel "
<< project_panel; << project_panel;
if (project_panel==NULL) return; if (project_panel==nullptr) return;
FWObjectDatabase *db = obj->getRoot(); FWObjectDatabase *db = obj->getRoot();
map<int, set<FWObject*> > reference_holders; map<int, set<FWObject*> > reference_holders;
@ -190,7 +190,7 @@ void FindWhereUsedWidget::_find(FWObject *obj)
foreach(FWObject *container, it->second) foreach(FWObject *container, it->second)
{ {
QTreeWidgetItem *item = createQTWidgetItem(c_obj, container); QTreeWidgetItem *item = createQTWidgetItem(c_obj, container);
if (item==NULL) continue; if (item==nullptr) continue;
QStringList item_str; QStringList item_str;
item_str << item->text(0) << item->text(1) << item->text(2); item_str << item->text(0) << item->text(1) << item->text(2);
widget_items[item_str.join("/")] = item; widget_items[item_str.join("/")] = item;
@ -214,7 +214,7 @@ void FindWhereUsedWidget::_find(FWObject *obj)
void FindWhereUsedWidget::init() void FindWhereUsedWidget::init()
{ {
object = NULL; object = nullptr;
m_widget->resListView->clear(); m_widget->resListView->clear();
resset.clear(); resset.clear();
} }
@ -234,9 +234,9 @@ void FindWhereUsedWidget::showObject(FWObject* o)
if (fwbdebug) qDebug("FindWhereUsedWidget::showObject o=%s (%s)", if (fwbdebug) qDebug("FindWhereUsedWidget::showObject o=%s (%s)",
o->getName().c_str(), o->getTypeName().c_str()); o->getName().c_str(), o->getTypeName().c_str());
if (object==NULL || o==NULL) return; if (object==nullptr || o==nullptr) return;
if (RuleElement::cast(o)!=NULL || RuleElement::cast(o->getParent())!=NULL) if (RuleElement::cast(o)!=nullptr || RuleElement::cast(o->getParent())!=nullptr)
{ {
QCoreApplication::postEvent( QCoreApplication::postEvent(
project_panel, project_panel,
@ -244,7 +244,7 @@ void FindWhereUsedWidget::showObject(FWObject* o)
return; return;
} }
if (Rule::cast(o)!=NULL) if (Rule::cast(o)!=nullptr)
{ {
QCoreApplication::postEvent( QCoreApplication::postEvent(
project_panel, project_panel,
@ -259,7 +259,7 @@ void FindWhereUsedWidget::showObject(FWObject* o)
project_panel->unselectRules(); project_panel->unselectRules();
if (Group::cast(o)!=NULL) if (Group::cast(o)!=nullptr)
{ {
QCoreApplication::postEvent( QCoreApplication::postEvent(
project_panel, project_panel,
@ -283,26 +283,26 @@ QTreeWidgetItem* FindWhereUsedWidget::createQTWidgetItem(FWObject *o,
<< "(" << container->getTypeName().c_str() << ")"; << "(" << container->getTypeName().c_str() << ")";
QString c1, c2; QString c1, c2;
FWObject *fw = NULL; FWObject *fw = nullptr;
Rule *r = NULL; Rule *r = nullptr;
RuleSet *rs = NULL; RuleSet *rs = nullptr;
QPixmap object_icon; QPixmap object_icon;
QPixmap parent_icon; QPixmap parent_icon;
FWBTree tree_format; FWBTree tree_format;
if (tree_format.isSystem(container) || Library::cast(container)) return NULL; if (tree_format.isSystem(container) || Library::cast(container)) return nullptr;
// container can be a Rule if user searched for an object used in action // container can be a Rule if user searched for an object used in action
if (RuleElement::cast(container)!=NULL || Rule::cast(container)!=NULL) if (RuleElement::cast(container)!=nullptr || Rule::cast(container)!=nullptr)
{ {
fw = container; fw = container;
while (fw!=NULL && Firewall::cast(fw)==NULL) // Firewall::cast matches also Cluster while (fw!=nullptr && Firewall::cast(fw)==nullptr) // Firewall::cast matches also Cluster
{ {
if (Rule::cast(fw)) r = Rule::cast(fw); if (Rule::cast(fw)) r = Rule::cast(fw);
if (RuleSet::cast(fw)) rs = RuleSet::cast(fw); if (RuleSet::cast(fw)) rs = RuleSet::cast(fw);
fw = fw->getParent(); fw = fw->getParent();
} }
if (fw==NULL || r==NULL || rs==NULL) return NULL; if (fw==nullptr || r==nullptr || rs==nullptr) return nullptr;
c1 = QString::fromUtf8(fw->getName().c_str()); c1 = QString::fromUtf8(fw->getName().c_str());
QString ruleset_kind; QString ruleset_kind;
@ -323,12 +323,12 @@ QTreeWidgetItem* FindWhereUsedWidget::createQTWidgetItem(FWObject *o,
QString rule_element_name; QString rule_element_name;
if (RuleElement::cast(container)!=NULL) if (RuleElement::cast(container)!=nullptr)
rule_element_name = rule_element_name =
getReadableRuleElementName( getReadableRuleElementName(
fw->getStr("platform"), container->getParent()->getTypeName()); fw->getStr("platform"), container->getParent()->getTypeName());
if (Rule::cast(container)!=NULL) if (Rule::cast(container)!=nullptr)
rule_element_name = "Action"; rule_element_name = "Action";
c2 += tr("%1 \"%2\" / Rule %3 / %4"). c2 += tr("%1 \"%2\" / Rule %3 / %4").

View File

@ -78,7 +78,7 @@ FirewallDialog::FirewallDialog(QWidget *parent) :
{ {
m_dialog = new Ui::FirewallDialog_q; m_dialog = new Ui::FirewallDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -89,7 +89,7 @@ void FirewallDialog::loadFWObject(FWObject *o)
{ {
obj = o; obj = o;
Firewall *s = dynamic_cast<Firewall*>(obj); Firewall *s = dynamic_cast<Firewall*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init = true; init = true;
@ -106,7 +106,7 @@ void FirewallDialog::loadFWObject(FWObject *o)
updateTimeStamps(); updateTimeStamps();
Management *mgmt=s->getManagementObject(); Management *mgmt=s->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
// FWOptions *opt =s->getOptionsObject(); // FWOptions *opt =s->getOptionsObject();
@ -239,7 +239,7 @@ void FirewallDialog::validate(bool *res)
if (m_dialog->obj_name->text().contains("/")) if (m_dialog->obj_name->text().contains("/"))
{ {
*res = false; *res = false;
if (QApplication::focusWidget() != NULL) if (QApplication::focusWidget() != nullptr)
{ {
blockSignals(true); blockSignals(true);
QMessageBox::critical( QMessageBox::critical(
@ -309,7 +309,7 @@ void FirewallDialog::applyChanges()
Firewall *s = dynamic_cast<Firewall*>(new_state); Firewall *s = dynamic_cast<Firewall*>(new_state);
Management *mgmt = s->getManagementObject(); Management *mgmt = s->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
string old_name = obj->getName(); string old_name = obj->getName();
string new_name = string(m_dialog->obj_name->text().toUtf8().constData()); string new_name = string(m_dialog->obj_name->text().toUtf8().constData());
@ -363,7 +363,7 @@ void FirewallDialog::applyChanges()
QMessageBox::critical( QMessageBox::critical(
this, "Firewall Builder", this, "Firewall Builder",
tr("Platform setting can not be empty"), tr("Platform setting can not be empty"),
tr("&Continue"), 0, 0, tr("&Continue"), nullptr, nullptr,
0 ); 0 );
return; return;
} }
@ -373,7 +373,7 @@ void FirewallDialog::applyChanges()
QMessageBox::critical( QMessageBox::critical(
this, "Firewall Builder", this, "Firewall Builder",
tr("Host OS setting can not be empty"), tr("Host OS setting can not be empty"),
tr("&Continue"), 0, 0, tr("&Continue"), nullptr, nullptr,
0 ); 0 );
return; return;
} }
@ -401,9 +401,9 @@ void FirewallDialog::openFWDialog()
try try
{ {
QWidget *w = DialogFactory::createFWDialog(mw, obj); QWidget *w = DialogFactory::createFWDialog(mw, obj);
if (w==NULL) return; // some dialogs may not be implemented yet if (w==nullptr) return; // some dialogs may not be implemented yet
QDialog *d=dynamic_cast<QDialog*>(w); QDialog *d=dynamic_cast<QDialog*>(w);
assert(d!=NULL); assert(d!=nullptr);
d->setWindowModality(Qt::WindowModal); d->setWindowModality(Qt::WindowModal);
// d->open(); // d->open();
d->exec(); d->exec();
@ -426,9 +426,9 @@ void FirewallDialog::openOSDialog()
try try
{ {
QWidget *w = DialogFactory::createOSDialog(mw, obj); QWidget *w = DialogFactory::createOSDialog(mw, obj);
if (w==NULL) return; // some dialogs may not be implemented yet if (w==nullptr) return; // some dialogs may not be implemented yet
QDialog *d=dynamic_cast<QDialog*>(w); QDialog *d=dynamic_cast<QDialog*>(w);
assert(d!=NULL); assert(d!=nullptr);
d->exec(); d->exec();
delete d; delete d;
} }

View File

@ -850,7 +850,7 @@ QString FirewallInstaller::getGeneratedFileName(Firewall *fw)
void FirewallInstaller::terminate() void FirewallInstaller::terminate()
{ {
if (session != NULL) if (session != nullptr)
{ {
session->terminate(); session->terminate();
} }

View File

@ -71,7 +71,7 @@ bool FirewallInstallerCisco::packInstallJobsList(Firewall*)
job_list.clear(); job_list.clear();
Management *mgmt = cnf->fwobj->getManagementObject(); Management *mgmt = cnf->fwobj->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
PolicyInstallScript *pis = mgmt->getPolicyInstallScript(); PolicyInstallScript *pis = mgmt->getPolicyInstallScript();
if (pis->getCommand()!="") if (pis->getCommand()!="")
{ {
@ -163,7 +163,7 @@ void FirewallInstallerCisco::activatePolicy(const QString&, const QString&)
packSSHArgs(args); packSSHArgs(args);
if (cnf->verbose) inst_dlg->displayCommand(args); if (cnf->verbose) inst_dlg->displayCommand(args);
SSHCisco *ssh_object = NULL; SSHCisco *ssh_object = nullptr;
if (cnf->fwobj->getStr("platform")=="pix" || if (cnf->fwobj->getStr("platform")=="pix" ||
cnf->fwobj->getStr("platform")=="fwsm") cnf->fwobj->getStr("platform")=="fwsm")
{ {

View File

@ -69,7 +69,7 @@ bool FirewallInstallerJuniper::packInstallJobsList(Firewall*)
job_list.clear(); job_list.clear();
Management *mgmt = cnf->fwobj->getManagementObject(); Management *mgmt = cnf->fwobj->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
PolicyInstallScript *pis = mgmt->getPolicyInstallScript(); PolicyInstallScript *pis = mgmt->getPolicyInstallScript();
if (pis->getCommand()!="") if (pis->getCommand()!="")
{ {

View File

@ -67,7 +67,7 @@ bool FirewallInstallerProcurve::packInstallJobsList(Firewall*)
job_list.clear(); job_list.clear();
Management *mgmt = cnf->fwobj->getManagementObject(); Management *mgmt = cnf->fwobj->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
PolicyInstallScript *pis = mgmt->getPolicyInstallScript(); PolicyInstallScript *pis = mgmt->getPolicyInstallScript();
if (pis->getCommand()!="") if (pis->getCommand()!="")
{ {
@ -146,7 +146,7 @@ void FirewallInstallerProcurve::activatePolicy(const QString&, const QString&)
packSSHArgs(args); packSSHArgs(args);
if (cnf->verbose) inst_dlg->displayCommand(args); if (cnf->verbose) inst_dlg->displayCommand(args);
SSHProcurve *ssh_object = NULL; SSHProcurve *ssh_object = nullptr;
ssh_object = new SSHProcurve(inst_dlg, ssh_object = new SSHProcurve(inst_dlg,
cnf->fwobj->getName().c_str(), cnf->fwobj->getName().c_str(),
args, args,

View File

@ -76,7 +76,7 @@ bool FirewallInstallerUnx::packInstallJobsList(Firewall* fw)
inst_dlg->addToLog(QString("Installation plan:\n")); inst_dlg->addToLog(QString("Installation plan:\n"));
Management *mgmt = cnf->fwobj->getManagementObject(); Management *mgmt = cnf->fwobj->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
PolicyInstallScript *pis = mgmt->getPolicyInstallScript(); PolicyInstallScript *pis = mgmt->getPolicyInstallScript();
if (pis->getCommand()!="") if (pis->getCommand()!="")
{ {

View File

@ -177,9 +177,9 @@ GroupObjectDialog::GroupObjectDialog(QWidget *parent) :
m_dialog = new Ui::GroupObjectDialog_q; m_dialog = new Ui::GroupObjectDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj = NULL; obj = nullptr;
selectedObject = NULL; selectedObject = nullptr;
new_object_menu = NULL; new_object_menu = nullptr;
listView = new ObjectListView( m_dialog->objectViewsStack, "listView" ); listView = new ObjectListView( m_dialog->objectViewsStack, "listView" );
QStringList sl; QStringList sl;
@ -307,9 +307,9 @@ void GroupObjectDialog::listViewSelectionChanged()
void GroupObjectDialog::iconViewCurrentChanged(QListWidgetItem *itm) void GroupObjectDialog::iconViewCurrentChanged(QListWidgetItem *itm)
{ {
if (itm==NULL) if (itm==nullptr)
{ {
selectedObject=NULL; selectedObject=nullptr;
return; return;
} }
int obj_id = itm->data(Qt::UserRole).toInt(); int obj_id = itm->data(Qt::UserRole).toInt();
@ -320,9 +320,9 @@ void GroupObjectDialog::iconViewCurrentChanged(QListWidgetItem *itm)
void GroupObjectDialog::listViewCurrentChanged(QTreeWidgetItem *itm) void GroupObjectDialog::listViewCurrentChanged(QTreeWidgetItem *itm)
{ {
if (itm==NULL) if (itm==nullptr)
{ {
selectedObject=NULL; selectedObject=nullptr;
return; return;
} }
int obj_id = itm->data(0, Qt::UserRole).toInt(); int obj_id = itm->data(0, Qt::UserRole).toInt();
@ -335,9 +335,9 @@ void GroupObjectDialog::listViewCurrentChanged(QTreeWidgetItem *itm)
*/ */
void GroupObjectDialog::insertObject(FWObject *o) void GroupObjectDialog::insertObject(FWObject *o)
{ {
assert(o!=NULL); assert(o!=nullptr);
Group *g = dynamic_cast<Group*>(obj); Group *g = dynamic_cast<Group*>(obj);
assert(g!=NULL); assert(g!=nullptr);
if ( ! g->validateChild(o) || g->isReadOnly() ) return; if ( ! g->validateChild(o) || g->isReadOnly() ) return;
// see #1976 do not allow pasting object that has been deleted // see #1976 do not allow pasting object that has been deleted
@ -368,7 +368,7 @@ void GroupObjectDialog::addIcon(FWObject *fwo)
{ {
FWObject *o=fwo; FWObject *o=fwo;
bool ref=false; bool ref=false;
if (FWReference::cast(o)!=NULL) if (FWReference::cast(o)!=nullptr)
{ {
o=FWReference::cast(o)->getPointer(); o=FWReference::cast(o)->getPointer();
ref=true; ref=true;
@ -412,7 +412,7 @@ void GroupObjectDialog::loadFWObject(FWObject *o)
{ {
obj = o; obj = o;
Group *g = Group::cast(obj); Group *g = Group::cast(obj);
assert(g!=NULL); assert(g!=nullptr);
init=true; init=true;
@ -472,7 +472,7 @@ void GroupObjectDialog::loadFWObject(FWObject *o)
if (new_object_menu) if (new_object_menu)
{ {
new_object_menu->clear(); new_object_menu->clear();
m_dialog->newButton->setMenu(NULL); m_dialog->newButton->setMenu(nullptr);
delete new_object_menu; delete new_object_menu;
} }
@ -540,7 +540,7 @@ void GroupObjectDialog::applyChanges()
for (FWObject::iterator j=obj->begin(); j!=obj->end(); ++j) for (FWObject::iterator j=obj->begin(); j!=obj->end(); ++j)
{ {
FWObject *o = *j; FWObject *o = *j;
if (FWReference::cast(o)!=NULL) o=FWReference::cast(o)->getPointer(); if (FWReference::cast(o)!=nullptr) o=FWReference::cast(o)->getPointer();
oldobj.insert(o->getId()); oldobj.insert(o->getId());
} }
@ -622,7 +622,7 @@ void GroupObjectDialog::switchToListView()
// This method is attached to the context menu item "Edit" // This method is attached to the context menu item "Edit"
void GroupObjectDialog::openObject() void GroupObjectDialog::openObject()
{ {
if (selectedObject!=NULL) if (selectedObject!=nullptr)
{ {
QCoreApplication::postEvent( QCoreApplication::postEvent(
m_project, new showObjectInTreeEvent(selectedObject->getRoot()->getFileName().c_str(), m_project, new showObjectInTreeEvent(selectedObject->getRoot()->getFileName().c_str(),
@ -657,7 +657,7 @@ void GroupObjectDialog::dropped(QDropEvent *ev)
void GroupObjectDialog::iconContextMenu(const QPoint & pos) void GroupObjectDialog::iconContextMenu(const QPoint & pos)
{ {
FWObject *o = NULL; FWObject *o = nullptr;
QListWidgetItem *itm = iconView->itemAt(pos); QListWidgetItem *itm = iconView->itemAt(pos);
if (itm) if (itm)
{ {
@ -671,7 +671,7 @@ void GroupObjectDialog::iconContextMenu(const QPoint & pos)
void GroupObjectDialog::listContextMenu(const QPoint & pos) void GroupObjectDialog::listContextMenu(const QPoint & pos)
{ {
FWObject *o=NULL; FWObject *o=nullptr;
QTreeWidgetItem *itm = listView->itemAt(pos); QTreeWidgetItem *itm = listView->itemAt(pos);
if (itm) if (itm)
{ {
@ -686,7 +686,7 @@ void GroupObjectDialog::setupPopupMenu(const QPoint &pos)
{ {
QMenu *popup = new QMenu(this); QMenu *popup = new QMenu(this);
if (selectedObject!=NULL) if (selectedObject!=nullptr)
{ {
if (selectedObject->isReadOnly() ) if (selectedObject->isReadOnly() )
popup->addAction(tr("Open"), this, SLOT(openObject())); popup->addAction(tr("Open"), this, SLOT(openObject()));
@ -699,9 +699,9 @@ void GroupObjectDialog::setupPopupMenu(const QPoint &pos)
QAction *pasteID = popup->addAction(tr("Paste"), this, SLOT(pasteObj())); QAction *pasteID = popup->addAction(tr("Paste"), this, SLOT(pasteObj()));
QAction *delID = popup->addAction(tr("Delete"),this, SLOT(deleteObj())); QAction *delID = popup->addAction(tr("Delete"),this, SLOT(deleteObj()));
copyID->setEnabled(selectedObject!=NULL && copyID->setEnabled(selectedObject!=nullptr &&
! FWBTree().isSystem(selectedObject) ); ! FWBTree().isSystem(selectedObject) );
cutID->setEnabled(selectedObject!=NULL && cutID->setEnabled(selectedObject!=nullptr &&
! FWBTree().isSystem(obj) && ! FWBTree().isSystem(obj) &&
! obj->isReadOnly() ); ! obj->isReadOnly() );
@ -714,7 +714,7 @@ void GroupObjectDialog::setupPopupMenu(const QPoint &pos)
pasteID->setEnabled(! FWBTree().isSystem(obj) && pasteID->setEnabled(! FWBTree().isSystem(obj) &&
! obj->isReadOnly() && ! obj_deleted); ! obj->isReadOnly() && ! obj_deleted);
delID->setEnabled(selectedObject!=NULL && delID->setEnabled(selectedObject!=nullptr &&
! FWBTree().isSystem(obj) && ! FWBTree().isSystem(obj) &&
! obj->isReadOnly() ); ! obj->isReadOnly() );
@ -729,7 +729,7 @@ void GroupObjectDialog::copyObj()
{ {
FWObject* selectedObject = m_project->db()->findInIndex(*it); FWObject* selectedObject = m_project->db()->findInIndex(*it);
if (selectedObject!=NULL && ! FWBTree().isSystem(selectedObject) ) if (selectedObject!=nullptr && ! FWBTree().isSystem(selectedObject) )
{ {
FWObjectClipboard::obj_clipboard->add(selectedObject, FWObjectClipboard::obj_clipboard->add(selectedObject,
this->m_project ); this->m_project );

View File

@ -57,7 +57,7 @@ ICMPServiceDialog::ICMPServiceDialog(QWidget *parent) :
{ {
m_dialog = new Ui::ICMPServiceDialog_q; m_dialog = new Ui::ICMPServiceDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -71,7 +71,7 @@ void ICMPServiceDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
ICMPService *s = dynamic_cast<ICMPService*>(obj); ICMPService *s = dynamic_cast<ICMPService*>(obj);
assert(s!=NULL); assert(s!=nullptr);
// if (ICMP6Service::isA(o)) // if (ICMP6Service::isA(o))
// { // {

View File

@ -56,7 +56,7 @@ IPServiceDialog::IPServiceDialog(QWidget *parent) : BaseObjectDialog(parent)
{ {
m_dialog = new Ui::IPServiceDialog_q; m_dialog = new Ui::IPServiceDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -84,7 +84,7 @@ void IPServiceDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
IPService *s = dynamic_cast<IPService*>(obj); IPService *s = dynamic_cast<IPService*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init = true; init = true;

View File

@ -81,7 +81,7 @@ InterfaceDialog::InterfaceDialog(QWidget *parent) :
seclevel->hide(); seclevelLabel->hide(); seclevel->hide(); seclevelLabel->hide();
netzone->hide(); netzoneLabel->hide(); netzone->hide(); netzoneLabel->hide();
*/ */
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -96,7 +96,7 @@ void InterfaceDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
Interface *s = dynamic_cast<Interface*>(obj); Interface *s = dynamic_cast<Interface*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init = true; init = true;
@ -345,7 +345,7 @@ void InterfaceDialog::validate(bool *res)
Interface::cast(obj), obj_name, err)) Interface::cast(obj), obj_name, err))
{ {
*res = false; *res = false;
if (QApplication::focusWidget() != NULL) if (QApplication::focusWidget() != nullptr)
{ {
blockSignals(true); blockSignals(true);
QMessageBox::critical( QMessageBox::critical(
@ -379,7 +379,7 @@ void InterfaceDialog::validate(bool *res)
*/ */
*res = false; *res = false;
// show warning dialog only if app has focus // show warning dialog only if app has focus
if (QApplication::focusWidget() != NULL) if (QApplication::focusWidget() != nullptr)
{ {
blockSignals(true); blockSignals(true);
QMessageBox::critical( QMessageBox::critical(
@ -435,7 +435,7 @@ void InterfaceDialog::applyChanges()
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
Interface *intf = Interface::cast(new_state); Interface *intf = Interface::cast(new_state);
assert(intf!=NULL); assert(intf!=nullptr);
string oldname = obj->getName(); string oldname = obj->getName();
string oldlabel = intf->getLabel(); string oldlabel = intf->getLabel();
@ -526,9 +526,9 @@ void InterfaceDialog::openIfaceDialog()
try try
{ {
QWidget *w = DialogFactory::createIfaceDialog(this, obj); QWidget *w = DialogFactory::createIfaceDialog(this, obj);
if (w==NULL) return; // some dialogs may not be implemented yet if (w==nullptr) return; // some dialogs may not be implemented yet
QDialog *d=dynamic_cast<QDialog*>(w); QDialog *d=dynamic_cast<QDialog*>(w);
assert(d!=NULL); assert(d!=nullptr);
d->exec(); d->exec();
delete w; delete w;
} }

View File

@ -43,7 +43,7 @@ InterfaceEditorWidget::InterfaceEditorWidget(QWidget *parent) :
m_ui(new Ui::InterfaceEditorWidget) m_ui(new Ui::InterfaceEditorWidget)
{ {
tabw = dynamic_cast<QTabWidget*>(parent); tabw = dynamic_cast<QTabWidget*>(parent);
this->interfacep = NULL; this->interfacep = nullptr;
m_ui->setupUi(this); m_ui->setupUi(this);
setClusterMode(false); setClusterMode(false);
this->m_ui->name->setText(""); // blank interface name this->m_ui->name->setText(""); // blank interface name
@ -101,7 +101,7 @@ InterfaceEditorWidget::InterfaceEditorWidget(QWidget *parent,
clusterMode = true; clusterMode = true;
tabw = dynamic_cast<QTabWidget*>(parent); tabw = dynamic_cast<QTabWidget*>(parent);
m_ui->setupUi(this); m_ui->setupUi(this);
this->interfacep = NULL; this->interfacep = nullptr;
this->m_ui->name->setText(data.name); this->m_ui->name->setText(data.name);
this->m_ui->label->setText(data.label); this->m_ui->label->setText(data.label);

View File

@ -72,11 +72,11 @@ QMap<Interface*, EditedInterfaceData> InterfacesTabWidget::getData()
{ {
InterfaceEditorWidget *w = dynamic_cast<InterfaceEditorWidget*>( InterfaceEditorWidget *w = dynamic_cast<InterfaceEditorWidget*>(
this->widget(i)); this->widget(i));
if (w == NULL || w->getInterface() == NULL) if (w == nullptr || w->getInterface() == nullptr)
continue; continue;
InterfaceEditorWidget *intEditor = dynamic_cast<InterfaceEditorWidget*>( InterfaceEditorWidget *intEditor = dynamic_cast<InterfaceEditorWidget*>(
this->widget(i)); this->widget(i));
if (intEditor != NULL) if (intEditor != nullptr)
res[intEditor->getInterface()] = intEditor->getInterfaceData(); res[intEditor->getInterface()] = intEditor->getInterfaceData();
} }
return res; return res;
@ -89,7 +89,7 @@ QList<EditedInterfaceData> InterfacesTabWidget::getNewData()
{ {
InterfaceEditorWidget *w = dynamic_cast<InterfaceEditorWidget*>( InterfaceEditorWidget *w = dynamic_cast<InterfaceEditorWidget*>(
this->widget(i)); this->widget(i));
if ( w != NULL && w->getInterface() == NULL) if ( w != nullptr && w->getInterface() == nullptr)
res.append(w->getInterfaceData()); res.append(w->getInterfaceData());
} }
return res; return res;
@ -145,7 +145,7 @@ void InterfacesTabWidget::closeTab()
int idx = this->currentIndex(); int idx = this->currentIndex();
QWidget *w = this->widget(idx); QWidget *w = this->widget(idx);
Interface *iface = dynamic_cast<InterfaceEditorWidget*>(w)->getInterface() ; Interface *iface = dynamic_cast<InterfaceEditorWidget*>(w)->getInterface() ;
if ( iface != NULL ) deleted.append( iface ); if ( iface != nullptr ) deleted.append( iface );
this->removeTab(idx); this->removeTab(idx);
delete w; delete w;
if (this->count() == 0) if (this->count() == 0)
@ -169,7 +169,7 @@ bool InterfacesTabWidget::isValid()
{ {
InterfaceEditorWidget* w = dynamic_cast<InterfaceEditorWidget*>( InterfaceEditorWidget* w = dynamic_cast<InterfaceEditorWidget*>(
this->widget(i)); this->widget(i));
if (w == NULL) continue; if (w == nullptr) continue;
if (!w->isValid()) if (!w->isValid())
{ {
this->setCurrentWidget(w); this->setCurrentWidget(w);
@ -195,8 +195,8 @@ void InterfacesTabWidget::addInterfaceFromData(InterfaceData* idata)
void InterfacesTabWidget::addTab(QWidget* widget, const QString& title) void InterfacesTabWidget::addTab(QWidget* widget, const QString& title)
{ {
if ( dynamic_cast<InterfaceEditorWidget*>(widget) != NULL || if ( dynamic_cast<InterfaceEditorWidget*>(widget) != nullptr ||
(noTabs && dynamic_cast<QLabel*>(widget) != NULL)) (noTabs && dynamic_cast<QLabel*>(widget) != nullptr))
{ {
widget->setObjectName(title+"_widget"); widget->setObjectName(title+"_widget");
if (!noTabs) if (!noTabs)
@ -212,7 +212,7 @@ void InterfacesTabWidget::setClusterMode(bool st)
{ {
InterfaceEditorWidget *w = dynamic_cast<InterfaceEditorWidget*>( InterfaceEditorWidget *w = dynamic_cast<InterfaceEditorWidget*>(
this->widget(i)); this->widget(i));
if (w!=NULL) w->setClusterMode(st); if (w!=nullptr) w->setClusterMode(st);
} }
newInterface.setVisible(!st); newInterface.setVisible(!st);
delInterface.setVisible(!st); delInterface.setVisible(!st);
@ -232,7 +232,7 @@ void InterfacesTabWidget::setExplanation(const QString& text)
{ {
InterfaceEditorWidget* w = dynamic_cast<InterfaceEditorWidget*>( InterfaceEditorWidget* w = dynamic_cast<InterfaceEditorWidget*>(
this->widget(i)); this->widget(i));
if (w!=NULL) w->setExplanation(text); if (w!=nullptr) w->setExplanation(text);
} }
} }
@ -243,6 +243,6 @@ void InterfacesTabWidget::setHostOS(const QString &s)
{ {
InterfaceEditorWidget *w = dynamic_cast<InterfaceEditorWidget*>( InterfaceEditorWidget *w = dynamic_cast<InterfaceEditorWidget*>(
this->widget(i)); this->widget(i));
if (w != NULL) w->setHostOS(host_OS); if (w != nullptr) w->setHostOS(host_OS);
} }
} }

View File

@ -80,12 +80,12 @@ void MetricEditorPanel::applyChanges()
void MetricEditorPanel::loadFWObject(libfwbuilder::FWObject *obj) void MetricEditorPanel::loadFWObject(libfwbuilder::FWObject *obj)
{ {
RoutingRule *r=RoutingRule::cast(obj); RoutingRule *r=RoutingRule::cast(obj);
if (r==NULL) return; if (r==nullptr) return;
rule=r; rule=r;
FWObject *o = r; FWObject *o = r;
while (o!=NULL && Firewall::cast(o)==NULL) o=o->getParent(); while (o!=nullptr && Firewall::cast(o)==nullptr) o=o->getParent();
assert(o!=NULL); assert(o!=nullptr);
m_widget->spin_box->setMinimum( 0); m_widget->spin_box->setMinimum( 0);
m_widget->spin_box->setMaximum( 255); m_widget->spin_box->setMaximum( 255);

View File

@ -59,7 +59,7 @@ NetworkDialogIPv6::NetworkDialogIPv6(QWidget *parent) : BaseObjectDialog(parent)
{ {
m_dialog = new Ui::NetworkDialogIPv6_q; m_dialog = new Ui::NetworkDialogIPv6_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -70,7 +70,7 @@ void NetworkDialogIPv6::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
NetworkIPv6 *s = dynamic_cast<NetworkIPv6*>(obj); NetworkIPv6 *s = dynamic_cast<NetworkIPv6*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init=true; init=true;
@ -111,20 +111,20 @@ void NetworkDialogIPv6::validate(bool *res)
} }
NetworkIPv6 *s = dynamic_cast<NetworkIPv6*>(obj); NetworkIPv6 *s = dynamic_cast<NetworkIPv6*>(obj);
assert(s != NULL); assert(s != nullptr);
try try
{ {
InetAddr(AF_INET6, m_dialog->address->text().toStdString() ); InetAddr(AF_INET6, m_dialog->address->text().toStdString() );
} catch (FWException &ex) } catch (FWException &ex)
{ {
*res = false; *res = false;
if (QApplication::focusWidget() != NULL) if (QApplication::focusWidget() != nullptr)
{ {
blockSignals(true); blockSignals(true);
QMessageBox::critical(this, "Firewall Builder", QMessageBox::critical(this, "Firewall Builder",
tr("Illegal IPv6 address '%1'").arg( tr("Illegal IPv6 address '%1'").arg(
m_dialog->address->text()), m_dialog->address->text()),
tr("&Continue"), 0, 0, tr("&Continue"), nullptr, nullptr,
0 ); 0 );
blockSignals(false); blockSignals(false);
} }
@ -140,13 +140,13 @@ void NetworkDialogIPv6::validate(bool *res)
else else
{ {
*res = false; *res = false;
if (QApplication::focusWidget() != NULL) if (QApplication::focusWidget() != nullptr)
{ {
blockSignals(true); blockSignals(true);
QMessageBox::critical(this, "Firewall Builder", QMessageBox::critical(this, "Firewall Builder",
tr("Illegal netmask '%1'").arg( tr("Illegal netmask '%1'").arg(
m_dialog->netmask->text() ), m_dialog->netmask->text() ),
tr("&Continue"), 0, 0, tr("&Continue"), nullptr, nullptr,
0 ); 0 );
blockSignals(false); blockSignals(false);
} }
@ -161,7 +161,7 @@ void NetworkDialogIPv6::applyChanges()
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
NetworkIPv6 *s = dynamic_cast<NetworkIPv6*>(new_state); NetworkIPv6 *s = dynamic_cast<NetworkIPv6*>(new_state);
assert(s!=NULL); assert(s!=nullptr);
string oldname=obj->getName(); string oldname=obj->getName();
new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) ); new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) );

View File

@ -143,7 +143,7 @@ int ObjConflictResolutionDialog::run(FWObject *o1, FWObject *o2)
FWObject *delObjLib2 = o2->getRoot()->getById( FWObject *delObjLib2 = o2->getRoot()->getById(
FWObjectDatabase::DELETED_OBJECTS_ID ); FWObjectDatabase::DELETED_OBJECTS_ID );
if (delObjLib1!=NULL && o1->isChildOf(delObjLib1)) if (delObjLib1!=nullptr && o1->isChildOf(delObjLib1))
{ {
/* This is the case when an object present in the file we are /* This is the case when an object present in the file we are
* trying to load has been deleted in the tree. We can not * trying to load has been deleted in the tree. We can not
@ -162,7 +162,7 @@ int ObjConflictResolutionDialog::run(FWObject *o1, FWObject *o2)
false, false,
false); false);
if (delObjLib2!=NULL && o2->isChildOf(delObjLib2)) if (delObjLib2!=nullptr && o2->isChildOf(delObjLib2))
{ {
/* This is the case where object o2 has been deleted in the /* This is the case where object o2 has been deleted in the
* file we are trying to load but is present in the tree. One * file we are trying to load but is present in the tree. One

View File

@ -36,7 +36,7 @@ ObjectEditorDockWidget::ObjectEditorDockWidget(const QString &title,
Qt::WindowFlags flags) : Qt::WindowFlags flags) :
QDockWidget(title, parent, flags) QDockWidget(title, parent, flags)
{ {
editor = NULL; editor = nullptr;
connect(this, SIGNAL(topLevelChanged(bool)), connect(this, SIGNAL(topLevelChanged(bool)),
this, SLOT(topLevelChanged(bool))); this, SLOT(topLevelChanged(bool)));
} }
@ -45,7 +45,7 @@ ObjectEditorDockWidget::ObjectEditorDockWidget(QWidget *parent,
Qt::WindowFlags flags) : Qt::WindowFlags flags) :
QDockWidget(parent, flags) QDockWidget(parent, flags)
{ {
editor = NULL; editor = nullptr;
connect(this, SIGNAL(topLevelChanged(bool)), connect(this, SIGNAL(topLevelChanged(bool)),
this, SLOT(topLevelChanged(bool))); this, SLOT(topLevelChanged(bool)));
} }

View File

@ -57,7 +57,7 @@ using namespace libfwbuilder;
ObjectIconView::ObjectIconView(QWidget* parent, const char*, Qt::WindowFlags) : ObjectIconView::ObjectIconView(QWidget* parent, const char*, Qt::WindowFlags) :
QListWidget(parent) QListWidget(parent)
{ {
db = NULL; db = nullptr;
//setWindowFlags(f); //setWindowFlags(f);
@ -82,16 +82,16 @@ bool ObjectIconView::event(QEvent *event)
//viewportToContents(pos.x(),pos.y(),cx,cy); //viewportToContents(pos.x(),pos.y(),cx,cy);
FWObject *obj = NULL; FWObject *obj = nullptr;
QRect cr; QRect cr;
QListWidgetItem *itm = itemAt( QPoint(cx,cy) ); QListWidgetItem *itm = itemAt( QPoint(cx,cy) );
QModelIndex ind = indexAt( QPoint(cx,cy) ); QModelIndex ind = indexAt( QPoint(cx,cy) );
if (itm==NULL) return false; if (itm==nullptr) return false;
int obj_id = itm->data(Qt::UserRole).toInt(); int obj_id = itm->data(Qt::UserRole).toInt();
obj = db->findInIndex(obj_id); obj = db->findInIndex(obj_id);
if (obj==NULL) return false; if (obj==nullptr) return false;
cr = rectForIndex(ind); cr = rectForIndex(ind);
cr = QRect( cr = QRect(
@ -119,7 +119,7 @@ QDrag* ObjectIconView::dragObject()
{ {
QListWidgetItem *ivi = currentItem(); QListWidgetItem *ivi = currentItem();
// currentItem returns NULL if the list is empty // currentItem returns NULL if the list is empty
if (ivi==NULL) return NULL; if (ivi==nullptr) return nullptr;
int obj_id = ivi->data(Qt::UserRole).toInt(); int obj_id = ivi->data(Qt::UserRole).toInt();
FWObject *obj = db->findInIndex(obj_id); FWObject *obj = db->findInIndex(obj_id);
QString icn = QString icn =
@ -170,7 +170,7 @@ void ObjectIconView::dragEnterEvent( QDragEnterEvent *ev)
for (list<FWObject*>::iterator i=dragol.begin();i!=dragol.end(); ++i) for (list<FWObject*>::iterator i=dragol.begin();i!=dragol.end(); ++i)
{ {
FWObject *dragobj = *i; FWObject *dragobj = *i;
assert(dragobj!=NULL); assert(dragobj!=nullptr);
if (FWBTree().isSystem(dragobj)) if (FWBTree().isSystem(dragobj))
{ {

View File

@ -58,7 +58,7 @@ using namespace libfwbuilder;
ObjectListView::ObjectListView(QWidget* parent, const char*, Qt::WindowFlags f) : ObjectListView::ObjectListView(QWidget* parent, const char*, Qt::WindowFlags f) :
QTreeWidget(parent) QTreeWidget(parent)
{ {
db = NULL; db = nullptr;
setWindowFlags(f); setWindowFlags(f);
/*setColumnWidthMode(0, QTreeWidget::Maximum); /*setColumnWidthMode(0, QTreeWidget::Maximum);
setColumnWidthMode(1, QTreeWidget::Maximum); setColumnWidthMode(1, QTreeWidget::Maximum);
@ -86,14 +86,14 @@ bool ObjectListView::event(QEvent *event)
//viewportToContents(pos.x(),pos.y(),cx,cy); //viewportToContents(pos.x(),pos.y(),cx,cy);
FWObject *obj=NULL; FWObject *obj=nullptr;
QRect cr; QRect cr;
QTreeWidgetItem *itm = itemAt(QPoint(cx,cy - header()->height())); QTreeWidgetItem *itm = itemAt(QPoint(cx,cy - header()->height()));
if (itm==NULL) return false; if (itm==nullptr) return false;
int obj_id = itm->data(0, Qt::UserRole).toInt(); int obj_id = itm->data(0, Qt::UserRole).toInt();
obj = db->findInIndex(obj_id); obj = db->findInIndex(obj_id);
if (obj==NULL) return false; if (obj==nullptr) return false;
cr = visualItemRect(itm); cr = visualItemRect(itm);
@ -122,7 +122,7 @@ QDrag* ObjectListView::dragObject()
{ {
QTreeWidgetItem *ovi = currentItem(); QTreeWidgetItem *ovi = currentItem();
// currentItem returns NULL if the list is empty // currentItem returns NULL if the list is empty
if (ovi==NULL) return NULL; if (ovi==nullptr) return nullptr;
int obj_id = ovi->data(0, Qt::UserRole).toInt(); int obj_id = ovi->data(0, Qt::UserRole).toInt();
FWObject *obj = db->findInIndex(obj_id); FWObject *obj = db->findInIndex(obj_id);
@ -183,7 +183,7 @@ void ObjectListView::dragEnterEvent( QDragEnterEvent *ev)
for (list<FWObject*>::iterator i=dragol.begin();i!=dragol.end(); ++i) for (list<FWObject*>::iterator i=dragol.begin();i!=dragol.end(); ++i)
{ {
FWObject *dragobj = *i; FWObject *dragobj = *i;
assert(dragobj!=NULL); assert(dragobj!=nullptr);
if (FWBTree().isSystem(dragobj)) if (FWBTree().isSystem(dragobj))
{ {

View File

@ -38,7 +38,7 @@ using namespace libfwbuilder;
bool ObjectListViewItem::operator< ( const QTreeWidgetItem & other ) const bool ObjectListViewItem::operator< ( const QTreeWidgetItem & other ) const
{ {
QTreeWidget * widget = treeWidget() ; QTreeWidget * widget = treeWidget() ;
if (widget==NULL) return false; if (widget==nullptr) return false;
int col = widget->sortColumn (); int col = widget->sortColumn ();
if (col==1) if (col==1)
@ -53,7 +53,7 @@ bool ObjectListViewItem::operator< ( const QTreeWidgetItem & other ) const
ICMPService * ricmp = ICMPService::cast(right); ICMPService * ricmp = ICMPService::cast(right);
ICMPService * licmp = ICMPService::cast(left); ICMPService * licmp = ICMPService::cast(left);
if (rtcpudp != NULL && ltcpudp != NULL) if (rtcpudp != nullptr && ltcpudp != nullptr)
{ {
int ls = ltcpudp->getDstRangeStart(); int ls = ltcpudp->getDstRangeStart();
int rs = rtcpudp->getDstRangeStart(); int rs = rtcpudp->getDstRangeStart();
@ -73,13 +73,13 @@ bool ObjectListViewItem::operator< ( const QTreeWidgetItem & other ) const
return false ; return false ;
} }
} }
if (rip != NULL && lip != NULL) if (rip != nullptr && lip != nullptr)
{ {
int lpn = lip->getProtocolNumber(); int lpn = lip->getProtocolNumber();
int rpn = rip->getProtocolNumber(); int rpn = rip->getProtocolNumber();
return (lpn < rpn); return (lpn < rpn);
} }
if (ricmp != NULL && licmp != NULL) if (ricmp != nullptr && licmp != nullptr)
{ {
int lpn = licmp->getInt("code"); int lpn = licmp->getInt("code");
int rpn = ricmp->getInt("code"); int rpn = ricmp->getInt("code");

View File

@ -111,7 +111,7 @@ ObjectManipulator::~ObjectManipulator()
} }
ObjectManipulator::ObjectManipulator(QWidget *parent): ObjectManipulator::ObjectManipulator(QWidget *parent):
QWidget(parent), current_tree_view(0) QWidget(parent), current_tree_view(nullptr)
{ {
m_objectManipulator = new Ui::ObjectManipulator_q; m_objectManipulator = new Ui::ObjectManipulator_q;
m_objectManipulator->setupUi(this); m_objectManipulator->setupUi(this);
@ -120,18 +120,18 @@ ObjectManipulator::ObjectManipulator(QWidget *parent):
libs_model = new ListOfLibrariesModel(); libs_model = new ListOfLibrariesModel();
m_objectManipulator->libs->setModel(libs_model); m_objectManipulator->libs->setModel(libs_model);
m_project = NULL; m_project = nullptr;
treeWidth = -1; treeWidth = -1;
treeHeight = -1; treeHeight = -1;
active = false; active = false;
current_tree_view=NULL; current_tree_view=nullptr;
previous_lib_index = -1; previous_lib_index = -1;
// used in duplicateWithDependencies() // used in duplicateWithDependencies()
dedup_marker_global_counter = time(NULL); dedup_marker_global_counter = time(nullptr);
popup_menu = NULL; popup_menu = nullptr;
// buildNewObjectMenu(); // buildNewObjectMenu();
@ -148,7 +148,7 @@ vector<QTreeWidget*> ObjectManipulator::getTreeWidgets()
for (int i=0; i<libs_model->rowCount(); ++i) for (int i=0; i<libs_model->rowCount(); ++i)
{ {
QTreeWidget *objTreeView = libs_model->getTreeWidget(i); QTreeWidget *objTreeView = libs_model->getTreeWidget(i);
if (objTreeView == NULL) continue; if (objTreeView == nullptr) continue;
res.push_back(objTreeView); res.push_back(objTreeView);
} }
return res; return res;
@ -165,7 +165,7 @@ void ObjectManipulator::showDeletedObjects(bool f)
qDebug("ObjectManipulator::showDeletedObjects f=%d dobj=%p", qDebug("ObjectManipulator::showDeletedObjects f=%d dobj=%p",
f, dobj); f, dobj);
if (dobj==NULL) if (dobj==nullptr)
{ {
dobj = m_project->db()->create(Library::TYPENAME); dobj = m_project->db()->create(Library::TYPENAME);
dobj->setId(FWObjectDatabase::DELETED_OBJECTS_ID); dobj->setId(FWObjectDatabase::DELETED_OBJECTS_ID);
@ -193,7 +193,7 @@ void ObjectManipulator::showDeletedObjects(bool f)
if (fwbdebug) if (fwbdebug)
qDebug("ObjectManipulator::showDeletedObjects otv=%p", otv); qDebug("ObjectManipulator::showDeletedObjects otv=%p", otv);
assert(otv!=NULL); assert(otv!=nullptr);
m_objectManipulator->widgetStack->removeWidget( otv ); m_objectManipulator->widgetStack->removeWidget( otv );
removeLib(idx.row()); removeLib(idx.row());
} }
@ -212,7 +212,7 @@ QString ObjectManipulator::getStandardName(FWObject *parent,
{ {
QStringList names; QStringList names;
FWObject *po = parent; FWObject *po = parent;
while (po!=NULL) while (po!=nullptr)
{ {
names.push_front(QString::fromUtf8(po->getName().c_str())); names.push_front(QString::fromUtf8(po->getName().c_str()));
if (Host::cast(po)) break; if (Host::cast(po)) break;
@ -236,7 +236,7 @@ void ObjectManipulator::switchingTrees(QWidget* w)
if (!new_otv) if (!new_otv)
return;//assert(new_otv) return;//assert(new_otv)
if (current_tree_view!=NULL) current_tree_view->becomingHidden(); if (current_tree_view!=nullptr) current_tree_view->becomingHidden();
new_otv->becomingVisible(); new_otv->becomingVisible();
current_tree_view = new_otv; current_tree_view = new_otv;
} }
@ -404,9 +404,9 @@ static void addKeywordsMenu(ObjectManipulator *om, QMenu *menu)
void ObjectManipulator::addSubfolderActions(QList<QAction*> &AddObjectActions, FWObject *currentObj, ObjectTreeViewItem *item, bool &addSubfolder) void ObjectManipulator::addSubfolderActions(QList<QAction*> &AddObjectActions, FWObject *currentObj, ObjectTreeViewItem *item, bool &addSubfolder)
{ {
addSubfolder = item != 0; addSubfolder = item != nullptr;
string path; string path;
if (currentObj == NULL) { if (currentObj == nullptr) {
path = item->getUserFolderParent()->getPath(true); path = item->getUserFolderParent()->getPath(true);
} }
else { else {
@ -414,7 +414,7 @@ void ObjectManipulator::addSubfolderActions(QList<QAction*> &AddObjectActions, F
} }
//Do not allow to create subfolders on real objects //Do not allow to create subfolders on real objects
if(item==0 && (currentObj!=NULL if(item==nullptr && (currentObj!=nullptr
&&!Firewall::isA(currentObj) &&!Firewall::isA(currentObj)
&&!Cluster::isA(currentObj) &&!Cluster::isA(currentObj)
&&!IPv4::isA(currentObj) &&!IPv4::isA(currentObj)
@ -555,7 +555,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
QList<QAction*>::iterator iter; QList<QAction*>::iterator iter;
QList<QAction*> AddObjectActions; QList<QAction*> AddObjectActions;
bool addSubfolder = false; bool addSubfolder = false;
if (popup_menu == NULL) if (popup_menu == nullptr)
{ {
popup_menu = new QMenu(this); popup_menu = new QMenu(this);
popup_menu->setObjectName("objectTreeContextMenu"); popup_menu->setObjectName("objectTreeContextMenu");
@ -565,7 +565,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
/* in extended selection mode there may be several selected items */ /* in extended selection mode there may be several selected items */
ObjectTreeView *objTreeView = getCurrentObjectTree(); ObjectTreeView *objTreeView = getCurrentObjectTree();
if (objTreeView == NULL) return; if (objTreeView == nullptr) return;
QTreeWidgetItem *item = objTreeView->itemAt(pos);//clicked item QTreeWidgetItem *item = objTreeView->itemAt(pos);//clicked item
@ -574,13 +574,13 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
getCurrentObjectTree()->getNumSelected()); getCurrentObjectTree()->getNumSelected());
ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(item); ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(item);
if (otvi==NULL) return; // happens when user clicks outside an item if (otvi==nullptr) return; // happens when user clicks outside an item
lastClickedItem = otvi; lastClickedItem = otvi;
FWObject *obj = otvi->getFWObject(); FWObject *obj = otvi->getFWObject();
if (obj == 0) { if (obj == nullptr) {
assert(otvi->getUserFolderParent() != 0); assert(otvi->getUserFolderParent() != nullptr);
QAction *action = QAction *action =
popup_menu->addAction(tr("Delete"), this, SLOT(removeUserFolder())); popup_menu->addAction(tr("Delete"), this, SLOT(removeUserFolder()));
/* The user-defined folder doesn't get counted as a selected obj */ /* The user-defined folder doesn't get counted as a selected obj */
@ -588,7 +588,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
action->setEnabled(false); action->setEnabled(false);
} }
addSubfolderActions(AddObjectActions, NULL, otvi, addSubfolder); addSubfolderActions(AddObjectActions, nullptr, otvi, addSubfolder);
for (iter=AddObjectActions.begin(); iter!=AddObjectActions.end(); iter++) for (iter=AddObjectActions.begin(); iter!=AddObjectActions.end(); iter++)
(*iter)->setEnabled(true); (*iter)->setEnabled(true);
@ -626,14 +626,14 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
if (RuleSet::cast(currentObj)) if (RuleSet::cast(currentObj))
popup_menu->addAction(tr("Open"), this, SLOT( openSelectedRuleSet())); popup_menu->addAction(tr("Open"), this, SLOT( openSelectedRuleSet()));
QMenu *duptargets = NULL; QMenu *duptargets = nullptr;
QAction *dupID = NULL; QAction *dupID = nullptr;
QMenu *movetargets = NULL; QMenu *movetargets = nullptr;
int moveTargetsCounter = 0; int moveTargetsCounter = 0;
if (!Interface::isA(currentObj) && if (!Interface::isA(currentObj) &&
!physAddress::isA(currentObj) && !physAddress::isA(currentObj) &&
RuleSet::cast(currentObj)==NULL && RuleSet::cast(currentObj)==nullptr &&
!Library::isA(currentObj) && !Library::isA(currentObj) &&
!FWBTree().isStandardFolder(currentObj)) !FWBTree().isStandardFolder(currentObj))
{ {
@ -662,7 +662,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
{ {
QModelIndex idx = libs_model->index(row, 0); QModelIndex idx = libs_model->index(row, 0);
FWObject *lib = libs_model->getLibrary(idx); FWObject *lib = libs_model->getLibrary(idx);
if (lib == NULL) continue; if (lib == nullptr) continue;
if ( lib->getId()==FWObjectDatabase::STANDARD_LIB_ID || if ( lib->getId()==FWObjectDatabase::STANDARD_LIB_ID ||
lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID || lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID ||
lib->isReadOnly()) lib->isReadOnly())
@ -779,16 +779,16 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
* object to an interface. * object to an interface.
*/ */
FWObject *att = currentObj->getFirstByType(AttachedNetworks::TYPENAME); FWObject *att = currentObj->getFirstByType(AttachedNetworks::TYPENAME);
if (att == NULL) if (att == nullptr)
addNewObjectMenuItem(popup_menu, AttachedNetworks::TYPENAME); addNewObjectMenuItem(popup_menu, AttachedNetworks::TYPENAME);
// Check if we should add menu item that creates failover // Check if we should add menu item that creates failover
// group. if parent is a cluster, allow one vrrp type // group. if parent is a cluster, allow one vrrp type
// FailoverClusterGroup per Interface only // FailoverClusterGroup per Interface only
FWObject *parent = NULL; FWObject *parent = nullptr;
parent = currentObj->getParent(); parent = currentObj->getParent();
if (parent != NULL && Cluster::isA(parent)) if (parent != nullptr && Cluster::isA(parent))
{ {
QAction *failover_menu_id = addNewObjectMenuItem( QAction *failover_menu_id = addNewObjectMenuItem(
popup_menu, FailoverClusterGroup::TYPENAME); popup_menu, FailoverClusterGroup::TYPENAME);
@ -797,7 +797,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
// SLOT( newFailoverClusterGroup() ) ); // SLOT( newFailoverClusterGroup() ) );
failover_menu_id->setEnabled( failover_menu_id->setEnabled(
currentObj->getFirstByType( currentObj->getFirstByType(
FailoverClusterGroup::TYPENAME) == NULL); FailoverClusterGroup::TYPENAME) == nullptr);
} }
} }
@ -816,7 +816,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
} }
addSubfolderActions(AddObjectActions, currentObj, NULL, addSubfolder); addSubfolderActions(AddObjectActions, currentObj, nullptr, addSubfolder);
if (addSubfolder) { if (addSubfolder) {
QAction *action = QAction *action =
@ -846,8 +846,8 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
addKeywordsMenu(this, popup_menu); addKeywordsMenu(this, popup_menu);
if (Firewall::cast(currentObj)!=NULL || if (Firewall::cast(currentObj)!=nullptr ||
(ObjectGroup::cast(currentObj)!=NULL && (ObjectGroup::cast(currentObj)!=nullptr &&
currentObj->getName()=="Firewalls")) currentObj->getName()=="Firewalls"))
{ {
bool canCreateCluster = true; bool canCreateCluster = true;
@ -870,11 +870,11 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
popup_menu->addAction( tr("Inspect"), this, SLOT( inspect())); popup_menu->addAction( tr("Inspect"), this, SLOT( inspect()));
} }
if (Interface::cast(currentObj)!=NULL) if (Interface::cast(currentObj)!=nullptr)
{ {
popup_menu->addSeparator(); popup_menu->addSeparator();
FWObject *h = Host::getParentHost(currentObj); FWObject *h = Host::getParentHost(currentObj);
if (h != NULL) { if (h != nullptr) {
list<FWObject*> top_level_interfaces = h->getByType(Interface::TYPENAME); list<FWObject*> top_level_interfaces = h->getByType(Interface::TYPENAME);
top_level_interfaces.sort(FWObjectNameCmpPredicate()); top_level_interfaces.sort(FWObjectNameCmpPredicate());
addSubinterfaceSubmenu(popup_menu, top_level_interfaces); addSubinterfaceSubmenu(popup_menu, top_level_interfaces);
@ -1006,7 +1006,7 @@ bool ObjectManipulator::getDeleteMenuState(FWObject *obj)
Firewall *fw = Firewall::cast(obj->getParent()); Firewall *fw = Firewall::cast(obj->getParent());
// fw can be NULL if this ruleset is in the Deleted objects // fw can be NULL if this ruleset is in the Deleted objects
// library // library
if (fw==NULL) return del_menu_item_state; if (fw==nullptr) return del_menu_item_state;
list<FWObject*> child_objects = fw->getByType(obj->getTypeName()); list<FWObject*> child_objects = fw->getByType(obj->getTypeName());
if (child_objects.size()==1) del_menu_item_state = false; if (child_objects.size()==1) del_menu_item_state = false;
} }
@ -1024,7 +1024,7 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
{ {
inDeletedObjects = false; inDeletedObjects = false;
if (m_project->db() == NULL) if (m_project->db() == nullptr)
{ {
dupMenuItem = false; dupMenuItem = false;
moveMenuItem = false; moveMenuItem = false;
@ -1047,13 +1047,13 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
FWObject *current_library = getCurrentLib(); FWObject *current_library = getCurrentLib();
if (getCurrentObjectTree()==NULL) return; if (getCurrentObjectTree()==nullptr) return;
// delete, cut and copy menu items will be enabled only if all // delete, cut and copy menu items will be enabled only if all
// selected objects have the same parent (so user can not select // selected objects have the same parent (so user can not select
// an interface and one but not all of its addresses for deletion, // an interface and one but not all of its addresses for deletion,
// see #1676) // see #1676)
FWObject *parent = NULL; FWObject *parent = nullptr;
vector<FWObject*> so = getCurrentObjectTree()->getSelectedObjects(); vector<FWObject*> so = getCurrentObjectTree()->getSelectedObjects();
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i) for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
{ {
@ -1061,7 +1061,7 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
QString object_path = obj->getPath(true).c_str(); QString object_path = obj->getPath(true).c_str();
if (parent == NULL) parent = obj->getParent(); if (parent == nullptr) parent = obj->getParent();
else else
{ {
if (parent != obj->getParent()) if (parent != obj->getParent())
@ -1087,7 +1087,7 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
FWObjectClipboard::obj_clipboard && FWObjectClipboard::obj_clipboard &&
(FWObjectClipboard::obj_clipboard->size()!=0); (FWObjectClipboard::obj_clipboard->size()!=0);
delMenuItem = delMenuItem && getDeleteMenuState(obj); delMenuItem = delMenuItem && getDeleteMenuState(obj);
delMenuItem = delMenuItem && current_library != NULL && delMenuItem = delMenuItem && current_library != nullptr &&
current_library->getId() != FWObjectDatabase::STANDARD_LIB_ID; current_library->getId() != FWObjectDatabase::STANDARD_LIB_ID;
#if DISABLE_PASTE_MENU_ITEM_IF_PASTE_IS_ILLEGAL #if DISABLE_PASTE_MENU_ITEM_IF_PASTE_IS_ILLEGAL
@ -1122,7 +1122,7 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
dupMenuItem= dupMenuItem=
(dupMenuItem && ! FWBTree().isStandardFolder(obj) && ! Library::isA(obj) ); (dupMenuItem && ! FWBTree().isStandardFolder(obj) && ! Library::isA(obj) );
inDeletedObjects = (del_obj_library!=NULL && obj->isChildOf(del_obj_library)); inDeletedObjects = (del_obj_library!=nullptr && obj->isChildOf(del_obj_library));
dupMenuItem = dupMenuItem && !inDeletedObjects; dupMenuItem = dupMenuItem && !inDeletedObjects;
// can't move system objects or libraries // can't move system objects or libraries
@ -1184,7 +1184,7 @@ void ObjectManipulator::filterFirewallsFromSelection(vector<FWObject*> &so,
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i) for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
{ {
cl = Cluster::cast(*i); cl = Cluster::cast(*i);
if (cl != NULL) if (cl != nullptr)
{ {
list<Firewall*> members; list<Firewall*> members;
cl->getMembersList(members); cl->getMembersList(members);
@ -1201,13 +1201,13 @@ void ObjectManipulator::filterFirewallsFromSelection(vector<FWObject*> &so,
continue; continue;
} }
fw = Firewall::cast(*i); fw = Firewall::cast(*i);
if (fw!=NULL) if (fw!=nullptr)
{ {
fo.insert(fw); fo.insert(fw);
continue; continue;
} }
gr = ObjectGroup::cast(*i); gr = ObjectGroup::cast(*i);
if (gr!=NULL) if (gr!=nullptr)
{ {
extractFirewallsFromGroup(gr,fo); extractFirewallsFromGroup(gr,fo);
} }
@ -1247,7 +1247,7 @@ FWObject* ObjectManipulator::prepareForInsertion(FWObject *target, FWObject *obj
"&Continue", QString::null, QString::null, "&Continue", QString::null, QString::null,
0, 1 ); 0, 1 );
return NULL; return nullptr;
} }
return ta; return ta;
} }
@ -1257,16 +1257,16 @@ void ObjectManipulator::editSelectedObject()
if (fwbdebug) qDebug("ObjectManipulator::editSelectedObject"); if (fwbdebug) qDebug("ObjectManipulator::editSelectedObject");
ObjectTreeView *objTreeView = getCurrentObjectTree(); ObjectTreeView *objTreeView = getCurrentObjectTree();
if (objTreeView == NULL) return; if (objTreeView == nullptr) return;
if (objTreeView->getNumSelected()==0) return; if (objTreeView->getNumSelected()==0) return;
FWObject *obj = getCurrentObjectTree()->getSelectedObjects().front(); FWObject *obj = getCurrentObjectTree()->getSelectedObjects().front();
if (obj==NULL) return; if (obj==nullptr) return;
// do not edit system folders (#1729) // do not edit system folders (#1729)
if (FWBTree().isSystem(obj)) return; if (FWBTree().isSystem(obj)) return;
if (RuleSet::cast(obj)!=NULL) if (RuleSet::cast(obj)!=nullptr)
{ {
// Open rule set object in the editor if it is already opened // Open rule set object in the editor if it is already opened
// in RuleSetView. If we just opened it in RuleSetView, check // in RuleSetView. If we just opened it in RuleSetView, check
@ -1300,9 +1300,9 @@ void ObjectManipulator::openSelectedRuleSet()
if (getCurrentObjectTree()->getNumSelected()==0) return; if (getCurrentObjectTree()->getNumSelected()==0) return;
FWObject *obj = getCurrentObjectTree()->getSelectedObjects().front(); FWObject *obj = getCurrentObjectTree()->getSelectedObjects().front();
if (obj==NULL) return; if (obj==nullptr) return;
if (RuleSet::cast(obj)!=NULL && m_project->getCurrentRuleSet()!=obj) if (RuleSet::cast(obj)!=nullptr && m_project->getCurrentRuleSet()!=obj)
QCoreApplication::postEvent( QCoreApplication::postEvent(
m_project, new openRulesetEvent(m_project->getFileName(), obj->getId())); m_project, new openRulesetEvent(m_project->getFileName(), obj->getId()));
} }
@ -1326,7 +1326,7 @@ bool ObjectManipulator::switchObjectInEditor(FWObject *obj)
qDebug("in editor: %s", edt_obj->getName().c_str()); qDebug("in editor: %s", edt_obj->getName().c_str());
} }
if (RuleSet::cast(obj)!=NULL) if (RuleSet::cast(obj)!=nullptr)
{ {
if (obj!=m_project->getCurrentRuleSet()) if (obj!=m_project->getCurrentRuleSet())
{ {
@ -1364,14 +1364,14 @@ void ObjectManipulator::selectionChanged(QTreeWidgetItem *cur)
qDebug("ObjectManipulator::selectionChanged"); qDebug("ObjectManipulator::selectionChanged");
QTreeWidget *qlv = getCurrentObjectTree(); QTreeWidget *qlv = getCurrentObjectTree();
if (qlv==NULL) return; if (qlv==nullptr) return;
ObjectTreeViewItem* otvi = dynamic_cast<ObjectTreeViewItem*>(cur); ObjectTreeViewItem* otvi = dynamic_cast<ObjectTreeViewItem*>(cur);
if (otvi==NULL) return; if (otvi==nullptr) return;
FWObject *obj = otvi->getFWObject(); FWObject *obj = otvi->getFWObject();
if (obj==NULL) return; if (obj==nullptr) return;
if (fwbdebug) qDebug("ObjectManipulator::selectionChanged obj=%s", if (fwbdebug) qDebug("ObjectManipulator::selectionChanged obj=%s",
obj->getName().c_str()); obj->getName().c_str());
@ -1426,13 +1426,13 @@ void ObjectManipulator::openObjectInTree(FWObject *obj, bool /*register_in_histo
<< "obj:" << ((obj)?obj->getName().c_str():"NULL") << "obj:" << ((obj)?obj->getName().c_str():"NULL")
<< "id:" << ((obj)?obj->getId():0); << "id:" << ((obj)?obj->getId():0);
if (obj==NULL) return; if (obj==nullptr) return;
openLibForObject(obj); openLibForObject(obj);
//raise(); //raise();
FWObject *o=obj; FWObject *o=obj;
if (FWReference::cast(o)!=NULL) o=FWReference::cast(o)->getPointer(); if (FWReference::cast(o)!=nullptr) o=FWReference::cast(o)->getPointer();
ObjectTreeViewItem *otvi = allItems[o]; ObjectTreeViewItem *otvi = allItems[o];
// this changes selection and thus calls slot slectionChanged // this changes selection and thus calls slot slectionChanged
@ -1477,7 +1477,7 @@ void ObjectManipulator::showObjectInTree(ObjectTreeViewItem *otvi)
{ {
if (fwbdebug) if (fwbdebug)
qDebug("ObjectManipulator::showObjectInTree"); qDebug("ObjectManipulator::showObjectInTree");
if (otvi==NULL) return; if (otvi==nullptr) return;
ObjectTreeView* otv = otvi->getTree(); ObjectTreeView* otv = otvi->getTree();
@ -1502,7 +1502,7 @@ void ObjectManipulator::libChangedById(int obj_id)
{ {
QModelIndex idx = libs_model->index(i, 0); QModelIndex idx = libs_model->index(i, 0);
FWObject *l = libs_model->getLibrary(idx); FWObject *l = libs_model->getLibrary(idx);
if (l == NULL) continue; if (l == nullptr) continue;
if (l->getId() == obj_id) if (l->getId() == obj_id)
{ {
libChanged(i); libChanged(i);
@ -1517,21 +1517,21 @@ FWObject* ObjectManipulator::getNextUserLib(FWObject *after_this)
QString sid2 = "syslib000"; QString sid2 = "syslib000";
QString sid3 = "syslib001"; QString sid3 = "syslib001";
FWObject *lib = NULL; FWObject *lib = nullptr;
if (after_this != NULL) lib = after_this->getLibrary(); if (after_this != nullptr) lib = after_this->getLibrary();
for (int i=0; i<libs_model->rowCount(); ++i) for (int i=0; i<libs_model->rowCount(); ++i)
{ {
QModelIndex idx = libs_model->index(i, 0); QModelIndex idx = libs_model->index(i, 0);
FWObject *l = libs_model->getLibrary(idx); FWObject *l = libs_model->getLibrary(idx);
if (l == NULL) continue; if (l == nullptr) continue;
if (l == lib) continue; if (l == lib) continue;
QString sid1 = FWObjectDatabase::getStringId(l->getId()).c_str(); QString sid1 = FWObjectDatabase::getStringId(l->getId()).c_str();
if ( sid1 == sid2 || sid1 == sid3) continue; if ( sid1 == sid2 || sid1 == sid3) continue;
return l; return l;
} }
return NULL; return nullptr;
} }
void ObjectManipulator::libChanged(int list_row) void ObjectManipulator::libChanged(int list_row)
@ -1541,7 +1541,7 @@ void ObjectManipulator::libChanged(int list_row)
previous_lib_index = list_row; previous_lib_index = list_row;
QTreeWidget *objTreeView = libs_model->getTreeWidget(list_row); QTreeWidget *objTreeView = libs_model->getTreeWidget(list_row);
if (objTreeView == NULL) if (objTreeView == nullptr)
{ {
if (fwbdebug) if (fwbdebug)
{ {
@ -1562,7 +1562,7 @@ void ObjectManipulator::libChanged(int list_row)
} }
ObjectTreeViewItem *otvi = dynamic_cast<ObjectTreeViewItem*>(objTreeView->currentItem()); ObjectTreeViewItem *otvi = dynamic_cast<ObjectTreeViewItem*>(objTreeView->currentItem());
if (otvi == NULL) if (otvi == nullptr)
{ {
if (objTreeView->invisibleRootItem()->childCount() > 0) if (objTreeView->invisibleRootItem()->childCount() > 0)
otvi = dynamic_cast<ObjectTreeViewItem*>( otvi = dynamic_cast<ObjectTreeViewItem*>(
@ -1579,7 +1579,7 @@ void ObjectManipulator::libChanged(int list_row)
void ObjectManipulator::updateCreateObjectMenu(FWObject* lib) void ObjectManipulator::updateCreateObjectMenu(FWObject* lib)
{ {
bool f = ( bool f = (
lib == NULL || lib == nullptr ||
lib->getId()==FWObjectDatabase::TEMPLATE_LIB_ID || lib->getId()==FWObjectDatabase::TEMPLATE_LIB_ID ||
lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID || lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID ||
lib->isReadOnly() lib->isReadOnly()
@ -1594,7 +1594,7 @@ void ObjectManipulator::updateCreateObjectMenu(FWObject* lib)
FWObject* ObjectManipulator::getCurrentLib() FWObject* ObjectManipulator::getCurrentLib()
{ {
int idx = m_objectManipulator->libs->currentIndex(); int idx = m_objectManipulator->libs->currentIndex();
if (idx == -1 ) return NULL; if (idx == -1 ) return nullptr;
FWObject *lib = libs_model->getLibrary(idx); FWObject *lib = libs_model->getLibrary(idx);
@ -1628,7 +1628,7 @@ void ObjectManipulator::select()
<< "currentObj=" << currentObj << "currentObj=" << currentObj
<< ((currentObj)?currentObj->getName().c_str():" [unknown] "); << ((currentObj)?currentObj->getName().c_str():" [unknown] ");
if (currentObj==NULL) return; if (currentObj==nullptr) return;
m_objectManipulator->libs->setCurrentIndex( m_objectManipulator->libs->setCurrentIndex(
libs_model->getIdxForLib(currentObj->getLibrary()).row()); libs_model->getIdxForLib(currentObj->getLibrary()).row());
@ -1646,12 +1646,12 @@ void ObjectManipulator::select()
void ObjectManipulator::unselect() void ObjectManipulator::unselect()
{ {
FWObject *currentObj = getSelectedObject(); FWObject *currentObj = getSelectedObject();
if (currentObj==NULL) return; if (currentObj==nullptr) return;
for (int i=0; i<libs_model->rowCount(); ++i) for (int i=0; i<libs_model->rowCount(); ++i)
{ {
QTreeWidget *otv = libs_model->getTreeWidget(i); QTreeWidget *otv = libs_model->getTreeWidget(i);
if (otv == NULL) continue; if (otv == nullptr) continue;
otv->clearSelection(); otv->clearSelection();
} }
@ -1705,7 +1705,7 @@ void ObjectManipulator::simulateInstall()
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i) for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
{ {
fw= Firewall::cast( *i ); fw= Firewall::cast( *i );
if (fw!=NULL) if (fw!=nullptr)
{ {
fw->updateLastCompiledTimestamp(); fw->updateLastCompiledTimestamp();
fw->updateLastInstalledTimestamp(); fw->updateLastInstalledTimestamp();
@ -1721,7 +1721,7 @@ FWObject* ObjectManipulator::getSelectedObject()
ObjectTreeViewItem* otvi = dynamic_cast<ObjectTreeViewItem*>(cur); ObjectTreeViewItem* otvi = dynamic_cast<ObjectTreeViewItem*>(cur);
return otvi->getFWObject(); return otvi->getFWObject();
} }
return NULL; return nullptr;
} }
void ObjectManipulator::reopenCurrentItemParent() void ObjectManipulator::reopenCurrentItemParent()
@ -1741,7 +1741,7 @@ void ObjectManipulator::loadSectionSizes()
{ {
QTreeWidget *objTreeView = libs_model->getTreeWidget(i); QTreeWidget *objTreeView = libs_model->getTreeWidget(i);
FWObject *lib = libs_model->getLibrary(i); FWObject *lib = libs_model->getLibrary(i);
if (lib == NULL || objTreeView == NULL) continue; if (lib == nullptr || objTreeView == nullptr) continue;
objTreeView->header()->resizeSection( objTreeView->header()->resizeSection(
0, 0,
@ -1760,7 +1760,7 @@ void ObjectManipulator::saveSectionSizes()
{ {
QTreeWidget *objTreeView = libs_model->getTreeWidget(i); QTreeWidget *objTreeView = libs_model->getTreeWidget(i);
FWObject *lib = libs_model->getLibrary(i); FWObject *lib = libs_model->getLibrary(i);
if (lib == NULL || objTreeView == NULL) continue; if (lib == nullptr || objTreeView == nullptr) continue;
st->setTreeSectionSize( st->setTreeSectionSize(
m_project->getFileName(), lib->getName().c_str(), 0, m_project->getFileName(), lib->getName().c_str(), 0,
@ -1781,7 +1781,7 @@ void ObjectManipulator::loadExpandedTreeItems()
ObjectTreeView *objTreeView = libs_model->getTreeWidget(i); ObjectTreeView *objTreeView = libs_model->getTreeWidget(i);
FWObject *lib = libs_model->getLibrary(i); FWObject *lib = libs_model->getLibrary(i);
if (lib == NULL || objTreeView == NULL) continue; if (lib == nullptr || objTreeView == nullptr) continue;
set<int> expanded_objects; set<int> expanded_objects;
st->getExpandedObjectIds(m_project->getFileName(), st->getExpandedObjectIds(m_project->getFileName(),
@ -1800,7 +1800,7 @@ void ObjectManipulator::saveExpandedTreeItems()
{ {
ObjectTreeView *objTreeView = libs_model->getTreeWidget(i); ObjectTreeView *objTreeView = libs_model->getTreeWidget(i);
FWObject *lib = libs_model->getLibrary(i); FWObject *lib = libs_model->getLibrary(i);
if (lib == NULL || objTreeView == NULL) continue; if (lib == nullptr || objTreeView == nullptr) continue;
st->setExpandedObjectIds(m_project->getFileName(), st->setExpandedObjectIds(m_project->getFileName(),
lib->getName().c_str(), lib->getName().c_str(),
@ -1813,7 +1813,7 @@ void ObjectManipulator::setAttributesColumnEnabled(bool)
for (int i=0; i<libs_model->rowCount(); ++i) for (int i=0; i<libs_model->rowCount(); ++i)
{ {
ObjectTreeView *objTreeView = libs_model->getTreeWidget(i); ObjectTreeView *objTreeView = libs_model->getTreeWidget(i);
if (objTreeView == NULL) continue; if (objTreeView == nullptr) continue;
objTreeView->showOrHideAttributesColumn(); objTreeView->showOrHideAttributesColumn();
} }
} }

View File

@ -140,7 +140,7 @@ QAction* ObjectManipulator::addNewObjectMenuItem(QMenu *menu,
void ObjectManipulator::createNewObject() void ObjectManipulator::createNewObject()
{ {
const QAction *action = dynamic_cast<const QAction*>(sender()); const QAction *action = dynamic_cast<const QAction*>(sender());
assert(action!=NULL); assert(action!=nullptr);
QVariant v = action->data(); QVariant v = action->data();
if (!v.isValid()) return; if (!v.isValid()) return;
@ -156,13 +156,13 @@ void ObjectManipulator::createNewObject()
qDebug() << "ObjectManipulator::createNewObject()" qDebug() << "ObjectManipulator::createNewObject()"
<< "type:" << type_name << "type:" << type_name
<< "add_to_group_id:" << add_to_group_id; << "add_to_group_id:" << add_to_group_id;
FWObject *new_obj = NULL; FWObject *new_obj = nullptr;
if (!isObjectAllowed(type_name)) return; if (!isObjectAllowed(type_name)) return;
QString descr = FWBTree().getTranslatableObjectTypeName(type_name); QString descr = FWBTree().getTranslatableObjectTypeName(type_name);
// FWCmdMacro should be used for commands grouping // FWCmdMacro should be used for commands grouping
FWCmdMacro* macro = 0; FWCmdMacro* macro = nullptr;
if (add_to_group_id == -1) if (add_to_group_id == -1)
macro = new FWCmdMacro( macro = new FWCmdMacro(
FWBTree().getTranslatableNewObjectMenuText(type_name)); FWBTree().getTranslatableNewObjectMenuText(type_name));
@ -179,7 +179,7 @@ void ObjectManipulator::createNewObject()
if (type_name == Firewall::TYPENAME) new_obj = newFirewall(macro); if (type_name == Firewall::TYPENAME) new_obj = newFirewall(macro);
if (type_name == Cluster::TYPENAME) new_obj = newCluster(macro); if (type_name == Cluster::TYPENAME) new_obj = newCluster(macro);
if (type_name == Host::TYPENAME) new_obj = newHost(macro); if (type_name == Host::TYPENAME) new_obj = newHost(macro);
if (new_obj == NULL) if (new_obj == nullptr)
{ {
delete macro; delete macro;
return; return;
@ -198,9 +198,9 @@ void ObjectManipulator::createNewObject()
//if (type_name == Routing::TYPENAME) new_obj = newRoutingRuleSet(); //if (type_name == Routing::TYPENAME) new_obj = newRoutingRuleSet();
if (type_name == AttachedNetworks::TYPENAME) new_obj = newAttachedNetworks(macro); if (type_name == AttachedNetworks::TYPENAME) new_obj = newAttachedNetworks(macro);
if (new_obj == NULL) new_obj = createObject(type_name, descr, NULL, macro); if (new_obj == nullptr) new_obj = createObject(type_name, descr, nullptr, macro);
if (new_obj == NULL) if (new_obj == nullptr)
{ {
delete macro; delete macro;
return; return;
@ -236,7 +236,7 @@ void ObjectManipulator::createNewObject()
m_project, new expandObjectInTreeEvent( m_project, new expandObjectInTreeEvent(
m_project->getFileName(), new_obj->getId())); m_project->getFileName(), new_obj->getId()));
if (Firewall::cast(new_obj)!=NULL) // Cluster too if (Firewall::cast(new_obj)!=nullptr) // Cluster too
{ {
FWObject *ruleset = new_obj->getFirstByType(Policy::TYPENAME); FWObject *ruleset = new_obj->getFirstByType(Policy::TYPENAME);
if (ruleset) if (ruleset)
@ -249,7 +249,7 @@ void ObjectManipulator::createNewObject()
list<FWObject*> newObjs; list<FWObject*> newObjs;
newObjs.push_back(new_obj); newObjs.push_back(new_obj);
moveItems(lastClickedItem, newObjs); moveItems(lastClickedItem, newObjs);
lastClickedItem = NULL; lastClickedItem = nullptr;
m_project->undoStack->push(macro); m_project->undoStack->push(macro);
} }
@ -258,13 +258,13 @@ void ObjectManipulator::newFirewallSlot()
{ {
QString descr = FWBTree().getTranslatableObjectTypeName(Firewall::TYPENAME); QString descr = FWBTree().getTranslatableObjectTypeName(Firewall::TYPENAME);
// FWCmdMacro should be used for commands grouping // FWCmdMacro should be used for commands grouping
FWCmdMacro* macro = 0; FWCmdMacro* macro = nullptr;
macro = new FWCmdMacro( macro = new FWCmdMacro(
FWBTree().getTranslatableNewObjectMenuText(Firewall::TYPENAME)); FWBTree().getTranslatableNewObjectMenuText(Firewall::TYPENAME));
FWObject *new_obj = newFirewall(macro); FWObject *new_obj = newFirewall(macro);
if (new_obj == NULL) if (new_obj == nullptr)
{ {
delete macro; delete macro;
return; return;
@ -332,7 +332,7 @@ FWObject* ObjectManipulator::createObject(const QString &objType,
FWObject *parent = FWBTree().getStandardSlotForObject(lib, objType); FWObject *parent = FWBTree().getStandardSlotForObject(lib, objType);
if (parent==NULL) if (parent==nullptr)
{ {
QMessageBox::warning(this,"Firewall Builder", QMessageBox::warning(this,"Firewall Builder",
QObject::tr( QObject::tr(
@ -342,7 +342,7 @@ FWObject* ObjectManipulator::createObject(const QString &objType,
.arg(objType), .arg(objType),
"&Continue", QString::null, QString::null, "&Continue", QString::null, QString::null,
0, 1 ); 0, 1 );
return NULL; return nullptr;
} }
return actuallyCreateObject(parent, objType, objName, copyFrom, macro); return actuallyCreateObject(parent, objType, objName, copyFrom, macro);
@ -357,7 +357,7 @@ FWObject* ObjectManipulator::createObject(FWObject *parent,
FWObject *lib = getCurrentLib(); FWObject *lib = getCurrentLib();
int i = 0; int i = 0;
assert(parent!=NULL); assert(parent!=nullptr);
if (fwbdebug) if (fwbdebug)
{ {
@ -385,7 +385,7 @@ FWObject* ObjectManipulator::createObject(FWObject *parent,
i++; i++;
} }
if (parent==NULL) parent=lib; if (parent==nullptr) parent=lib;
return actuallyCreateObject(parent, objType, objName, copyFrom, macro); return actuallyCreateObject(parent, objType, objName, copyFrom, macro);
} }
@ -396,11 +396,11 @@ FWObject* ObjectManipulator::actuallyCreateObject(FWObject *parent,
FWObject *copyFrom, FWObject *copyFrom,
QUndoCommand* macro) QUndoCommand* macro)
{ {
FWObject *nobj=NULL; FWObject *nobj=nullptr;
if (!isTreeReadWrite(this, parent)) return NULL; if (!isTreeReadWrite(this, parent)) return nullptr;
nobj = m_project->db()->create(objType.toLatin1().constData()); nobj = m_project->db()->create(objType.toLatin1().constData());
assert(nobj!=NULL); assert(nobj!=nullptr);
if (copyFrom!=NULL) nobj->duplicate(copyFrom, true); if (copyFrom!=nullptr) nobj->duplicate(copyFrom, true);
if (nobj->isReadOnly()) nobj->setReadOnly(false); if (nobj->isReadOnly()) nobj->setReadOnly(false);
QString new_name = makeNameUnique(parent, objName, objType); QString new_name = makeNameUnique(parent, objName, objType);
@ -448,7 +448,7 @@ FWObject* ObjectManipulator::newLibrary(QUndoCommand* macro)
// At this point new library is already inserted into the object tree // At this point new library is already inserted into the object tree
// but it has not been added to the QTreeWidget yet. // but it has not been added to the QTreeWidget yet.
FWCmdAddLibrary *cmd = new FWCmdAddLibrary( FWCmdAddLibrary *cmd = new FWCmdAddLibrary(
m_project, m_project->db(), NULL, QObject::tr("Create library"), macro); m_project, m_project->db(), nullptr, QObject::tr("Create library"), macro);
FWObject *new_state = cmd->getNewState(); FWObject *new_state = cmd->getNewState();
m_project->db()->remove(nlib, false); m_project->db()->remove(nlib, false);
new_state->add(nlib); new_state->add(nlib);
@ -463,10 +463,10 @@ FWObject* ObjectManipulator::newLibrary(QUndoCommand* macro)
FWObject* ObjectManipulator::newPolicyRuleSet(QUndoCommand* macro) FWObject* ObjectManipulator::newPolicyRuleSet(QUndoCommand* macro)
{ {
FWObject *currentObj = getSelectedObject(); FWObject *currentObj = getSelectedObject();
if ( currentObj->isReadOnly() ) return NULL; if ( currentObj->isReadOnly() ) return nullptr;
QString name = "Policy"; QString name = "Policy";
Firewall * fw = Firewall::cast(currentObj); Firewall * fw = Firewall::cast(currentObj);
if (fw!=NULL) if (fw!=nullptr)
{ {
int count = 0; int count = 0;
for (FWObjectTypedChildIterator it = fw->findByType(Policy::TYPENAME);it != it.end(); ++it) for (FWObjectTypedChildIterator it = fw->findByType(Policy::TYPENAME);it != it.end(); ++it)
@ -477,7 +477,7 @@ FWObject* ObjectManipulator::newPolicyRuleSet(QUndoCommand* macro)
name+=QString().setNum(count); name+=QString().setNum(count);
} }
} }
FWObject *o = createObject(currentObj, Policy::TYPENAME, name, NULL, macro); FWObject *o = createObject(currentObj, Policy::TYPENAME, name, nullptr, macro);
this->getCurrentObjectTree()->sortItems(0, Qt::AscendingOrder); this->getCurrentObjectTree()->sortItems(0, Qt::AscendingOrder);
return o; return o;
} }
@ -485,10 +485,10 @@ FWObject* ObjectManipulator::newPolicyRuleSet(QUndoCommand* macro)
FWObject* ObjectManipulator::newNATRuleSet(QUndoCommand* macro) FWObject* ObjectManipulator::newNATRuleSet(QUndoCommand* macro)
{ {
FWObject *currentObj = getSelectedObject(); FWObject *currentObj = getSelectedObject();
if ( currentObj->isReadOnly() ) return NULL; if ( currentObj->isReadOnly() ) return nullptr;
QString name = "NAT"; QString name = "NAT";
Firewall * fw = Firewall::cast(currentObj); Firewall * fw = Firewall::cast(currentObj);
if (fw!=NULL) if (fw!=nullptr)
{ {
int count = 0; int count = 0;
for (FWObjectTypedChildIterator it = fw->findByType(NAT::TYPENAME); for (FWObjectTypedChildIterator it = fw->findByType(NAT::TYPENAME);
@ -500,7 +500,7 @@ FWObject* ObjectManipulator::newNATRuleSet(QUndoCommand* macro)
name += QString().setNum(count); name += QString().setNum(count);
} }
} }
FWObject *o = createObject(currentObj, NAT::TYPENAME, name, NULL, macro); FWObject *o = createObject(currentObj, NAT::TYPENAME, name, nullptr, macro);
this->getCurrentObjectTree()->sortItems(0, Qt::AscendingOrder); this->getCurrentObjectTree()->sortItems(0, Qt::AscendingOrder);
return o; return o;
} }
@ -521,10 +521,10 @@ FWObject* ObjectManipulator::newFirewall(QUndoCommand* macro)
FWObject *nfw = nfd->getNewFirewall(); FWObject *nfw = nfd->getNewFirewall();
delete nfd; delete nfd;
if (nfw!=NULL) if (nfw!=nullptr)
{ {
FWCmdAddObject *cmd = new FWCmdAddObject( FWCmdAddObject *cmd = new FWCmdAddObject(
m_project, parent, NULL, QObject::tr("Create new Firewall"), macro); m_project, parent, nullptr, QObject::tr("Create new Firewall"), macro);
FWObject *new_state = cmd->getNewState(); FWObject *new_state = cmd->getNewState();
parent->remove(nfw, false); parent->remove(nfw, false);
@ -559,7 +559,7 @@ FWObject* ObjectManipulator::newCluster(QUndoCommand* macro, bool fromSelected)
fwvector.push_back(FWObject::cast(fw)); fwvector.push_back(FWObject::cast(fw));
ncd->setFirewallList(fwvector); ncd->setFirewallList(fwvector);
} }
if ( ncd->exec() != QDialog::Accepted) return NULL; if ( ncd->exec() != QDialog::Accepted) return nullptr;
FWObject *ncl = ncd->getNewCluster(); FWObject *ncl = ncd->getNewCluster();
delete ncd; delete ncd;
@ -570,7 +570,7 @@ FWObject* ObjectManipulator::newCluster(QUndoCommand* macro, bool fromSelected)
qDebug() << "ObjectManipulator::newCluster checkpoint 1"; qDebug() << "ObjectManipulator::newCluster checkpoint 1";
FWCmdAddObject *cmd = new FWCmdAddObject( FWCmdAddObject *cmd = new FWCmdAddObject(
m_project, parent, NULL, QObject::tr("Create new Cluster"), macro); m_project, parent, nullptr, QObject::tr("Create new Cluster"), macro);
// newCluster dialog may create backup copies of member firewalls, // newCluster dialog may create backup copies of member firewalls,
// to see them in the tree need to reload it. // to see them in the tree need to reload it.
cmd->setNeedTreeReload(true); cmd->setNeedTreeReload(true);
@ -591,7 +591,7 @@ void ObjectManipulator::newClusterFromSelected()
FWCmdMacro* macro = new FWCmdMacro( FWCmdMacro* macro = new FWCmdMacro(
FWBTree().getTranslatableNewObjectMenuText(Cluster::TYPENAME)); FWBTree().getTranslatableNewObjectMenuText(Cluster::TYPENAME));
FWObject *ncl = newCluster(macro, true); FWObject *ncl = newCluster(macro, true);
if (ncl == NULL) if (ncl == nullptr)
{ {
delete macro; delete macro;
return; return;
@ -602,11 +602,11 @@ void ObjectManipulator::newClusterFromSelected()
FWObject* ObjectManipulator::newClusterIface(QUndoCommand* macro) FWObject* ObjectManipulator::newClusterIface(QUndoCommand* macro)
{ {
FWObject *currentObj = getSelectedObject(); FWObject *currentObj = getSelectedObject();
if ( currentObj->isReadOnly() ) return NULL; if ( currentObj->isReadOnly() ) return nullptr;
QString new_name = makeNameUnique(currentObj, QString new_name = makeNameUnique(currentObj,
findNewestInterfaceName(currentObj), findNewestInterfaceName(currentObj),
Interface::TYPENAME); Interface::TYPENAME);
return createObject(currentObj, Interface::TYPENAME, new_name, NULL, macro); return createObject(currentObj, Interface::TYPENAME, new_name, nullptr, macro);
} }
/* /*
@ -617,13 +617,13 @@ FWObject* ObjectManipulator::newClusterIface(QUndoCommand* macro)
FWObject* ObjectManipulator::newStateSyncClusterGroup(QUndoCommand* macro) FWObject* ObjectManipulator::newStateSyncClusterGroup(QUndoCommand* macro)
{ {
FWObject *currentObj = getSelectedObject(); FWObject *currentObj = getSelectedObject();
if ( currentObj->isReadOnly() ) return NULL; if ( currentObj->isReadOnly() ) return nullptr;
FWObject *o = NULL; FWObject *o = nullptr;
FWObject *cluster = currentObj; FWObject *cluster = currentObj;
while (cluster && !Cluster::isA(cluster)) cluster = cluster->getParent(); while (cluster && !Cluster::isA(cluster)) cluster = cluster->getParent();
assert(cluster != NULL); assert(cluster != nullptr);
QString host_os = cluster->getStr("host_OS").c_str(); QString host_os = cluster->getStr("host_OS").c_str();
list<QStringPair> lst; list<QStringPair> lst;
@ -635,13 +635,13 @@ FWObject* ObjectManipulator::newStateSyncClusterGroup(QUndoCommand* macro)
this,"Firewall Builder", this,"Firewall Builder",
tr("Cluster host OS %1 does not support state synchronization").arg(host_os), tr("Cluster host OS %1 does not support state synchronization").arg(host_os),
"&Continue", QString::null, QString::null, 0, 1 ); "&Continue", QString::null, QString::null, 0, 1 );
return NULL; return nullptr;
} }
QString group_type = lst.front().first; QString group_type = lst.front().first;
o = createObject(currentObj, StateSyncClusterGroup::TYPENAME, o = createObject(currentObj, StateSyncClusterGroup::TYPENAME,
tr("State Sync Group"), NULL, macro); tr("State Sync Group"), nullptr, macro);
o->setStr("type", group_type.toStdString()); o->setStr("type", group_type.toStdString());
return o; return o;
} }
@ -654,9 +654,9 @@ FWObject* ObjectManipulator::newStateSyncClusterGroup(QUndoCommand* macro)
FWObject* ObjectManipulator::newFailoverClusterGroup(QUndoCommand* macro) FWObject* ObjectManipulator::newFailoverClusterGroup(QUndoCommand* macro)
{ {
FWObject *currentObj = getSelectedObject(); FWObject *currentObj = getSelectedObject();
if ( currentObj->isReadOnly() ) return NULL; if ( currentObj->isReadOnly() ) return nullptr;
FWObject *o = NULL; FWObject *o = nullptr;
QString group_type; QString group_type;
if (Interface::isA(currentObj)) if (Interface::isA(currentObj))
@ -665,11 +665,11 @@ FWObject* ObjectManipulator::newFailoverClusterGroup(QUndoCommand* macro)
} else } else
{ {
qWarning("newClusterGroup: invalid currentObj"); qWarning("newClusterGroup: invalid currentObj");
return NULL; return nullptr;
} }
o = createObject(currentObj, FailoverClusterGroup::TYPENAME, o = createObject(currentObj, FailoverClusterGroup::TYPENAME,
tr("Failover group"), NULL, macro); tr("Failover group"), nullptr, macro);
o->setStr("type", group_type.toStdString()); o->setStr("type", group_type.toStdString());
return o; return o;
} }
@ -681,12 +681,12 @@ FWObject* ObjectManipulator::newFailoverClusterGroup(QUndoCommand* macro)
FWObject* ObjectManipulator::newAttachedNetworks(QUndoCommand* macro) FWObject* ObjectManipulator::newAttachedNetworks(QUndoCommand* macro)
{ {
FWObject *currentObj = getSelectedObject(); FWObject *currentObj = getSelectedObject();
if ( currentObj->isReadOnly() ) return NULL; if ( currentObj->isReadOnly() ) return nullptr;
if (Interface::isA(currentObj)) if (Interface::isA(currentObj))
{ {
FWObject *no = createObject(currentObj, AttachedNetworks::TYPENAME, FWObject *no = createObject(currentObj, AttachedNetworks::TYPENAME,
tr("Attached Networks"), NULL, macro); tr("Attached Networks"), nullptr, macro);
FWObject *parent_host = Host::getParentHost(currentObj); FWObject *parent_host = Host::getParentHost(currentObj);
string name = parent_host->getName() + string name = parent_host->getName() +
":" + currentObj->getName() + ":attached"; ":" + currentObj->getName() + ":attached";
@ -695,7 +695,7 @@ FWObject* ObjectManipulator::newAttachedNetworks(QUndoCommand* macro)
} else } else
{ {
qWarning("newAttachedNetworks: invalid currentObj"); qWarning("newAttachedNetworks: invalid currentObj");
return NULL; return nullptr;
} }
} }
@ -710,10 +710,10 @@ FWObject* ObjectManipulator::newHost(QUndoCommand* macro)
FWObject *o = nhd->getNewHost(); FWObject *o = nhd->getNewHost();
delete nhd; delete nhd;
if (o!=NULL) if (o!=nullptr)
{ {
FWCmdAddObject *cmd = new FWCmdAddObject( FWCmdAddObject *cmd = new FWCmdAddObject(
m_project, parent, NULL, QObject::tr("Create new Host"), macro); m_project, parent, nullptr, QObject::tr("Create new Host"), macro);
FWObject *new_state = cmd->getNewState(); FWObject *new_state = cmd->getNewState();
parent->remove(o, false); parent->remove(o, false);
new_state->add(o); new_state->add(o);
@ -743,10 +743,10 @@ QString ObjectManipulator::findNewestInterfaceName(FWObject *parent)
FWObject* ObjectManipulator::newInterface(QUndoCommand* macro) FWObject* ObjectManipulator::newInterface(QUndoCommand* macro)
{ {
FWObject *currentObj = getSelectedObject(); FWObject *currentObj = getSelectedObject();
if ( currentObj->isReadOnly() ) return NULL; if ( currentObj->isReadOnly() ) return nullptr;
Interface *new_interface = NULL; Interface *new_interface = nullptr;
FWObject *parent = NULL; FWObject *parent = nullptr;
// Note that Firewall::cast matches Firewall and Cluster // Note that Firewall::cast matches Firewall and Cluster
if (Host::isA(currentObj) || Firewall::cast(currentObj)) if (Host::isA(currentObj) || Firewall::cast(currentObj))
@ -769,19 +769,19 @@ FWObject* ObjectManipulator::newInterface(QUndoCommand* macro)
} }
} }
if (parent == NULL) if (parent == nullptr)
{ {
// since we can;t find quitable parent for the new interface, // since we can;t find quitable parent for the new interface,
// we can't create it. // we can't create it.
return NULL; return nullptr;
} }
QString new_name = makeNameUnique(parent, findNewestInterfaceName(parent), QString new_name = makeNameUnique(parent, findNewestInterfaceName(parent),
Interface::TYPENAME); Interface::TYPENAME);
new_interface = Interface::cast( new_interface = Interface::cast(
createObject(parent, Interface::TYPENAME, new_name, NULL, macro)); createObject(parent, Interface::TYPENAME, new_name, nullptr, macro));
if (new_interface == NULL) return NULL; if (new_interface == nullptr) return nullptr;
if (Interface::isA(parent)) if (Interface::isA(parent))
{ {
@ -801,49 +801,49 @@ FWObject* ObjectManipulator::newInterface(QUndoCommand* macro)
FWObject* ObjectManipulator::newInterfaceAddress(QUndoCommand* macro) FWObject* ObjectManipulator::newInterfaceAddress(QUndoCommand* macro)
{ {
FWObject *currentObj = getSelectedObject(); FWObject *currentObj = getSelectedObject();
if ( currentObj->isReadOnly() ) return NULL; if ( currentObj->isReadOnly() ) return nullptr;
if (Interface::isA(currentObj)) if (Interface::isA(currentObj))
{ {
Interface *intf = Interface::cast(currentObj); Interface *intf = Interface::cast(currentObj);
if (intf && if (intf &&
(intf->isDyn() || intf->isUnnumbered() || intf->isBridgePort()) (intf->isDyn() || intf->isUnnumbered() || intf->isBridgePort())
) return NULL; ) return nullptr;
QString iname = getStandardName(currentObj, IPv4::TYPENAME, "ip"); QString iname = getStandardName(currentObj, IPv4::TYPENAME, "ip");
iname = makeNameUnique(currentObj, iname, IPv4::TYPENAME); iname = makeNameUnique(currentObj, iname, IPv4::TYPENAME);
return createObject(currentObj, IPv4::TYPENAME, iname, NULL, macro); return createObject(currentObj, IPv4::TYPENAME, iname, nullptr, macro);
} }
// if current object is not interface, create address in the standard folder // if current object is not interface, create address in the standard folder
return createObject(IPv4::TYPENAME, return createObject(IPv4::TYPENAME,
FWBTree().getTranslatableObjectTypeName(IPv4::TYPENAME), FWBTree().getTranslatableObjectTypeName(IPv4::TYPENAME),
NULL, macro); nullptr, macro);
} }
FWObject* ObjectManipulator::newInterfaceAddressIPv6(QUndoCommand* macro) FWObject* ObjectManipulator::newInterfaceAddressIPv6(QUndoCommand* macro)
{ {
FWObject *currentObj = getSelectedObject(); FWObject *currentObj = getSelectedObject();
if ( currentObj->isReadOnly() ) return NULL; if ( currentObj->isReadOnly() ) return nullptr;
if (Interface::isA(currentObj)) if (Interface::isA(currentObj))
{ {
Interface *intf = Interface::cast(currentObj); Interface *intf = Interface::cast(currentObj);
if (intf && if (intf &&
(intf->isDyn() || intf->isUnnumbered() || intf->isBridgePort()) (intf->isDyn() || intf->isUnnumbered() || intf->isBridgePort())
) return NULL; ) return nullptr;
QString iname = getStandardName(currentObj, IPv4::TYPENAME, "ipv6"); QString iname = getStandardName(currentObj, IPv4::TYPENAME, "ipv6");
iname = makeNameUnique(currentObj, iname, IPv4::TYPENAME); iname = makeNameUnique(currentObj, iname, IPv4::TYPENAME);
return createObject(currentObj, IPv6::TYPENAME, iname, NULL, macro); return createObject(currentObj, IPv6::TYPENAME, iname, nullptr, macro);
} }
// if current object is not interface, create address in the standard folder // if current object is not interface, create address in the standard folder
return createObject(IPv6::TYPENAME, return createObject(IPv6::TYPENAME,
FWBTree().getTranslatableObjectTypeName(IPv6::TYPENAME), FWBTree().getTranslatableObjectTypeName(IPv6::TYPENAME),
NULL, macro); nullptr, macro);
} }
FWObject* ObjectManipulator::newPhysicalAddress(QUndoCommand* macro) FWObject* ObjectManipulator::newPhysicalAddress(QUndoCommand* macro)
{ {
FWObject *currentObj = getSelectedObject(); FWObject *currentObj = getSelectedObject();
if ( currentObj->isReadOnly() ) return NULL; if ( currentObj->isReadOnly() ) return nullptr;
if (Interface::isA(currentObj)) if (Interface::isA(currentObj))
{ {
@ -854,10 +854,10 @@ FWObject* ObjectManipulator::newPhysicalAddress(QUndoCommand* macro)
.arg(QString::fromUtf8(currentObj->getParent()->getName().c_str())) .arg(QString::fromUtf8(currentObj->getParent()->getName().c_str()))
.arg(QString::fromUtf8(currentObj->getName().c_str())); .arg(QString::fromUtf8(currentObj->getName().c_str()));
return createObject(currentObj, physAddress::TYPENAME, iname, return createObject(currentObj, physAddress::TYPENAME, iname,
NULL, macro); nullptr, macro);
} }
} }
return NULL; return nullptr;
} }
void ObjectManipulator::reminderAboutStandardLib() void ObjectManipulator::reminderAboutStandardLib()

View File

@ -91,10 +91,10 @@ void ObjectManipulator::autoRenameChildren(FWObject *obj,
if (oldName == QString::fromUtf8(obj->getName().c_str())) return; if (oldName == QString::fromUtf8(obj->getName().c_str())) return;
QTreeWidgetItem *itm = allItems[obj]; QTreeWidgetItem *itm = allItems[obj];
assert(itm!=NULL); assert(itm!=nullptr);
if ((QString::fromUtf8(obj->getName().c_str())!=oldName) && if ((QString::fromUtf8(obj->getName().c_str())!=oldName) &&
(Host::isA(obj) || Firewall::cast(obj)!=NULL || Interface::isA(obj))) (Host::isA(obj) || Firewall::cast(obj)!=nullptr || Interface::isA(obj)))
{ {
autorename(obj); autorename(obj);
} }
@ -105,7 +105,7 @@ void ObjectManipulator::autorename(FWObject *obj)
if (fwbdebug) if (fwbdebug)
qDebug() << "ObjectManipulator::autorename obj=" << obj->getName().c_str(); qDebug() << "ObjectManipulator::autorename obj=" << obj->getName().c_str();
if (Host::isA(obj) || Firewall::cast(obj)!=NULL || Cluster::isA(obj)) if (Host::isA(obj) || Firewall::cast(obj)!=nullptr || Cluster::isA(obj))
{ {
list<FWObject*> il = obj->getByType(Interface::TYPENAME); list<FWObject*> il = obj->getByType(Interface::TYPENAME);
for (list<FWObject*>::iterator i=il.begin(); i!=il.end(); ++i) for (list<FWObject*>::iterator i=il.begin(); i!=il.end(); ++i)
@ -179,7 +179,7 @@ void ObjectManipulator::autorenameVlans(list<FWObject*> &obj_list)
FWObject *obj = *j; FWObject *obj = *j;
FWObject *parent = obj->getParent(); FWObject *parent = obj->getParent();
FWObject *fw = parent; FWObject *fw = parent;
while (fw && Firewall::cast(fw)==NULL) fw = fw->getParent(); while (fw && Firewall::cast(fw)==nullptr) fw = fw->getParent();
assert(fw); assert(fw);
QString obj_name = QString::fromUtf8(obj->getName().c_str()); QString obj_name = QString::fromUtf8(obj->getName().c_str());
@ -216,24 +216,24 @@ void ObjectManipulator::autorenameVlans(list<FWObject*> &obj_list)
FWObject* ObjectManipulator::duplicateObject(FWObject *targetLib, FWObject *obj) FWObject* ObjectManipulator::duplicateObject(FWObject *targetLib, FWObject *obj)
{ {
if (!isTreeReadWrite(this, targetLib)) return NULL; if (!isTreeReadWrite(this, targetLib)) return nullptr;
// we disable copy/cut/paste/duplicate menu items for objects that // we disable copy/cut/paste/duplicate menu items for objects that
// can't be copied or duplicated in // can't be copied or duplicated in
// ObjectManipulator::getMenuState() but will check here just in // ObjectManipulator::getMenuState() but will check here just in
// case // case
if (AttachedNetworks::isA(obj)) return NULL; if (AttachedNetworks::isA(obj)) return nullptr;
openLib(targetLib); openLib(targetLib);
FWObject *new_parent = FWBTree().getStandardSlotForObject( FWObject *new_parent = FWBTree().getStandardSlotForObject(
targetLib, obj->getTypeName().c_str()); targetLib, obj->getTypeName().c_str());
if (new_parent == NULL) new_parent = obj->getParent(); if (new_parent == nullptr) new_parent = obj->getParent();
QString newName = QString newName =
makeNameUnique(new_parent, makeNameUnique(new_parent,
QString::fromUtf8(obj->getName().c_str()), QString::fromUtf8(obj->getName().c_str()),
obj->getTypeName().c_str()); obj->getTypeName().c_str());
if (!isObjectAllowed(new_parent, obj)) return NULL; if (!isObjectAllowed(new_parent, obj)) return nullptr;
return createObject(obj->getTypeName().c_str(), newName, obj); return createObject(obj->getTypeName().c_str(), newName, obj);
} }
@ -243,7 +243,7 @@ void ObjectManipulator::moveObject(FWObject *targetLib, FWObject *obj)
FWObject *cl=getCurrentLib(); FWObject *cl=getCurrentLib();
if (cl==targetLib) return; if (cl==targetLib) return;
FWObject *grp = NULL; FWObject *grp = nullptr;
if (FWObjectDatabase::isA(targetLib)) grp = targetLib; if (FWObjectDatabase::isA(targetLib)) grp = targetLib;
else else
@ -251,7 +251,7 @@ void ObjectManipulator::moveObject(FWObject *targetLib, FWObject *obj)
grp = FWBTree().getStandardSlotForObject( grp = FWBTree().getStandardSlotForObject(
targetLib, obj->getTypeName().c_str()); targetLib, obj->getTypeName().c_str());
} }
if (grp==NULL) grp=targetLib; if (grp==nullptr) grp=targetLib;
if (!grp->isReadOnly()) if (!grp->isReadOnly())
{ {
@ -301,15 +301,15 @@ FWObject* ObjectManipulator::actuallyPasteTo(FWObject *target,
//FWObject *res = NULL; //FWObject *res = NULL;
FWObject *ta = prepareForInsertion(target, obj); FWObject *ta = prepareForInsertion(target, obj);
if (ta == NULL) return NULL; if (ta == nullptr) return nullptr;
if (!isObjectAllowed(ta, obj)) return NULL; if (!isObjectAllowed(ta, obj)) return nullptr;
// we disable copy/cut/paste/duplicate menu items for objects that // we disable copy/cut/paste/duplicate menu items for objects that
// can't be copied or duplicated in // can't be copied or duplicated in
// ObjectManipulator::getMenuState() but will check here just in // ObjectManipulator::getMenuState() but will check here just in
// case // case
if (AttachedNetworks::isA(obj)) return NULL; if (AttachedNetworks::isA(obj)) return nullptr;
if (fwbdebug) if (fwbdebug)
qDebug() << "ObjectManipulator::actuallyPasteTo" qDebug() << "ObjectManipulator::actuallyPasteTo"
@ -326,7 +326,7 @@ FWObject* ObjectManipulator::actuallyPasteTo(FWObject *target,
{ {
if (fwbdebug) qDebug("Copy object %s (%d) to a different object tree", if (fwbdebug) qDebug("Copy object %s (%d) to a different object tree",
obj->getName().c_str(), obj->getId()); obj->getName().c_str(), obj->getId());
FWCmdAddObject *cmd = new FWCmdAddObject(m_project, target, NULL, FWCmdAddObject *cmd = new FWCmdAddObject(m_project, target, nullptr,
QObject::tr("Paste object")); QObject::tr("Paste object"));
FWObject *new_state = cmd->getNewState(); FWObject *new_state = cmd->getNewState();
cmd->setNeedTreeReload(true); cmd->setNeedTreeReload(true);
@ -343,7 +343,7 @@ FWObject* ObjectManipulator::actuallyPasteTo(FWObject *target,
} }
Group *grp = Group::cast(ta); Group *grp = Group::cast(ta);
if (grp!=NULL && !FWBTree().isSystem(ta)) if (grp!=nullptr && !FWBTree().isSystem(ta))
{ {
if (fwbdebug) qDebug("Copy object %s (%d) to a regular group", if (fwbdebug) qDebug("Copy object %s (%d) to a regular group",
obj->getName().c_str(), obj->getId()); obj->getName().c_str(), obj->getId());
@ -356,7 +356,7 @@ FWObject* ObjectManipulator::actuallyPasteTo(FWObject *target,
if(cp_id==o1->getId()) return o1; if(cp_id==o1->getId()) return o1;
FWReference *ref; FWReference *ref;
if( (ref=FWReference::cast(o1))!=NULL && if( (ref=FWReference::cast(o1))!=nullptr &&
cp_id==ref->getPointerId()) return o1; cp_id==ref->getPointerId()) return o1;
} }
FWCmdChange *cmd = new FWCmdChange( FWCmdChange *cmd = new FWCmdChange(
@ -379,7 +379,7 @@ FWObject* ObjectManipulator::actuallyPasteTo(FWObject *target,
obj->getName().c_str(), obj->getId()); obj->getName().c_str(), obj->getId());
FWObject *nobj = m_project->db()->create(obj->getTypeName()); FWObject *nobj = m_project->db()->create(obj->getTypeName());
assert(nobj!=NULL); assert(nobj!=nullptr);
//nobj->ref(); //nobj->ref();
nobj->duplicate(obj, true); nobj->duplicate(obj, true);
if (new_name != nobj->getName().c_str()) if (new_name != nobj->getName().c_str())
@ -417,7 +417,7 @@ FWObject* ObjectManipulator::actuallyPasteTo(FWObject *target,
0, 1 ); 0, 1 );
} }
return NULL; return nullptr;
} }
void ObjectManipulator::lockObject() void ObjectManipulator::lockObject()
@ -510,7 +510,7 @@ void ObjectManipulator::deleteObject(FWObject *obj, QUndoCommand* macro)
FWObject *deleted_objects_lib = m_project->db()->findInIndex( FWObject *deleted_objects_lib = m_project->db()->findInIndex(
FWObjectDatabase::DELETED_OBJECTS_ID ); FWObjectDatabase::DELETED_OBJECTS_ID );
if (deleted_objects_lib == NULL) if (deleted_objects_lib == nullptr)
{ {
FWObject *dobj = m_project->db()->createLibrary(); FWObject *dobj = m_project->db()->createLibrary();
dobj->setId(FWObjectDatabase::DELETED_OBJECTS_ID); dobj->setId(FWObjectDatabase::DELETED_OBJECTS_ID);
@ -529,8 +529,8 @@ void ObjectManipulator::deleteObject(FWObject *obj, QUndoCommand* macro)
obj->getId() == FWObjectDatabase::DELETED_OBJECTS_ID) return; obj->getId() == FWObjectDatabase::DELETED_OBJECTS_ID) return;
bool is_library = Library::isA(obj); bool is_library = Library::isA(obj);
bool is_firewall = Firewall::cast(obj) != NULL; // includes Cluster too bool is_firewall = Firewall::cast(obj) != nullptr; // includes Cluster too
bool is_deleted_object = (deleted_objects_lib!=NULL && obj->isChildOf(deleted_objects_lib)); bool is_deleted_object = (deleted_objects_lib!=nullptr && obj->isChildOf(deleted_objects_lib));
// ruleset_visible == true if 1) we delete firewall object and one of its // ruleset_visible == true if 1) we delete firewall object and one of its
// rulesets is visible in the project panel, or 2) we delete ruleset object // rulesets is visible in the project panel, or 2) we delete ruleset object
@ -568,7 +568,7 @@ void ObjectManipulator::deleteObject(FWObject *obj, QUndoCommand* macro)
obj, obj,
QString("Delete object"), QString("Delete object"),
macro); macro);
if (macro==0) if (macro==nullptr)
m_project->undoStack->push(cmd); m_project->undoStack->push(cmd);
return; return;
} }
@ -622,7 +622,7 @@ void ObjectManipulator::actuallyDeleteObject(FWObject *obj, QUndoCommand* macro)
QString("Delete object"), QString("Delete object"),
macro); macro);
if (macro == 0) if (macro == nullptr)
m_project->undoStack->push(cmd); m_project->undoStack->push(cmd);
} }
@ -645,11 +645,11 @@ void ObjectManipulator::groupObjects()
QString libName = ngd.m_dialog->libs->currentText(); QString libName = ngd.m_dialog->libs->currentText();
QString type = ObjectGroup::TYPENAME; QString type = ObjectGroup::TYPENAME;
if (Service::cast(co)!=NULL) type=ServiceGroup::TYPENAME; if (Service::cast(co)!=nullptr) type=ServiceGroup::TYPENAME;
if (Interval::cast(co)!=NULL) type=IntervalGroup::TYPENAME; if (Interval::cast(co)!=nullptr) type=IntervalGroup::TYPENAME;
FWObject *parent = NULL; FWObject *parent = nullptr;
FWObject *newgrp = NULL; FWObject *newgrp = nullptr;
list<FWObject*> ll = m_project->db()->getByType( Library::TYPENAME ); list<FWObject*> ll = m_project->db()->getByType( Library::TYPENAME );
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++) for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
@ -663,7 +663,7 @@ void ObjectManipulator::groupObjects()
*/ */
if (lib->isReadOnly()) return; if (lib->isReadOnly()) return;
parent = FWBTree().getStandardSlotForObject(lib,type); parent = FWBTree().getStandardSlotForObject(lib,type);
if (parent==NULL) if (parent==nullptr)
{ {
if (fwbdebug) if (fwbdebug)
qDebug("ObjectManipulator::groupObjects(): could not find standard slot for object of type %s in library %s", qDebug("ObjectManipulator::groupObjects(): could not find standard slot for object of type %s in library %s",
@ -676,7 +676,7 @@ void ObjectManipulator::groupObjects()
break; break;
} }
} }
if (newgrp==NULL) return; if (newgrp==nullptr) return;
FWCmdAddObject *cmd = new FWCmdAddObject( FWCmdAddObject *cmd = new FWCmdAddObject(
m_project, parent, newgrp, QObject::tr("Create new group")); m_project, parent, newgrp, QObject::tr("Create new group"));
@ -718,14 +718,14 @@ static void doKeyword(vector<FWObject *> objs, bool doAdd,
void ObjectManipulator::addNewKeywordSlot() void ObjectManipulator::addNewKeywordSlot()
{ {
QString keyword = QInputDialog::getText(0, tr("Add New Keyword"), QString keyword = QInputDialog::getText(nullptr, tr("Add New Keyword"),
tr("Enter new keyword to add to selected objects")); tr("Enter new keyword to add to selected objects"));
keyword = keyword.simplified(); keyword = keyword.simplified();
if (fwbdebug) { if (fwbdebug) {
qDebug() << "ObjectManipulator::addNewKeyword: " << keyword; qDebug() << "ObjectManipulator::addNewKeyword: " << keyword;
} }
if (!KeywordsDialog::validateKeyword(0, keyword)) return; if (!KeywordsDialog::validateKeyword(nullptr, keyword)) return;
doKeyword(getCurrentObjectTree()->getSelectedObjects(), true, doKeyword(getCurrentObjectTree()->getSelectedObjects(), true,
keyword.toUtf8().constData(), m_project); keyword.toUtf8().constData(), m_project);
@ -735,7 +735,7 @@ void ObjectManipulator::addNewKeywordSlot()
void ObjectManipulator::processKeywordSlot() void ObjectManipulator::processKeywordSlot()
{ {
const QObject *qObj = sender(); const QObject *qObj = sender();
if (qObj == 0) return; if (qObj == nullptr) return;
const QAction *qAct = dynamic_cast<const QAction *>(qObj); const QAction *qAct = dynamic_cast<const QAction *>(qObj);
QStringList list = qAct->data().toStringList(); QStringList list = qAct->data().toStringList();
if (list.size() != 2) return; if (list.size() != 2) return;
@ -752,12 +752,12 @@ void ObjectManipulator::processKeywordSlot()
void ObjectManipulator::addSubfolderSlot() void ObjectManipulator::addSubfolderSlot()
{ {
const QAction *qAct = dynamic_cast<const QAction *>(sender()); const QAction *qAct = dynamic_cast<const QAction *>(sender());
if (qAct == 0) return; if (qAct == nullptr) return;
FWObject *obj = getCurrentObjectTree()->getCurrentObject(); FWObject *obj = getCurrentObjectTree()->getCurrentObject();
assert(obj->getId() == qAct->data().toInt()); assert(obj->getId() == qAct->data().toInt());
QString folder = QInputDialog::getText(0, tr("Add Subfolder"), QString folder = QInputDialog::getText(nullptr, tr("Add Subfolder"),
tr("Enter new subfolder name")); tr("Enter new subfolder name"));
folder = folder.simplified(); folder = folder.simplified();
if (folder.isEmpty()) return; if (folder.isEmpty()) return;
@ -791,10 +791,10 @@ void ObjectManipulator::removeUserFolder()
{ {
ObjectTreeViewItem *item = dynamic_cast<ObjectTreeViewItem *> ObjectTreeViewItem *item = dynamic_cast<ObjectTreeViewItem *>
(getCurrentObjectTree()->currentItem()); (getCurrentObjectTree()->currentItem());
if (item == 0 || item->getUserFolderParent() == 0) return; if (item == nullptr || item->getUserFolderParent() == nullptr) return;
ObjectTreeViewItem *parent = dynamic_cast<ObjectTreeViewItem *> ObjectTreeViewItem *parent = dynamic_cast<ObjectTreeViewItem *>
(item->parent()); (item->parent());
assert(parent != 0); assert(parent != nullptr);
vector<FWObject *> objs; vector<FWObject *> objs;
for (int ii = 0; ii < item->childCount(); ii++) { for (int ii = 0; ii < item->childCount(); ii++) {
@ -826,7 +826,7 @@ void ObjectManipulator::removeUserFolder()
while (!children.isEmpty()) { while (!children.isEmpty()) {
ObjectTreeViewItem *child = dynamic_cast<ObjectTreeViewItem *> ObjectTreeViewItem *child = dynamic_cast<ObjectTreeViewItem *>
(children.takeFirst()); (children.takeFirst());
assert(child != 0); assert(child != nullptr);
FWObject *obj = child->getFWObject(); FWObject *obj = child->getFWObject();
if (mw->isEditorVisible() && mw->getOpenedEditor() == obj) { if (mw->isEditorVisible() && mw->getOpenedEditor() == obj) {

View File

@ -73,7 +73,7 @@ void ObjectManipulator::undeleteLibrary()
if (getCurrentObjectTree()->getNumSelected()==0) return; if (getCurrentObjectTree()->getNumSelected()==0) return;
FWObject *obj = getCurrentObjectTree()->getSelectedObjects().front(); FWObject *obj = getCurrentObjectTree()->getSelectedObjects().front();
if (obj==NULL) return; if (obj==nullptr) return;
// check that obj is in Deleted objects library. We do not show menu item // check that obj is in Deleted objects library. We do not show menu item
// "Undelete" if it isnt, but will double check anyway // "Undelete" if it isnt, but will double check anyway
@ -88,7 +88,7 @@ void ObjectManipulator::undeleteLibrary()
obj, obj,
reference_holders, reference_holders,
QString("Undelete library object"), QString("Undelete library object"),
0); nullptr);
m_project->undoStack->push(cmd); m_project->undoStack->push(cmd);
} }
} }
@ -185,11 +185,11 @@ void ObjectManipulator::pasteObj()
{ {
if (getCurrentObjectTree()->getNumSelected()==0) return; if (getCurrentObjectTree()->getNumSelected()==0) return;
FWObject *target_object = getCurrentObjectTree()->getSelectedObjects().front(); FWObject *target_object = getCurrentObjectTree()->getSelectedObjects().front();
if (target_object==NULL) return; if (target_object==nullptr) return;
vector<std::pair<int,ProjectPanel*> >::iterator i; vector<std::pair<int,ProjectPanel*> >::iterator i;
int idx = 0; int idx = 0;
FWObject *last_object = NULL; FWObject *last_object = nullptr;
Q_UNUSED(last_object); Q_UNUSED(last_object);
map<int,int> map_ids; map<int,int> map_ids;
if (fwbdebug) if (fwbdebug)
@ -254,7 +254,7 @@ void ObjectManipulator::duplicateObj(QAction *action)
ObjectTreeView* ot=getCurrentObjectTree(); ObjectTreeView* ot=getCurrentObjectTree();
ot->freezeSelection(true); ot->freezeSelection(true);
FWObject *obj; FWObject *obj;
FWObject *nobj = NULL; FWObject *nobj = nullptr;
vector<FWObject*> so = getCurrentObjectTree()->getSimplifiedSelection(); vector<FWObject*> so = getCurrentObjectTree()->getSimplifiedSelection();
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i) for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
{ {
@ -356,7 +356,7 @@ void ObjectManipulator::dumpObj()
if (getCurrentObjectTree()->getNumSelected()==0) return; if (getCurrentObjectTree()->getNumSelected()==0) return;
FWObject *obj=getCurrentObjectTree()->getSelectedObjects().front(); FWObject *obj=getCurrentObjectTree()->getSelectedObjects().front();
if (obj==NULL) return; if (obj==nullptr) return;
obj->dump(true,false); obj->dump(true,false);
} }
@ -416,7 +416,7 @@ void ObjectManipulator::find()
if (getCurrentObjectTree()->getNumSelected()==0) return; if (getCurrentObjectTree()->getNumSelected()==0) return;
FWObject *obj=getCurrentObjectTree()->getSelectedObjects().front(); FWObject *obj=getCurrentObjectTree()->getSelectedObjects().front();
if (obj==NULL) return; if (obj==nullptr) return;
m_project->setFDObject(obj); m_project->setFDObject(obj);
} }
@ -425,7 +425,7 @@ void ObjectManipulator::findObject()
if (getCurrentObjectTree()->getNumSelected()==0) return; if (getCurrentObjectTree()->getNumSelected()==0) return;
FWObject *obj=getCurrentObjectTree()->getSelectedObjects().front(); FWObject *obj=getCurrentObjectTree()->getSelectedObjects().front();
if (obj==NULL) return; if (obj==nullptr) return;
mw->findObject( obj ); mw->findObject( obj );
} }
@ -434,7 +434,7 @@ void ObjectManipulator::findWhereUsedSlot()
if (getCurrentObjectTree()->getNumSelected()==0) return; if (getCurrentObjectTree()->getNumSelected()==0) return;
FWObject *obj = getCurrentObjectTree()->getSelectedObjects().front(); FWObject *obj = getCurrentObjectTree()->getSelectedObjects().front();
if (obj==NULL) return; if (obj==nullptr) return;
mw->findWhereUsed(obj, m_project); mw->findWhereUsed(obj, m_project);
} }
@ -443,7 +443,7 @@ void ObjectManipulator::makeSubinterface(QAction *act)
{ {
int intf_id = act->data().toInt(); int intf_id = act->data().toInt();
FWObject *new_parent_interface = m_project->db()->findInIndex(intf_id); FWObject *new_parent_interface = m_project->db()->findInIndex(intf_id);
assert(new_parent_interface!=NULL); assert(new_parent_interface!=nullptr);
if (getCurrentObjectTree()->getNumSelected()==0) return; if (getCurrentObjectTree()->getNumSelected()==0) return;
@ -474,7 +474,7 @@ void ObjectManipulator::makeSubinterface(QAction *act)
obj, obj,
reference_holders, reference_holders,
QString("Make an interface a subinterface"), QString("Make an interface a subinterface"),
0); nullptr);
m_project->undoStack->push(cmd); m_project->undoStack->push(cmd);
} }

View File

@ -183,7 +183,7 @@ void ObjectManipulator::expandObjectInTree(FWObject *obj)
//if (FWReference::cast(o)!=NULL) o = FWReference::cast(o)->getPointer(); //if (FWReference::cast(o)!=NULL) o = FWReference::cast(o)->getPointer();
QTreeWidgetItem *it = allItems[o]; QTreeWidgetItem *it = allItems[o];
if (it==NULL) if (it==nullptr)
{ {
if (fwbdebug) qDebug() << "#### Tree node not found"; if (fwbdebug) qDebug() << "#### Tree node not found";
return; return;
@ -196,7 +196,7 @@ void ObjectManipulator::expandOrCollapseCurrentTreeNode(QTreeWidgetItem *item,
bool expand) bool expand)
{ {
QTreeWidgetItem *parent = item->parent(); QTreeWidgetItem *parent = item->parent();
if (expand && parent != NULL && ! parent->isExpanded()) if (expand && parent != nullptr && ! parent->isExpanded())
parent->setExpanded(true); parent->setExpanded(true);
item->setExpanded(expand); item->setExpanded(expand);
@ -224,14 +224,14 @@ static ObjectTreeViewItem *findUserFolder(ObjectTreeViewItem *parent,
{ {
if (folder.isEmpty()) return parent; if (folder.isEmpty()) return parent;
ObjectTreeViewItem *otvi = 0; ObjectTreeViewItem *otvi = nullptr;
int childNo = 0; int childNo = 0;
while(parent->child(childNo) != NULL && otvi == 0) { while(parent->child(childNo) != nullptr && otvi == nullptr) {
ObjectTreeViewItem *sub = ObjectTreeViewItem *sub =
dynamic_cast<ObjectTreeViewItem *>(parent->child(childNo)); dynamic_cast<ObjectTreeViewItem *>(parent->child(childNo));
if (sub != 0 && if (sub != nullptr &&
sub->getUserFolderParent() != 0 && sub->getUserFolderParent() != nullptr &&
sub->getUserFolderName() == folder) { sub->getUserFolderName() == folder) {
otvi = sub; otvi = sub;
return otvi; return otvi;
@ -263,12 +263,12 @@ static ObjectTreeViewItem *findUserFolder(ObjectTreeViewItem *parent,
ObjectTreeViewItem* ObjectManipulator::insertObject(ObjectTreeViewItem *itm, ObjectTreeViewItem* ObjectManipulator::insertObject(ObjectTreeViewItem *itm,
FWObject *obj) FWObject *obj)
{ {
if (FWReference::cast(obj)!=NULL) return NULL; if (FWReference::cast(obj)!=nullptr) return nullptr;
if (Resources::global_res->getObjResourceBool(obj,"hidden") ) return NULL; if (Resources::global_res->getObjResourceBool(obj,"hidden") ) return nullptr;
if (Resources::global_res->getResourceBool( if (Resources::global_res->getResourceBool(
string("/FWBuilderResources/Type/") + string("/FWBuilderResources/Type/") +
obj->getTypeName() + "/hidden")) return NULL; obj->getTypeName() + "/hidden")) return nullptr;
ObjectTreeViewItem *item = itm; ObjectTreeViewItem *item = itm;
if (!obj->getStr("folder").empty()) { if (!obj->getStr("folder").empty()) {
@ -276,7 +276,7 @@ ObjectTreeViewItem* ObjectManipulator::insertObject(ObjectTreeViewItem *itm,
/* If we can't find the user folder, put it under the system /* If we can't find the user folder, put it under the system
folder and get rid of the folder attribute */ folder and get rid of the folder attribute */
if (item == 0) { if (item == nullptr) {
item = itm; item = itm;
obj->setStr("folder", ""); obj->setStr("folder", "");
} }
@ -316,15 +316,15 @@ void ObjectManipulator::insertSubtree(FWObject *parent, FWObject *obj)
ObjectTreeViewItem* parent_item = allItems[parent]; ObjectTreeViewItem* parent_item = allItems[parent];
insertSubtree(parent_item, obj); insertSubtree(parent_item, obj);
QTreeWidgetItem *itm = allItems[parent]; QTreeWidgetItem *itm = allItems[parent];
if (itm==NULL) return; if (itm==nullptr) return;
refreshSubtree(itm, NULL); refreshSubtree(itm, nullptr);
} }
void ObjectManipulator::insertSubtree(ObjectTreeViewItem *itm, FWObject *obj) void ObjectManipulator::insertSubtree(ObjectTreeViewItem *itm, FWObject *obj)
{ {
this->m_objectManipulator->filter->clear(); this->m_objectManipulator->filter->clear();
ObjectTreeViewItem *nitm = insertObject(itm, obj); ObjectTreeViewItem *nitm = insertObject(itm, obj);
if (nitm==NULL) return; if (nitm==nullptr) return;
if (FWBTree().isStandardFolder(obj)) nitm->setExpanded( st->getExpandTree()); if (FWBTree().isStandardFolder(obj)) nitm->setExpanded( st->getExpandTree());
@ -387,7 +387,7 @@ void ObjectManipulator::insertSubtree(ObjectTreeViewItem *itm, FWObject *obj)
for (list<FWObject*>::iterator m=obj->begin(); m!=obj->end(); m++) for (list<FWObject*>::iterator m=obj->begin(); m!=obj->end(); m++)
{ {
FWObject *o1=*m; FWObject *o1=*m;
if (FWReference::cast(o1)!=NULL) continue; if (FWReference::cast(o1)!=nullptr) continue;
insertSubtree(nitm, o1); insertSubtree(nitm, o1);
} }
@ -404,7 +404,7 @@ void ObjectManipulator::removeObjectFromTreeView(FWObject *obj)
objTreeView->clearLastSelected(); objTreeView->clearLastSelected();
ObjectTreeViewItem *itm = allItems[obj]; ObjectTreeViewItem *itm = allItems[obj];
allItems[obj] = NULL; allItems[obj] = nullptr;
if (itm && itm->parent()) if (itm && itm->parent())
{ {
itm->parent()->takeChild(itm->parent()->indexOfChild(itm)); itm->parent()->takeChild(itm->parent()->indexOfChild(itm));
@ -431,11 +431,11 @@ FWObject* ObjectManipulator::findRuleSetInHistoryByParentFw(FWObject* parent)
if (RuleSet::cast(obj)) if (RuleSet::cast(obj))
{ {
FWObject *parent_fw = Host::getParentHost(obj); FWObject *parent_fw = Host::getParentHost(obj);
if (parent_fw != NULL && parent_fw == parent) return obj; if (parent_fw != nullptr && parent_fw == parent) return obj;
} }
} }
return NULL; return nullptr;
} }
void ObjectManipulator::removeObjectFromHistory(FWObject *obj) void ObjectManipulator::removeObjectFromHistory(FWObject *obj)
@ -509,7 +509,7 @@ void ObjectManipulator::updateObjectInTree(FWObject *obj, bool subtree)
<< "subtree=" << subtree; << "subtree=" << subtree;
QTreeWidgetItem *itm = allItems[obj]; QTreeWidgetItem *itm = allItems[obj];
if (itm==NULL) return; if (itm==nullptr) return;
// first, update tree item that represents @obj. Its name or label // first, update tree item that represents @obj. Its name or label
// (second column) might have changed // (second column) might have changed
@ -528,7 +528,7 @@ void ObjectManipulator::updateObjectInTree(FWObject *obj, bool subtree)
// now if we need to update subtree, call refreshSubtree() // now if we need to update subtree, call refreshSubtree()
if (subtree) if (subtree)
refreshSubtree(itm, NULL); refreshSubtree(itm, nullptr);
} }
void ObjectManipulator::clearObjects() void ObjectManipulator::clearObjects()
@ -543,7 +543,7 @@ void ObjectManipulator::clearObjects()
{ {
QTreeWidget *objTreeView = libs_model->getTreeWidget(i); QTreeWidget *objTreeView = libs_model->getTreeWidget(i);
if (objTreeView == NULL) continue; if (objTreeView == nullptr) continue;
m_objectManipulator->widgetStack->removeWidget(objTreeView); m_objectManipulator->widgetStack->removeWidget(objTreeView);
// delete otv; // delete otv;
@ -554,7 +554,7 @@ void ObjectManipulator::clearObjects()
libs_model->addStaticItems(); libs_model->addStaticItems();
current_tree_view = NULL; current_tree_view = nullptr;
if (fwbdebug) qDebug("ObjectManipulator::clearObjects done"); if (fwbdebug) qDebug("ObjectManipulator::clearObjects done");
} }
@ -580,7 +580,7 @@ void ObjectManipulator::loadObjects()
clearObjects(); clearObjects();
FWObject *firstUserLib = NULL; FWObject *firstUserLib = nullptr;
list<FWObject*> ll = m_project->db()->getByType( Library::TYPENAME ); list<FWObject*> ll = m_project->db()->getByType( Library::TYPENAME );
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++) for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
@ -599,7 +599,7 @@ void ObjectManipulator::loadObjects()
if ( lib->getId()!=FWObjectDatabase::STANDARD_LIB_ID && if ( lib->getId()!=FWObjectDatabase::STANDARD_LIB_ID &&
lib->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID && lib->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID &&
firstUserLib==NULL) firstUserLib = *i; firstUserLib==nullptr) firstUserLib = *i;
addLib( lib ); addLib( lib );
@ -609,7 +609,7 @@ void ObjectManipulator::loadObjects()
} }
if (firstUserLib==NULL) firstUserLib = ll.front(); if (firstUserLib==nullptr) firstUserLib = ll.front();
openLib( firstUserLib ); openLib( firstUserLib );
if (fwbdebug) if (fwbdebug)
@ -774,9 +774,9 @@ void ObjectManipulator::moveItems(ObjectTreeViewItem *dest,
{ {
string folder; string folder;
if(dest != NULL) if(dest != nullptr)
{ {
if (dest->getUserFolderParent() != 0) { if (dest->getUserFolderParent() != nullptr) {
folder = dest->getUserFolderName().toUtf8().constData(); folder = dest->getUserFolderName().toUtf8().constData();
} else { } else {
folder = dest->getFWObject()->getStr("folder"); folder = dest->getFWObject()->getStr("folder");
@ -807,7 +807,7 @@ void ObjectManipulator::addUserFolderToTree(FWObject *obj,
ObjectTreeViewItem *item = allItems[obj]; ObjectTreeViewItem *item = allItems[obj];
if (item == 0) return; if (item == nullptr) return;
ObjectTreeViewItem *sub = new ObjectTreeViewItem(item); ObjectTreeViewItem *sub = new ObjectTreeViewItem(item);
@ -834,7 +834,7 @@ std::string ObjectManipulator::getFolderNameString(libfwbuilder::FWObject *obj)
FWObject *parent = obj->getParent(); FWObject *parent = obj->getParent();
while(parent != NULL) { while(parent != nullptr) {
result = parent->getName() + "/" + result; result = parent->getName() + "/" + result;
parent = parent->getParent(); parent = parent->getParent();
} }
@ -848,16 +848,16 @@ void ObjectManipulator::removeUserFolderFromTree(FWObject *obj,
const QString &folder) const QString &folder)
{ {
ObjectTreeViewItem *item = allItems[obj]; ObjectTreeViewItem *item = allItems[obj];
if (item == 0) return; if (item == nullptr) return;
ObjectTreeViewItem *sub = findUserFolder(item, folder); ObjectTreeViewItem *sub = findUserFolder(item, folder);
if (sub == 0) return; if (sub == nullptr) return;
QList<QTreeWidgetItem *> children = sub->takeChildren(); QList<QTreeWidgetItem *> children = sub->takeChildren();
while (!children.isEmpty()) { while (!children.isEmpty()) {
ObjectTreeViewItem *child = dynamic_cast<ObjectTreeViewItem *> ObjectTreeViewItem *child = dynamic_cast<ObjectTreeViewItem *>
(children.takeFirst()); (children.takeFirst());
assert(child != 0); assert(child != nullptr);
FWObject *obj = child->getFWObject(); FWObject *obj = child->getFWObject();
if (mw->isEditorVisible() && mw->getOpenedEditor() == obj) { if (mw->isEditorVisible() && mw->getOpenedEditor() == obj) {
@ -870,7 +870,7 @@ void ObjectManipulator::removeUserFolderFromTree(FWObject *obj,
item->removeChild(sub); item->removeChild(sub);
delete sub; delete sub;
refreshSubtree(item, 0); refreshSubtree(item, nullptr);
} }
@ -881,7 +881,7 @@ void ObjectManipulator::moveToFromUserFolderInTree(FWObject *obj,
{ {
ObjectTreeViewItem *parent = allItems[obj]; ObjectTreeViewItem *parent = allItems[obj];
ObjectTreeViewItem *toMove = allItems[objToMove]; ObjectTreeViewItem *toMove = allItems[objToMove];
if (parent == 0 || toMove == 0) return; if (parent == nullptr || toMove == nullptr) return;
ObjectTreeViewItem *oldItem = findUserFolder(parent, oldFolder); ObjectTreeViewItem *oldItem = findUserFolder(parent, oldFolder);
ObjectTreeViewItem *newItem = findUserFolder(parent, newFolder); ObjectTreeViewItem *newItem = findUserFolder(parent, newFolder);
@ -889,7 +889,7 @@ void ObjectManipulator::moveToFromUserFolderInTree(FWObject *obj,
oldItem->removeChild(toMove); oldItem->removeChild(toMove);
newItem->addChild(toMove); newItem->addChild(toMove);
refreshSubtree(newItem, 0); refreshSubtree(newItem, nullptr);
} }

View File

@ -63,7 +63,7 @@ void ObjectSelectorWidget::updateObjectsToUse()
{ {
objects_to_use.clear(); objects_to_use.clear();
QListWidgetItem* item = m_dialog->objectList->item(0); QListWidgetItem* item = m_dialog->objectList->item(0);
while (item != NULL) while (item != nullptr)
{ {
QString name = item->text().split(" ")[0]; QString name = item->text().split(" ")[0];
QString addr = item->data(Qt::UserRole).toString(); QString addr = item->data(Qt::UserRole).toString();
@ -154,7 +154,7 @@ void ObjectSelectorWidget::removeObject()
QListWidgetItem* item1 = m_dialog->objectList->item(0); QListWidgetItem* item1 = m_dialog->objectList->item(0);
QListWidgetItem* item2; QListWidgetItem* item2;
while (item1!=0) while (item1!=nullptr)
{ {
item2 = m_dialog->objectList->item(m_dialog->objectList->row(item1)+1); item2 = m_dialog->objectList->item(m_dialog->objectList->row(item1)+1);
if (item1->isSelected()) if (item1->isSelected())

View File

@ -106,8 +106,8 @@ ObjectTreeView::ObjectTreeView(ProjectPanel* project,
setExpandsOnDoubleClick(false); setExpandsOnDoubleClick(false);
setDragEnabled(true); setDragEnabled(true);
item_before_drag_started=NULL; item_before_drag_started=nullptr;
lastSelected = NULL; lastSelected = nullptr;
second_click = false; second_click = false;
selectionFrozen = false; selectionFrozen = false;
expandOrCollapse = false; expandOrCollapse = false;
@ -216,16 +216,16 @@ bool ObjectTreeView::event( QEvent *event )
{ {
int cx = pos.x(), cy = pos.y(); int cx = pos.x(), cy = pos.y();
FWObject *obj=NULL; FWObject *obj=nullptr;
QRect cr; QRect cr;
QTreeWidgetItem *itm = itemAt(QPoint(cx, cy - header()->height())); QTreeWidgetItem *itm = itemAt(QPoint(cx, cy - header()->height()));
if (itm==NULL) return false; if (itm==nullptr) return false;
ObjectTreeViewItem *oivi = dynamic_cast<ObjectTreeViewItem*>(itm); ObjectTreeViewItem *oivi = dynamic_cast<ObjectTreeViewItem*>(itm);
assert(oivi!=NULL); assert(oivi!=nullptr);
obj = oivi->getFWObject(); obj = oivi->getFWObject();
if (obj==NULL) return false; if (obj==nullptr) return false;
if (obj->getId() == FWObjectDatabase::ANY_ADDRESS_ID || if (obj->getId() == FWObjectDatabase::ANY_ADDRESS_ID ||
obj->getId() == FWObjectDatabase::ANY_SERVICE_ID || obj->getId() == FWObjectDatabase::ANY_SERVICE_ID ||
@ -268,7 +268,7 @@ void ObjectTreeView::itemCollapsed(QTreeWidgetItem* itm)
expandOrCollapse = true; expandOrCollapse = true;
ObjectTreeViewItem *otvi = dynamic_cast<ObjectTreeViewItem*>(itm); ObjectTreeViewItem *otvi = dynamic_cast<ObjectTreeViewItem*>(itm);
assert(otvi!=NULL); assert(otvi!=nullptr);
FWObject *o = otvi->getFWObject(); FWObject *o = otvi->getFWObject();
if (o) if (o)
{ {
@ -282,7 +282,7 @@ void ObjectTreeView::itemExpanded(QTreeWidgetItem* itm)
expandOrCollapse = true; expandOrCollapse = true;
ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(itm); ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(itm);
assert(otvi!=NULL); assert(otvi!=nullptr);
FWObject *o = otvi->getFWObject(); FWObject *o = otvi->getFWObject();
if (o) if (o)
{ {
@ -319,7 +319,7 @@ FWObject* ObjectTreeView::getCurrentObject()
{ {
QTreeWidgetItem *ovi = currentItem(); QTreeWidgetItem *ovi = currentItem();
ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(ovi); ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(ovi);
if (otvi==NULL) return NULL; if (otvi==nullptr) return nullptr;
return otvi->getFWObject(); return otvi->getFWObject();
} }
@ -347,7 +347,7 @@ void ObjectTreeView::updateTreeIcons()
FWObject *obj = otvi->getFWObject(); FWObject *obj = otvi->getFWObject();
/* We can have obj==0 if it's a user-create subfolder */ /* We can have obj==0 if it's a user-create subfolder */
if (obj == 0) continue; if (obj == nullptr) continue;
QPixmap pm_obj; QPixmap pm_obj;
IconSetter::setObjectIcon(obj, &pm_obj, 0); IconSetter::setObjectIcon(obj, &pm_obj, 0);
@ -359,12 +359,12 @@ void ObjectTreeView::updateTreeIcons()
void ObjectTreeView::startDrag(Qt::DropActions supportedActions) void ObjectTreeView::startDrag(Qt::DropActions supportedActions)
{ {
QTreeWidgetItem *ovi = currentItem(); QTreeWidgetItem *ovi = currentItem();
if (ovi==NULL) return; if (ovi==nullptr) return;
FWObject *current_obj = getCurrentObject(); FWObject *current_obj = getCurrentObject();
/* User-defined folders can't be dragged */ /* User-defined folders can't be dragged */
if (current_obj == 0) return; if (current_obj == nullptr) return;
if (fwbdebug) qDebug("ObjectTreeView::startDrag: this: %p current_obj: %s", if (fwbdebug) qDebug("ObjectTreeView::startDrag: this: %p current_obj: %s",
this, current_obj->getName().c_str()); this, current_obj->getName().c_str());
@ -481,22 +481,22 @@ void ObjectTreeView::dragEnterEvent( QDragEnterEvent *ev)
static bool isValidDropTarget(QTreeWidgetItem *item, list<FWObject *> &objs) static bool isValidDropTarget(QTreeWidgetItem *item, list<FWObject *> &objs)
{ {
ObjectTreeViewItem *dest = dynamic_cast<ObjectTreeViewItem *>(item); ObjectTreeViewItem *dest = dynamic_cast<ObjectTreeViewItem *>(item);
if (dest == 0) return false; if (dest == nullptr) return false;
bool dragIsNoop = true; bool dragIsNoop = true;
list<FWObject *>::const_iterator iter; list<FWObject *>::const_iterator iter;
for (iter = objs.begin(); iter != objs.end(); ++iter) { for (iter = objs.begin(); iter != objs.end(); ++iter) {
FWObject *dragobj = *iter; FWObject *dragobj = *iter;
assert(dragobj != 0); assert(dragobj != nullptr);
if (Interface::cast(dragobj) != 0 || if (Interface::cast(dragobj) != nullptr ||
Interface::cast(dragobj->getParent()) != 0 || Interface::cast(dragobj->getParent()) != nullptr ||
Policy::cast(dragobj) != 0 || Policy::cast(dragobj) != nullptr ||
NAT::cast(dragobj) != 0 || NAT::cast(dragobj) != nullptr ||
Routing::cast(dragobj) != 0) return false; Routing::cast(dragobj) != nullptr) return false;
/* See if destination is a user folder */ /* See if destination is a user folder */
if (dest->getUserFolderParent() != 0) { if (dest->getUserFolderParent() != nullptr) {
/* Dragged object has to match parent of user folder */ /* Dragged object has to match parent of user folder */
if (dest->getUserFolderParent() != dragobj->getParent()) { if (dest->getUserFolderParent() != dragobj->getParent()) {
return false; return false;
@ -548,11 +548,11 @@ void ObjectTreeView::dragMoveEvent(QDragMoveEvent *ev)
void ObjectTreeView::dropEvent(QDropEvent *ev) void ObjectTreeView::dropEvent(QDropEvent *ev)
{ {
// only accept drops from the same instance of fwbuilder // only accept drops from the same instance of fwbuilder
if (ev->source() == NULL) return; if (ev->source() == nullptr) return;
ObjectTreeViewItem *dest = ObjectTreeViewItem *dest =
dynamic_cast<ObjectTreeViewItem *>(itemAt(ev->pos())); dynamic_cast<ObjectTreeViewItem *>(itemAt(ev->pos()));
if (dest == 0) { if (dest == nullptr) {
notWanted: notWanted:
ev->setAccepted(false); ev->setAccepted(false);
return; return;
@ -581,7 +581,7 @@ void ObjectTreeView::mouseMoveEvent( QMouseEvent * e )
clicks and tries to drag something non-draggable. */ clicks and tries to drag something non-draggable. */
if (state() == DragSelectingState) return; if (state() == DragSelectingState) return;
QTreeWidget::mouseMoveEvent(e); QTreeWidget::mouseMoveEvent(e);
if (e==NULL) return; if (e==nullptr) return;
} }
void ObjectTreeView::mousePressEvent( QMouseEvent *e ) void ObjectTreeView::mousePressEvent( QMouseEvent *e )
@ -659,7 +659,7 @@ void ObjectTreeView::mouseReleaseEvent( QMouseEvent *e )
qDebug("ObjectTreeView::mouseReleaseEvent 2 selectedObjects.size()=%d getCurrentObject()=%p current object %s", qDebug("ObjectTreeView::mouseReleaseEvent 2 selectedObjects.size()=%d getCurrentObject()=%p current object %s",
int(selectedObjects.size()), int(selectedObjects.size()),
getCurrentObject(), getCurrentObject(),
(getCurrentObject()!=NULL)?getCurrentObject()->getName().c_str():"nil"); (getCurrentObject()!=nullptr)?getCurrentObject()->getName().c_str():"nil");
if (expandOrCollapse) return; // user expanded or collapsed subtree, if (expandOrCollapse) return; // user expanded or collapsed subtree,
// no need to change object in the editor // no need to change object in the editor
@ -742,7 +742,7 @@ void ObjectTreeView::itemOpened ()
void ObjectTreeView::clearLastSelected() void ObjectTreeView::clearLastSelected()
{ {
lastSelected = NULL; lastSelected = nullptr;
} }
@ -779,7 +779,7 @@ void ObjectTreeView::itemSelectionChanged()
ObjectTreeViewItem *otvi = dynamic_cast<ObjectTreeViewItem*>(itm); ObjectTreeViewItem *otvi = dynamic_cast<ObjectTreeViewItem*>(itm);
FWObject *obj = otvi->getFWObject(); FWObject *obj = otvi->getFWObject();
if (obj == 0) continue; if (obj == nullptr) continue;
selectedObjects.push_back(otvi->getFWObject()); selectedObjects.push_back(otvi->getFWObject());
@ -824,7 +824,7 @@ void ObjectTreeView::ExpandTreeItems(const set<int> &ids)
QTreeWidgetItem *itm = *it; QTreeWidgetItem *itm = *it;
ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(itm); ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(itm);
FWObject *obj = otvi->getFWObject(); FWObject *obj = otvi->getFWObject();
if (obj == 0) continue; if (obj == nullptr) continue;
if (ids.count(obj->getId())) if (ids.count(obj->getId()))
itm->setExpanded(true); itm->setExpanded(true);
} }
@ -852,7 +852,7 @@ QSet<QTreeWidgetItem*> ObjectTreeView::resolveParents(QTreeWidgetItem *child)
{ {
QSet<QTreeWidgetItem*> parents; QSet<QTreeWidgetItem*> parents;
parents.insert(child); parents.insert(child);
if (child->parent() == NULL) return parents; if (child->parent() == nullptr) return parents;
parents.unite(resolveParents(child->parent())); parents.unite(resolveParents(child->parent()));
return parents; return parents;
} }
@ -1013,7 +1013,7 @@ static bool filterMatches(const QString &text,
// Support for port and ip search // Support for port and ip search
if (filterMatchesCommand(text, item)) return true; if (filterMatchesCommand(text, item)) return true;
if (item->getUserFolderParent() != 0) return false; if (item->getUserFolderParent() != nullptr) return false;
FWObject *obj = item->getFWObject(); FWObject *obj = item->getFWObject();
QByteArray utf8 = text.toUtf8(); QByteArray utf8 = text.toUtf8();
@ -1079,12 +1079,12 @@ void ObjectTreeView::setFilter(QString text)
if (filterMatches(text, otvi)) { if (filterMatches(text, otvi)) {
(*wit)->setHidden(false); (*wit)->setHidden(false);
if (Firewall::cast(otvi->getFWObject()) != 0) { if (Firewall::cast(otvi->getFWObject()) != nullptr) {
expand.push_back(otvi); expand.push_back(otvi);
} }
QTreeWidgetItem *parent = (*wit)->parent(); QTreeWidgetItem *parent = (*wit)->parent();
while (parent != 0) { while (parent != nullptr) {
parent->setHidden(false); parent->setHidden(false);
parent = parent->parent(); parent = parent->parent();
} }

View File

@ -58,16 +58,16 @@ QVariant ObjectTreeViewItem::data(int column, int role) const
QFont item_font = QTreeWidgetItem::data(column, role).value<QFont>(); QFont item_font = QTreeWidgetItem::data(column, role).value<QFont>();
FWObject *obj = getFWObject(); FWObject *obj = getFWObject();
Firewall *o = NULL; Firewall *o = nullptr;
if (obj!=NULL && ( if (obj!=nullptr && (
getProperty("type")==Firewall::TYPENAME || getProperty("type")==Firewall::TYPENAME ||
getProperty("type")==Cluster::TYPENAME)) getProperty("type")==Cluster::TYPENAME))
{ {
o = Firewall::cast( obj ); o = Firewall::cast( obj );
} }
if (o!=NULL) if (o!=nullptr)
{ {
bool mf = !o->getInactive() && (o->needsCompile()) ; bool mf = !o->getInactive() && (o->needsCompile()) ;
item_font.setBold (mf); item_font.setBold (mf);
@ -84,12 +84,12 @@ QVariant ObjectTreeViewItem::data(int column, int role) const
static int getRank(FWObject *obj) static int getRank(FWObject *obj)
{ {
/* User-defined folders are first */ /* User-defined folders are first */
if (obj == 0) return 0; if (obj == nullptr) return 0;
if (Interface::cast(obj) != 0) return 5; if (Interface::cast(obj) != nullptr) return 5;
if (Policy::cast(obj) != 0) return 2; if (Policy::cast(obj) != nullptr) return 2;
if (NAT::cast(obj) != 0) return 3; if (NAT::cast(obj) != nullptr) return 3;
if (Routing::cast(obj) != 0) return 4; if (Routing::cast(obj) != nullptr) return 4;
return 1; return 1;
} }

View File

@ -57,7 +57,7 @@ PhysicalAddressDialog::PhysicalAddressDialog(QWidget *parent) : BaseObjectDialog
{ {
m_dialog = new Ui::PhysAddressDialog_q; m_dialog = new Ui::PhysAddressDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -71,7 +71,7 @@ void PhysicalAddressDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
physAddress *s = dynamic_cast<physAddress*>(obj); physAddress *s = dynamic_cast<physAddress*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init=true; init=true;
@ -105,7 +105,7 @@ void PhysicalAddressDialog::applyChanges()
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
physAddress *s = dynamic_cast<physAddress*>(new_state); physAddress *s = dynamic_cast<physAddress*>(new_state);
assert(s!=NULL); assert(s!=nullptr);
string oldname=obj->getName(); string oldname=obj->getName();
new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) ); new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) );

View File

@ -115,28 +115,28 @@ list<FWObject*> PrintingController::findAllUsedByType(list<FWObject*> &result,
FWObject *obj, FWObject *obj,
const string &type_name) const string &type_name)
{ {
if (RuleElement::cast(obj)!=NULL) if (RuleElement::cast(obj)!=nullptr)
{ {
for (list<FWObject*>::iterator m=obj->begin(); m!=obj->end(); m++) for (list<FWObject*>::iterator m=obj->begin(); m!=obj->end(); m++)
{ {
FWObject *o=*m; FWObject *o=*m;
if (FWReference::cast(o)!=NULL) if (FWReference::cast(o)!=nullptr)
o=FWReference::cast(o)->getPointer(); o=FWReference::cast(o)->getPointer();
if (o->getTypeName()==type_name) if (o->getTypeName()==type_name)
result.push_back(o); result.push_back(o);
} }
} }
if (RuleSet::cast(obj)!=NULL) if (RuleSet::cast(obj)!=nullptr)
{ {
for (list<FWObject*>::iterator m=obj->begin(); m!=obj->end(); m++) for (list<FWObject*>::iterator m=obj->begin(); m!=obj->end(); m++)
{ {
if (Rule::cast(*m)!=NULL) if (Rule::cast(*m)!=nullptr)
{ {
for (list<FWObject*>::iterator n=(*m)->begin(); for (list<FWObject*>::iterator n=(*m)->begin();
n!=(*m)->end(); n++) n!=(*m)->end(); n++)
{ {
if (RuleElement::cast(*n)!=NULL) if (RuleElement::cast(*n)!=nullptr)
{ {
findAllUsedByType(result,*n,type_name); findAllUsedByType(result,*n,type_name);
} }
@ -149,7 +149,7 @@ list<FWObject*> PrintingController::findAllUsedByType(list<FWObject*> &result,
{ {
FWObject *ruleSet; FWObject *ruleSet;
const char* const child_types[] = const char* const child_types[] =
{Policy::TYPENAME, NAT::TYPENAME, Routing::TYPENAME, NULL}; {Policy::TYPENAME, NAT::TYPENAME, Routing::TYPENAME, nullptr};
for (const char* const *cptr = child_types; *cptr; ++cptr) for (const char* const *cptr = child_types; *cptr; ++cptr)
{ {
for (FWObjectTypedChildIterator it = obj->findByType(*cptr); for (FWObjectTypedChildIterator it = obj->findByType(*cptr);
@ -179,9 +179,9 @@ int PrintingController::addObjectsToTable(list<FWObject*> &objects,
for (list<FWObject*>::iterator i=objects.begin(); i!=objects.end(); ++i) for (list<FWObject*>::iterator i=objects.begin(); i!=objects.end(); ++i)
{ {
if (Address::cast(*i)!=NULL && Address::cast(*i)->isAny()) continue; if (Address::cast(*i)!=nullptr && Address::cast(*i)->isAny()) continue;
if (Service::cast(*i)!=NULL && Service::cast(*i)->isAny()) continue; if (Service::cast(*i)!=nullptr && Service::cast(*i)->isAny()) continue;
if (Interval::cast(*i)!=NULL && Interval::cast(*i)->isAny()) continue; if (Interval::cast(*i)!=nullptr && Interval::cast(*i)->isAny()) continue;
if (col>=tbl->columnCount()) if (col>=tbl->columnCount())
{ {
@ -261,8 +261,8 @@ void PrintingController::findAllGroups(list<FWObject*> &objects,
{ {
if (fwbdebug) qDebug(" %s",(*obj)->getName().c_str()); if (fwbdebug) qDebug(" %s",(*obj)->getName().c_str());
FWObject *o = *obj; FWObject *o = *obj;
if (FWReference::cast(o)!=NULL) o=FWReference::cast(o)->getPointer(); if (FWReference::cast(o)!=nullptr) o=FWReference::cast(o)->getPointer();
if (Group::cast(o)!=NULL && if (Group::cast(o)!=nullptr &&
std::find(groups.begin(),groups.end(),o)==groups.end()) std::find(groups.begin(),groups.end(),o)==groups.end())
{ {
groups.push_back(o); groups.push_back(o);
@ -287,7 +287,7 @@ void PrintingController::printRuleSet(FWObject *fw,
pr->printText(name); pr->printText(name);
RuleSetView *ruleView = RuleSetView::getRuleSetViewByType( RuleSetView *ruleView = RuleSetView::getRuleSetViewByType(
project, ruleset, NULL); project, ruleset, nullptr);
ruleView->setSizePolicy( QSizePolicy( (QSizePolicy::Policy)7, ruleView->setSizePolicy( QSizePolicy( (QSizePolicy::Policy)7,
(QSizePolicy::Policy)7) ); (QSizePolicy::Policy)7) );
ruleView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); ruleView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -311,7 +311,7 @@ void PrintingController::printRuleSet(FWObject *fw,
void PrintingController::printFirewall(FWObject *fw, ProjectPanel *project) void PrintingController::printFirewall(FWObject *fw, ProjectPanel *project)
{ {
if (Firewall::cast(fw)==NULL) return ; if (Firewall::cast(fw)==nullptr) return ;
string platform = fw->getStr("platform"); string platform = fw->getStr("platform");
string version = fw->getStr("version"); string version = fw->getStr("version");
@ -328,7 +328,7 @@ void PrintingController::printFirewall(FWObject *fw, ProjectPanel *project)
pr->printText(QObject::tr("Host OS: ") + hostOS.c_str()); pr->printText(QObject::tr("Host OS: ") + hostOS.c_str());
const char* const child_types[] = const char* const child_types[] =
{Policy::TYPENAME, NAT::TYPENAME, Routing::TYPENAME, NULL}; {Policy::TYPENAME, NAT::TYPENAME, Routing::TYPENAME, nullptr};
for (const char* const *cptr = child_types; *cptr; ++cptr) for (const char* const *cptr = child_types; *cptr; ++cptr)
{ {
@ -543,7 +543,7 @@ void PrintingController::printObjects(FWObject *firewall_to_print,
j!=(*obj)->end(); ++j) j!=(*obj)->end(); ++j)
{ {
FWObject *o = *j; FWObject *o = *j;
if (FWReference::cast(o)!=NULL) if (FWReference::cast(o)!=nullptr)
o=FWReference::cast(o)->getPointer(); o=FWReference::cast(o)->getPointer();
groupMembers.push_back(o); groupMembers.push_back(o);
} }

View File

@ -70,17 +70,17 @@ bool ProjectPanel::event(QEvent *event)
<< "rcs:" << "rcs:"
<< rcs << rcs
<< "rcs->getFileName():" << "rcs->getFileName():"
<< QString((rcs!=NULL) ? rcs->getFileName() : "") << QString((rcs!=nullptr) ? rcs->getFileName() : "")
<< "file:" << "file:"
<< data_file << data_file
<< "event:" << "event:"
<< ev->getEventName() << ev->getEventName()
<< "object:" << "object:"
<< ((obj!=NULL) ? QString::fromUtf8(obj->getName().c_str()) : "") << ((obj!=nullptr) ? QString::fromUtf8(obj->getName().c_str()) : "")
<< "(" << ((obj!=NULL) ? obj->getTypeName().c_str() : "") << ")" << "(" << ((obj!=nullptr) ? obj->getTypeName().c_str() : "") << ")"
<< "id=" << ((obj!=NULL) ? obj->getId() : -1); << "id=" << ((obj!=nullptr) ? obj->getId() : -1);
if (event_code == UPDATE_GUI_STATE_EVENT && mdiWindow != NULL) if (event_code == UPDATE_GUI_STATE_EVENT && mdiWindow != nullptr)
{ {
m_panel->om->updateCreateObjectMenu(getCurrentLib()); m_panel->om->updateCreateObjectMenu(getCurrentLib());
ev->accept(); ev->accept();
@ -126,7 +126,7 @@ bool ProjectPanel::event(QEvent *event)
return true; return true;
} }
if (obj == NULL) return false; if (obj == nullptr) return false;
switch (event_code) switch (event_code)
{ {
@ -136,7 +136,7 @@ bool ProjectPanel::event(QEvent *event)
// this purely data structure update event. // this purely data structure update event.
FWObject *p = obj; FWObject *p = obj;
while (p && Firewall::cast(p)==NULL) p = p->getParent(); while (p && Firewall::cast(p)==nullptr) p = p->getParent();
Firewall *f = Firewall::cast(p); Firewall *f = Firewall::cast(p);
// when user locks firewall object, this code tries to // when user locks firewall object, this code tries to
// update last_modified timestamp in it because it // update last_modified timestamp in it because it
@ -157,10 +157,10 @@ bool ProjectPanel::event(QEvent *event)
case UPDATE_OBJECT_EVERYWHERE_EVENT: case UPDATE_OBJECT_EVERYWHERE_EVENT:
{ {
Rule *rule = NULL; Rule *rule = nullptr;
RuleSet* current_ruleset = NULL; RuleSet* current_ruleset = nullptr;
RuleSetView* rsv = getCurrentRuleSetView(); RuleSetView* rsv = getCurrentRuleSetView();
RuleSetModel* md = NULL; RuleSetModel* md = nullptr;
if (rsv) if (rsv)
{ {
md = (RuleSetModel*)rsv->model(); md = (RuleSetModel*)rsv->model();
@ -250,7 +250,7 @@ bool ProjectPanel::event(QEvent *event)
// update events below will only be processed if MDI // update events below will only be processed if MDI
// window exists. // window exists.
if (mdiWindow == NULL) return false; if (mdiWindow == nullptr) return false;
switch (event->type() - QEvent::User) switch (event->type() - QEvent::User)
{ {
@ -326,9 +326,9 @@ bool ProjectPanel::event(QEvent *event)
FWReference *ref = FWReference::cast(obj); FWReference *ref = FWReference::cast(obj);
if (ref) if (ref)
{ {
RuleSet* current_ruleset = NULL; RuleSet* current_ruleset = nullptr;
RuleSetView* rsv = getCurrentRuleSetView(); RuleSetView* rsv = getCurrentRuleSetView();
RuleSetModel* md = NULL; RuleSetModel* md = nullptr;
if (rsv) if (rsv)
{ {
md = (RuleSetModel*)rsv->model(); md = (RuleSetModel*)rsv->model();
@ -343,7 +343,7 @@ bool ProjectPanel::event(QEvent *event)
} else } else
{ {
FWObject *rs = obj; FWObject *rs = obj;
while (rs && RuleSet::cast(rs)==NULL) rs = rs->getParent(); while (rs && RuleSet::cast(rs)==nullptr) rs = rs->getParent();
if (rs) if (rs)
{ {
// reopen rule set right now, before we post event // reopen rule set right now, before we post event
@ -371,9 +371,9 @@ bool ProjectPanel::event(QEvent *event)
Rule *rule = Rule::cast(obj); Rule *rule = Rule::cast(obj);
if (rule) if (rule)
{ {
RuleSet* current_ruleset = NULL; RuleSet* current_ruleset = nullptr;
RuleSetView* rsv = getCurrentRuleSetView(); RuleSetView* rsv = getCurrentRuleSetView();
RuleSetModel* md = NULL; RuleSetModel* md = nullptr;
if (rsv) if (rsv)
{ {
md = (RuleSetModel*)rsv->model(); md = (RuleSetModel*)rsv->model();

View File

@ -116,7 +116,7 @@ bool ProjectPanel::saveIfModified(bool include_discard_button)
switch (QMessageBox::information(this, "Firewall Builder", switch (QMessageBox::information(this, "Firewall Builder",
message, message,
tr("&Save"),tr("&Cancel"), tr("&Save"),tr("&Cancel"),
0, // Enter = button 0 nullptr, // Enter = button 0
1 ) ) // Escape == button 1 1 ) ) // Escape == button 1
{ {
case 0: case 0:
@ -175,7 +175,7 @@ QString ProjectPanel::chooseNewFileName(const QString &fname,
void ProjectPanel::fileProp() void ProjectPanel::fileProp()
{ {
if (rcs!=NULL) if (rcs!=nullptr)
{ {
filePropDialog fpd(this,rcs); filePropDialog fpd(this,rcs);
fpd.setPrinter(mainW->getPrinter()); fpd.setPrinter(mainW->getPrinter());
@ -193,12 +193,12 @@ bool ProjectPanel::fileNew()
if ( !nfn.isEmpty() ) if ( !nfn.isEmpty() )
{ {
//if (!saveIfModified() || !checkin(true)) return; //if (!saveIfModified() || !checkin(true)) return;
if (!systemFile && rcs!=NULL) if (!systemFile && rcs!=nullptr)
fileClose(); // fileClose calls load(this) fileClose(); // fileClose calls load(this)
else else
loadStandardObjects(); loadStandardObjects();
visibleFirewall = NULL; visibleFirewall = nullptr;
setFileName(nfn); setFileName(nfn);
save(); save();
setupAutoSave(); setupAutoSave();
@ -210,10 +210,10 @@ bool ProjectPanel::fileNew()
if (fwbdebug) if (fwbdebug)
qDebug("ProjectPanel::fileNew() rcs=%p rcs->getFileName()='%s'", qDebug("ProjectPanel::fileNew() rcs=%p rcs->getFileName()='%s'",
rcs, rcs == 0 ? "<null>" : rcs, rcs == nullptr ? "<null>" :
rcs->getFileName().toLatin1().constData()); rcs->getFileName().toLatin1().constData());
return (rcs!=NULL); return (rcs!=nullptr);
} }
bool ProjectPanel::loadFile(const QString &fileName, bool load_rcs_head) bool ProjectPanel::loadFile(const QString &fileName, bool load_rcs_head)
@ -241,7 +241,7 @@ bool ProjectPanel::loadFile(const QString &fileName, bool load_rcs_head)
if (!saveIfModified() || !checkin(true)) return false; if (!saveIfModified() || !checkin(true)) return false;
if (!systemFile && rcs!=NULL) if (!systemFile && rcs!=nullptr)
{ {
if (mw->isEditorVisible()) mw->hideEditor(); if (mw->isEditorVisible()) mw->hideEditor();
reset(); reset();
@ -252,8 +252,8 @@ bool ProjectPanel::loadFile(const QString &fileName, bool load_rcs_head)
//if preview cannot give RCS, //if preview cannot give RCS,
//get a new RCS from file dialog //get a new RCS from file dialog
if (new_rcs==NULL) new_rcs = new RCS(fileName); if (new_rcs==nullptr) new_rcs = new RCS(fileName);
if (new_rcs==NULL) return false; if (new_rcs==nullptr) return false;
try try
{ {
@ -334,7 +334,7 @@ void ProjectPanel::fileSaveAs()
{ {
db()->setDirty(false); // so it wont ask if user wants to save db()->setDirty(false); // so it wont ask if user wants to save
rcs->abandon(); rcs->abandon();
if (rcs!=NULL) delete rcs; if (rcs!=nullptr) delete rcs;
rcs = new RCS(""); rcs = new RCS("");
setFileName(newFileName); setFileName(newFileName);
save(); save();
@ -381,13 +381,13 @@ void ProjectPanel::fileDiscard()
if (mw->isEditorVisible()) mw->hideEditor(); if (mw->isEditorVisible()) mw->hideEditor();
if (rcs) delete rcs; if (rcs) delete rcs;
rcs=NULL; rcs=nullptr;
FWObjectClipboard::obj_clipboard->clear(); FWObjectClipboard::obj_clipboard->clear();
firewalls.clear(); firewalls.clear();
visibleFirewall = NULL; visibleFirewall = nullptr;
visibleRuleSet = NULL; visibleRuleSet = nullptr;
clearFirewallTabs(); clearFirewallTabs();
clearObjects(); clearObjects();
@ -715,20 +715,20 @@ bool ProjectPanel::exportLibraryTest(list<FWObject*> &selectedLibs)
if (std::find(selectedLibs.begin(),selectedLibs.end(),tgtlib)!=selectedLibs.end()) continue; if (std::find(selectedLibs.begin(),selectedLibs.end(),tgtlib)!=selectedLibs.end()) continue;
if (RuleElement::cast(pp)!=NULL) if (RuleElement::cast(pp)!=nullptr)
{ {
FWObject *fw = pp; FWObject *fw = pp;
FWObject *rule = pp; FWObject *rule = pp;
FWObject *ruleset = pp; FWObject *ruleset = pp;
FWObject *iface = pp; FWObject *iface = pp;
while (rule!=NULL && Rule::cast(rule)==NULL) while (rule!=nullptr && Rule::cast(rule)==nullptr)
rule=rule->getParent(); rule=rule->getParent();
while (ruleset!=NULL && RuleSet::cast(ruleset)==NULL) while (ruleset!=nullptr && RuleSet::cast(ruleset)==nullptr)
ruleset=ruleset->getParent(); ruleset=ruleset->getParent();
while (iface!=NULL && Interface::cast(iface)==NULL) while (iface!=nullptr && Interface::cast(iface)==nullptr)
iface=iface->getParent(); iface=iface->getParent();
while (fw!=NULL && Firewall::cast(fw)==NULL) while (fw!=nullptr && Firewall::cast(fw)==nullptr)
fw=fw->getParent(); fw=fw->getParent();
s = QObject::tr("Library %1: Firewall '%2' (%3 rule #%4) uses " s = QObject::tr("Library %1: Firewall '%2' (%3 rule #%4) uses "
@ -814,7 +814,7 @@ void ProjectPanel::exportLibraryTo(QString fname,list<FWObject*> &selectedLibs,
void ProjectPanel::setupAutoSave() void ProjectPanel::setupAutoSave()
{ {
if ( st->getBool("Environment/autoSaveFile") && if ( st->getBool("Environment/autoSaveFile") &&
rcs!=NULL && rcs->getFileName()!="") rcs!=nullptr && rcs->getFileName()!="")
{ {
int p = st->getInt("Environment/autoSaveFilePeriod"); int p = st->getInt("Environment/autoSaveFilePeriod");
autosaveTimer->start( p*1000*60 ); autosaveTimer->start( p*1000*60 );
@ -828,7 +828,7 @@ void ProjectPanel::findExternalRefs(FWObject *lib,
list<FWReference*> &extRefs) list<FWReference*> &extRefs)
{ {
FWReference *ref=FWReference::cast(root); FWReference *ref=FWReference::cast(root);
if (ref!=NULL) if (ref!=nullptr)
{ {
FWObject *plib = ref->getPointer()->getLibrary(); FWObject *plib = ref->getPointer()->getLibrary();
if ( plib->getId()!=FWObjectDatabase::STANDARD_LIB_ID && if ( plib->getId()!=FWObjectDatabase::STANDARD_LIB_ID &&
@ -851,7 +851,7 @@ void ProjectPanel::findExternalRefs(FWObject *lib,
FWObject* ProjectPanel::loadLibrary(const string &libfpath) FWObject* ProjectPanel::loadLibrary(const string &libfpath)
{ {
MessageBoxUpgradePredicate upgrade_predicate(mainW); MessageBoxUpgradePredicate upgrade_predicate(mainW);
FWObject *last_new_lib = NULL; FWObject *last_new_lib = nullptr;
try try
{ {
@ -869,7 +869,7 @@ FWObject* ProjectPanel::loadLibrary(const string &libfpath)
++it) ++it)
{ {
FWObject *obj = ndb->findInIndex(*it); FWObject *obj = ndb->findInIndex(*it);
assert(obj!=NULL); assert(obj!=nullptr);
int new_id = FWObjectDatabase::generateUniqueId(); int new_id = FWObjectDatabase::generateUniqueId();
obj->setId(new_id); obj->setId(new_id);
id_mapping[*it] = new_id; id_mapping[*it] = new_id;
@ -1007,7 +1007,7 @@ bool ProjectPanel::loadFromRCS(RCS *_rcs)
MessageBoxUpgradePredicate upgrade_predicate(mainW); MessageBoxUpgradePredicate upgrade_predicate(mainW);
assert(_rcs!=NULL); assert(_rcs!=nullptr);
rcs = _rcs; rcs = _rcs;
try try
@ -1106,7 +1106,7 @@ bool ProjectPanel::loadFromRCS(RCS *_rcs)
* read-only. * read-only.
*/ */
FWObject *slib = objdb->findInIndex(FWObjectDatabase::STANDARD_LIB_ID); FWObject *slib = objdb->findInIndex(FWObjectDatabase::STANDARD_LIB_ID);
if (slib!=NULL ) if (slib!=nullptr )
{ {
if (fwbdebug) if (fwbdebug)
qDebug("standard library read-only status: %d, " qDebug("standard library read-only status: %d, "
@ -1310,7 +1310,7 @@ bool ProjectPanel::checkin(bool unlock)
/* doing checkin only if we did checkout so rcs!=NULL */ /* doing checkin only if we did checkout so rcs!=NULL */
QString rlog=""; QString rlog="";
if (systemFile || rcs==NULL || !rcs->isCheckedOut() || rcs->isTemp()) if (systemFile || rcs==nullptr || !rcs->isCheckedOut() || rcs->isTemp())
return true; return true;
if (rcs->isDiff()) if (rcs->isDiff())

View File

@ -50,7 +50,7 @@ using namespace std;
void ProjectPanel::saveState() void ProjectPanel::saveState()
{ {
QString file_name ; QString file_name ;
if (rcs!=NULL) file_name = rcs->getFileName(); if (rcs!=nullptr) file_name = rcs->getFileName();
if (fwbdebug) if (fwbdebug)
qDebug( ) << "ProjectPanel::saveState " << this qDebug( ) << "ProjectPanel::saveState " << this
<< "title " << mdiWindow->windowTitle() << "title " << mdiWindow->windowTitle()
@ -83,7 +83,7 @@ void ProjectPanel::saveState()
void ProjectPanel::loadState(bool) void ProjectPanel::loadState(bool)
{ {
if (rcs==NULL) return; if (rcs==nullptr) return;
QString filename = rcs->getFileName(); QString filename = rcs->getFileName();
// This function can end up being called recursively because some // This function can end up being called recursively because some
@ -106,7 +106,7 @@ void ProjectPanel::loadState(bool)
if (!mdiWindow->isMaximized() && mdiWindow) if (!mdiWindow->isMaximized() && mdiWindow)
{ {
if (fwbdebug) qDebug("ProjectPanel::loadState show normal"); if (fwbdebug) qDebug("ProjectPanel::loadState show normal");
setWindowState(0); setWindowState(nullptr);
int x = st->getInt("Window/"+filename+"/x"); int x = st->getInt("Window/"+filename+"/x");
int y = st->getInt("Window/"+filename+"/y"); int y = st->getInt("Window/"+filename+"/y");
int width = st->getInt("Window/"+filename+"/width"); int width = st->getInt("Window/"+filename+"/width");
@ -144,7 +144,7 @@ void ProjectPanel::loadState(bool)
void ProjectPanel::saveMainSplitter() void ProjectPanel::saveMainSplitter()
{ {
QString fileName ; QString fileName ;
if (rcs!=NULL) fileName = rcs->getFileName(); if (rcs!=nullptr) fileName = rcs->getFileName();
#ifdef TREE_IS_DOCKABLE #ifdef TREE_IS_DOCKABLE
// Save position of splitters regardless of the window state // Save position of splitters regardless of the window state
@ -182,7 +182,7 @@ void ProjectPanel::saveMainSplitter()
void ProjectPanel::loadMainSplitter() void ProjectPanel::loadMainSplitter()
{ {
QString fileName ; QString fileName ;
if (rcs!=NULL) fileName = rcs->getFileName(); if (rcs!=nullptr) fileName = rcs->getFileName();
if (fwbdebug) if (fwbdebug)
qDebug() << QString("ProjectPanel::loadMainSplitter() filename=%1") qDebug() << QString("ProjectPanel::loadMainSplitter() filename=%1")
@ -242,10 +242,10 @@ void ProjectPanel::collapseRules()
void ProjectPanel::loadOpenedRuleSet() void ProjectPanel::loadOpenedRuleSet()
{ {
if (rcs==NULL) return; if (rcs==nullptr) return;
QString filename = rcs->getFileName(); QString filename = rcs->getFileName();
if (m_panel->om->getCurrentLib() == NULL) return; if (m_panel->om->getCurrentLib() == nullptr) return;
int id = st->getVisibleRuleSetId( int id = st->getVisibleRuleSetId(
filename, m_panel->om->getCurrentLib()->getName().c_str()); filename, m_panel->om->getCurrentLib()->getName().c_str());
@ -276,10 +276,10 @@ void ProjectPanel::loadOpenedRuleSet()
void ProjectPanel::saveOpenedRuleSet() void ProjectPanel::saveOpenedRuleSet()
{ {
if (rcs==NULL) return; if (rcs==nullptr) return;
QString filename = rcs->getFileName(); QString filename = rcs->getFileName();
if (visibleRuleSet!=NULL) if (visibleRuleSet!=nullptr)
{ {
st->setVisibleRuleSet(filename, st->setVisibleRuleSet(filename,
visibleRuleSet->getLibrary()->getName().c_str(), visibleRuleSet->getLibrary()->getName().c_str(),
@ -291,10 +291,10 @@ void ProjectPanel::saveOpenedRuleSet()
void ProjectPanel::saveLastOpenedLib() void ProjectPanel::saveLastOpenedLib()
{ {
QString filename = ""; QString filename = "";
if (rcs!=NULL) filename = rcs->getFileName(); if (rcs!=nullptr) filename = rcs->getFileName();
FWObject* obj = m_panel->om->getCurrentLib(); FWObject* obj = m_panel->om->getCurrentLib();
if (obj!=NULL) if (obj!=nullptr)
{ {
std::string sid = FWObjectDatabase::getStringId(obj->getId()); std::string sid = FWObjectDatabase::getStringId(obj->getId());
st->setStr("Window/" + filename + "/LastLib", sid.c_str() ); st->setStr("Window/" + filename + "/LastLib", sid.c_str() );
@ -307,7 +307,7 @@ void ProjectPanel::loadLastOpenedLib()
if (fwbdebug) qDebug("ProjectPanel::loadLastOpenedLib()"); if (fwbdebug) qDebug("ProjectPanel::loadLastOpenedLib()");
QString filename = ""; QString filename = "";
if (rcs!=NULL) filename = rcs->getFileName(); if (rcs!=nullptr) filename = rcs->getFileName();
QString sid = st->getStr("Window/" + filename + "/LastLib"); QString sid = st->getStr("Window/" + filename + "/LastLib");
if (filename!="" && sid!="") if (filename!="" && sid!="")
{ {
@ -334,7 +334,7 @@ void ProjectPanel::loadLastOpenedLib()
void ProjectPanel::loadFirstNonStandardLib() void ProjectPanel::loadFirstNonStandardLib()
{ {
list<FWObject*> all_libs = db()->getByType(Library::TYPENAME); list<FWObject*> all_libs = db()->getByType(Library::TYPENAME);
FWObject *first_non_system_lib = NULL; FWObject *first_non_system_lib = nullptr;
for (list<FWObject*>::iterator i=all_libs.begin(); i!=all_libs.end(); ++i) for (list<FWObject*>::iterator i=all_libs.begin(); i!=all_libs.end(); ++i)
{ {
int lib_id = (*i)->getId(); int lib_id = (*i)->getId();
@ -342,7 +342,7 @@ void ProjectPanel::loadFirstNonStandardLib()
if (lib_id == FWObjectDatabase::STANDARD_LIB_ID) continue; if (lib_id == FWObjectDatabase::STANDARD_LIB_ID) continue;
if (lib_id == FWObjectDatabase::TEMPLATE_LIB_ID) continue; if (lib_id == FWObjectDatabase::TEMPLATE_LIB_ID) continue;
if (first_non_system_lib==NULL) first_non_system_lib = (*i); if (first_non_system_lib==nullptr) first_non_system_lib = (*i);
if ((*i)->getName()=="User") if ((*i)->getName()=="User")
{ {
first_non_system_lib = *i; first_non_system_lib = *i;

View File

@ -83,7 +83,7 @@ RCSFilePreview::RCSFilePreview(QWidget *parent): QDialog(parent)
if (fwbdebug) qDebug("RCSFilePreview: constructor done"); if (fwbdebug) qDebug("RCSFilePreview: constructor done");
rcs = NULL; rcs = nullptr;
RO = false; RO = false;
} }
@ -96,7 +96,7 @@ RCSFilePreview::~RCSFilePreview()
void RCSFilePreview::openReadOnly() void RCSFilePreview::openReadOnly()
{ {
if (rcs!=NULL) rcs->setRO(true); if (rcs!=nullptr) rcs->setRO(true);
RO = true; RO = true;
accept(); accept();
} }
@ -111,7 +111,7 @@ void RCSFilePreview::selectedRevision(QTreeWidgetItem *itm)
if (itm == m_widget->RCSTreeView->topLevelItem(0)) return; if (itm == m_widget->RCSTreeView->topLevelItem(0)) return;
QString rev = itm->text(0); QString rev = itm->text(0);
assert(rcs!=NULL); assert(rcs!=nullptr);
rcs->setSelectedRev(rev); rcs->setSelectedRev(rev);
m_widget->comment->setText( rcsComments[rev] ); m_widget->comment->setText( rcsComments[rev] );
if (fwbdebug) if (fwbdebug)
@ -131,7 +131,7 @@ bool RCSFilePreview::showFileRLog( const QString &filename )
m_widget->RCSTreeView->clear(); m_widget->RCSTreeView->clear();
if (rcs!=NULL) delete rcs; if (rcs!=nullptr) delete rcs;
rcs = new RCS(filename); rcs = new RCS(filename);
if (rcs->revisions.size()==0) if (rcs->revisions.size()==0)
@ -155,8 +155,8 @@ bool RCSFilePreview::showFileRLog( const QString &filename )
QList<Revision>::iterator i; QList<Revision>::iterator i;
QList<RCSViewItem*> itemList; QList<RCSViewItem*> itemList;
QList<RCSViewItem*>::iterator ili; QList<RCSViewItem*>::iterator ili;
RCSViewItem* latest_revision_item = NULL; RCSViewItem* latest_revision_item = nullptr;
RCSViewItem* latest_date_item = NULL; RCSViewItem* latest_date_item = nullptr;
string latest_revision = "1.0"; string latest_revision = "1.0";
QString latest_date = ""; QString latest_date = "";
@ -164,7 +164,7 @@ bool RCSFilePreview::showFileRLog( const QString &filename )
{ {
rcsComments[(*i).rev] = (*i).log; rcsComments[(*i).rev] = (*i).log;
RCSViewItem *itm = NULL; RCSViewItem *itm = nullptr;
if (st->getRCSFilePreviewStyle()==1) if (st->getRCSFilePreviewStyle()==1)
{ {
// List style // List style
@ -187,7 +187,7 @@ bool RCSFilePreview::showFileRLog( const QString &filename )
if ((*ili)->text(0) == branch_root) if ((*ili)->text(0) == branch_root)
{ {
QTreeWidgetItem *br = *ili; QTreeWidgetItem *br = *ili;
if (br!=NULL) itm = addRevision((*i), br); if (br!=nullptr) itm = addRevision((*i), br);
} }
} }
} }
@ -222,7 +222,7 @@ bool RCSFilePreview::showFileRLog( const QString &filename )
SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
this, SLOT(selectedRevision(QTreeWidgetItem*))); this, SLOT(selectedRevision(QTreeWidgetItem*)));
RCSViewItem* show_item = NULL; RCSViewItem* show_item = nullptr;
if (m_widget->RCSTreeView->sortColumn()==0 && latest_revision_item) if (m_widget->RCSTreeView->sortColumn()==0 && latest_revision_item)
show_item = latest_revision_item; show_item = latest_revision_item;

View File

@ -81,7 +81,7 @@ RuleOptionsDialog::RuleOptionsDialog(QWidget *parent) :
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
firewall = NULL; firewall = nullptr;
init=false; init=false;
} }
@ -425,7 +425,7 @@ void RuleOptionsDialog::applyChanges()
{ {
FWObject *tag_object = m_dialog->iptTagDropArea->getObject(); FWObject *tag_object = m_dialog->iptTagDropArea->getObject();
// if tag_object==NULL, setTagObject clears setting in the rule // if tag_object==NULL, setTagObject clears setting in the rule
policy_rule->setTagging(tag_object != NULL); policy_rule->setTagging(tag_object != nullptr);
policy_rule->setTagObject(tag_object); policy_rule->setTagObject(tag_object);
policy_rule->setClassification( policy_rule->setClassification(
@ -440,7 +440,7 @@ void RuleOptionsDialog::applyChanges()
{ {
FWObject *tag_object = m_dialog->pfTagDropArea->getObject(); FWObject *tag_object = m_dialog->pfTagDropArea->getObject();
// if tag_object==NULL, setTagObject clears setting in the rule // if tag_object==NULL, setTagObject clears setting in the rule
policy_rule->setTagging(tag_object != NULL); policy_rule->setTagging(tag_object != nullptr);
policy_rule->setTagObject(tag_object); policy_rule->setTagObject(tag_object);
policy_rule->setClassification( policy_rule->setClassification(

View File

@ -91,7 +91,7 @@ RuleSetDiffDialog::RuleSetDiffDialog(ProjectPanel *project, QWidget *parent) :
Library* RuleSetDiffDialog::findUserLibrary(FWObjectDatabase *db) Library* RuleSetDiffDialog::findUserLibrary(FWObjectDatabase *db)
{ {
Library *lib = NULL; Library *lib = nullptr;
foreach (FWObject *obj, db->getByType(Library::TYPENAME)) foreach (FWObject *obj, db->getByType(Library::TYPENAME))
{ {
if (obj->getName() == "User") if (obj->getName() == "User")

View File

@ -209,7 +209,7 @@ void RuleSetViewDelegate::paintRule(QPainter *painter,
QVariant v = index.data(Qt::DisplayRole); QVariant v = index.data(Qt::DisplayRole);
if (!v.isValid()) return; if (!v.isValid()) return;
if (node != 0) if (node != nullptr)
{ {
QString color = getRuleColor(node); QString color = getRuleColor(node);
if (!color.isEmpty()) if (!color.isEmpty())
@ -352,7 +352,7 @@ void RuleSetViewDelegate::paintObject(
//if (fwbdebug) qDebug() << "RuleSetViewDelegate::paintObject"; //if (fwbdebug) qDebug() << "RuleSetViewDelegate::paintObject";
RuleElement *re = (RuleElement *)v.value<void *>(); RuleElement *re = (RuleElement *)v.value<void *>();
if (re==NULL) return; if (re==nullptr) return;
DrawingContext ctx = initContext(option.rect, true); DrawingContext ctx = initContext(option.rect, true);
@ -361,7 +361,7 @@ void RuleSetViewDelegate::paintObject(
for (FWObject::iterator i=re->begin(); i!=re->end(); i++) for (FWObject::iterator i=re->begin(); i!=re->end(); i++)
{ {
FWObject *o1 = FWReference::getObject(*i); FWObject *o1 = FWReference::getObject(*i);
if (o1==NULL) continue ; if (o1==nullptr) continue ;
QRect itemRect = QRect(ctx.objectRect.left(), y, ctx.objectRect.width(), ctx.itemHeight); QRect itemRect = QRect(ctx.objectRect.left(), y, ctx.objectRect.width(), ctx.itemHeight);
@ -578,7 +578,7 @@ QSize RuleSetViewDelegate::calculateCellSizeForComment(const QModelIndex & index
QSize RuleSetViewDelegate::calculateCellSizeForObject(const QModelIndex & index) const QSize RuleSetViewDelegate::calculateCellSizeForObject(const QModelIndex & index) const
{ {
RuleElement *re = (RuleElement *)index.data(Qt::DisplayRole).value<void *>(); RuleElement *re = (RuleElement *)index.data(Qt::DisplayRole).value<void *>();
if (re == 0) return QSize(0,0); if (re == nullptr) return QSize(0,0);
int itemHeight = getItemHeight(); int itemHeight = getItemHeight();
QSize iconSize = getIconSize(); QSize iconSize = getIconSize();
@ -591,12 +591,12 @@ QSize RuleSetViewDelegate::calculateCellSizeForObject(const QModelIndex & index)
FWObject *o1= *j; FWObject *o1= *j;
FWObject *o2 = o1; FWObject *o2 = o1;
string o1ref = ""; string o1ref = "";
if (FWReference::cast(o1)!=NULL) if (FWReference::cast(o1)!=nullptr)
{ {
o1ref = FWReference::cast(o1)->getPointerId(); o1ref = FWReference::cast(o1)->getPointerId();
o2=FWReference::cast(o1)->getPointer(); o2=FWReference::cast(o1)->getPointer();
} }
if (o2!=NULL) if (o2!=nullptr)
{ {
QString ot = objectText(re,o2); QString ot = objectText(re,o2);

View File

@ -73,7 +73,7 @@ StartTipDialog::StartTipDialog(QWidget *parent): QDialog(parent)
// we use separate Help() object for the tip of the day becayse it should // we use separate Help() object for the tip of the day becayse it should
// have different size and should not be persistent // have different size and should not be persistent
Help *h = new Help(NULL, ""); Help *h = new Help(nullptr, "");
int tip_no = 1; int tip_no = 1;
while (true) while (true)
{ {

View File

@ -56,7 +56,7 @@ TCPServiceDialog::TCPServiceDialog(QWidget *parent) : BaseObjectDialog(parent)
m_dialog = new Ui::TCPServiceDialog_q; m_dialog = new Ui::TCPServiceDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -70,7 +70,7 @@ void TCPServiceDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
TCPService *s = dynamic_cast<TCPService*>(obj); TCPService *s = dynamic_cast<TCPService*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init=true; init=true;

View File

@ -64,7 +64,7 @@ TagServiceDialog::TagServiceDialog(QWidget *parent) : BaseObjectDialog(parent)
{ {
m_dialog = new Ui::TagServiceDialog_q; m_dialog = new Ui::TagServiceDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -73,7 +73,7 @@ void TagServiceDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
TagService *s = dynamic_cast<TagService*>(obj); TagService *s = dynamic_cast<TagService*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init=true; init=true;
@ -98,7 +98,7 @@ void TagServiceDialog::validate(bool *res)
{ {
*res=true; *res=true;
TagService *s = dynamic_cast<TagService*>(obj); TagService *s = dynamic_cast<TagService*>(obj);
assert(s!=NULL); assert(s!=nullptr);
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; } if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
} }
@ -111,7 +111,7 @@ void TagServiceDialog::applyChanges()
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
TagService *s = dynamic_cast<TagService*>(new_state); TagService *s = dynamic_cast<TagService*>(new_state);
assert(s!=NULL); assert(s!=nullptr);
string oldname = obj->getName(); string oldname = obj->getName();
new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) ); new_state->setName( string(m_dialog->obj_name->text().toUtf8().constData()) );

View File

@ -32,10 +32,10 @@
#include <QFile> #include <QFile>
#include "FWBApplication.h" #include "FWBApplication.h"
TutorialDialog * TutorialDialog::dialog = NULL; TutorialDialog * TutorialDialog::dialog = nullptr;
TutorialDialog::TutorialDialog(QString tutorial, QWidget *parent) : TutorialDialog::TutorialDialog(QString tutorial, QWidget *parent) :
QDialog(NULL), QDialog(nullptr),
ui(new Ui::TutorialDialog_q) ui(new Ui::TutorialDialog_q)
{ {
Q_UNUSED(parent) Q_UNUSED(parent)
@ -50,7 +50,7 @@ TutorialDialog::TutorialDialog(QString tutorial, QWidget *parent) :
void TutorialDialog::showTutorial(QString tutorial) void TutorialDialog::showTutorial(QString tutorial)
{ {
if (dialog != NULL) if (dialog != nullptr)
{ {
dialog->initializeTutorial(tutorial); dialog->initializeTutorial(tutorial);
dialog->showNormal(); dialog->showNormal();

View File

@ -55,7 +55,7 @@ UDPServiceDialog::UDPServiceDialog(QWidget *parent) : BaseObjectDialog(parent)
m_dialog = new Ui::UDPServiceDialog_q; m_dialog = new Ui::UDPServiceDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -69,7 +69,7 @@ void UDPServiceDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
UDPService *s = dynamic_cast<UDPService*>(obj); UDPService *s = dynamic_cast<UDPService*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init=true; init=true;

View File

@ -56,7 +56,7 @@ UserDialog::UserDialog(QWidget *parent) : BaseObjectDialog(parent)
{ {
m_dialog = new Ui::UserDialog_q; m_dialog = new Ui::UserDialog_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
obj=NULL; obj=nullptr;
connectSignalsOfAllWidgetsToSlotChange(); connectSignalsOfAllWidgetsToSlotChange();
} }
@ -67,7 +67,7 @@ void UserDialog::loadFWObject(FWObject *o)
{ {
obj=o; obj=o;
UserService *s = dynamic_cast<UserService*>(obj); UserService *s = dynamic_cast<UserService*>(obj);
assert(s!=NULL); assert(s!=nullptr);
init=true; init=true;
@ -94,7 +94,7 @@ void UserDialog::validate(bool *res)
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; } if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
UserService *s = dynamic_cast<UserService*>(obj); UserService *s = dynamic_cast<UserService*>(obj);
assert(s!=NULL); assert(s!=nullptr);
} }
@ -105,7 +105,7 @@ void UserDialog::applyChanges()
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
UserService *s = dynamic_cast<UserService*>(new_state); UserService *s = dynamic_cast<UserService*>(new_state);
assert(s!=NULL); assert(s!=nullptr);
string oldname = obj->getName(); string oldname = obj->getName();
s->setName( string(m_dialog->obj_name->text().toUtf8().constData()) ); s->setName( string(m_dialog->obj_name->text().toUtf8().constData()) );

View File

@ -52,7 +52,7 @@ bsdIfaceOptsDialog::bsdIfaceOptsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *ifopt = (Interface::cast(obj))->getOptionsObject(); FWOptions *ifopt = (Interface::cast(obj))->getOptionsObject();
cluster_interface = (Cluster::cast(obj->getParent()) != NULL); cluster_interface = (Cluster::cast(obj->getParent()) != nullptr);
setInterfaceTypes(m_dialog->iface_type, Interface::cast(obj), setInterfaceTypes(m_dialog->iface_type, Interface::cast(obj),
ifopt->getStr("type").c_str()); ifopt->getStr("type").c_str());
@ -108,7 +108,7 @@ void bsdIfaceOptsDialog::accept()
// new_state is a copy of the interface object // new_state is a copy of the interface object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* ifopt = Interface::cast(new_state)->getOptionsObject(); FWOptions* ifopt = Interface::cast(new_state)->getOptionsObject();
assert(ifopt!=NULL); assert(ifopt!=nullptr);
if (cluster_interface) if (cluster_interface)
{ {

View File

@ -52,7 +52,7 @@ carpOptionsDialog::carpOptionsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *gropt = FWOptions::cast(obj); FWOptions *gropt = FWOptions::cast(obj);
assert(gropt != NULL); assert(gropt != nullptr);
data.registerOption(m_dialog->carp_password, data.registerOption(m_dialog->carp_password,
gropt, gropt,

View File

@ -60,14 +60,14 @@ clusterMembersDialog::clusterMembersDialog(QWidget *parent, FWObject *o)
// if empty, retry with parent of parent (interface level) // if empty, retry with parent of parent (interface level)
if (host_os.isEmpty()) if (host_os.isEmpty())
{ {
FWObject *parent = NULL; FWObject *parent = nullptr;
parent = obj->getParent(); parent = obj->getParent();
if (parent == NULL) if (parent == nullptr)
{ {
throw FWException("clusterMembersDialog: parent is NULL!"); throw FWException("clusterMembersDialog: parent is NULL!");
} }
parent = parent->getParent(); parent = parent->getParent();
if (parent == NULL) if (parent == nullptr)
{ {
throw FWException("clusterMembersDialog: parent is NULL!"); throw FWException("clusterMembersDialog: parent is NULL!");
} }
@ -120,9 +120,9 @@ void clusterMembersDialog::getSelectedMembers()
{ {
// get fw and interface pointer from interface reference // get fw and interface pointer from interface reference
Interface *iface = NULL; Interface *iface = nullptr;
iface = Interface::cast(FWReference::cast((*it))->getPointer()); iface = Interface::cast(FWReference::cast((*it))->getPointer());
assert(iface != NULL); assert(iface != nullptr);
Firewall *fw = Firewall::cast(Host::getParentHost(iface)); Firewall *fw = Firewall::cast(Host::getParentHost(iface));
//Firewall *fw = Firewall::cast(iface->getParentHost()); //Firewall *fw = Firewall::cast(iface->getParentHost());
@ -135,7 +135,7 @@ void clusterMembersDialog::getSelectedMembers()
} }
// create ClusterMember object // create ClusterMember object
ClusterMember *new_member = createMember(fw, iface, master); ClusterMember *new_member = createMember(fw, iface, master);
if (new_member == NULL) if (new_member == nullptr)
{ {
qWarning() << "clusterMembersDialog: could not create new " qWarning() << "clusterMembersDialog: could not create new "
"cluster member"; "cluster member";
@ -183,7 +183,7 @@ void clusterMembersDialog::getPossibleMembers()
// valid member, add to member list // valid member, add to member list
ClusterMember *new_member = createMember(fw); ClusterMember *new_member = createMember(fw);
if (new_member == NULL) if (new_member == nullptr)
{ {
qWarning() << "clusterMembersDialog: could not create new " qWarning() << "clusterMembersDialog: could not create new "
"cluster member"; "cluster member";
@ -200,7 +200,7 @@ void clusterMembersDialog::updateSelectedTable()
table_update = true; table_update = true;
m_dialog->fwSelectedTable->setRowCount(selected.size()); m_dialog->fwSelectedTable->setRowCount(selected.size());
QTableWidgetItem *item = NULL; QTableWidgetItem *item = nullptr;
int row = 0; int row = 0;
for (t_memberList::const_iterator it = selected.begin(); for (t_memberList::const_iterator it = selected.begin();
it != selected.end(); it++) it != selected.end(); it++)
@ -211,7 +211,7 @@ void clusterMembersDialog::updateSelectedTable()
item = m_dialog->fwSelectedTable->item(row, 0); item = m_dialog->fwSelectedTable->item(row, 0);
const char *new_text = (*it)->fwobj->getName().c_str(); const char *new_text = (*it)->fwobj->getName().c_str();
if (item == NULL) if (item == nullptr)
{ {
item = new QTableWidgetItem; item = new QTableWidgetItem;
item->setText(new_text); item->setText(new_text);
@ -226,7 +226,7 @@ void clusterMembersDialog::updateSelectedTable()
// Column "Interface" // Column "Interface"
item = m_dialog->fwSelectedTable->item(row, 1); item = m_dialog->fwSelectedTable->item(row, 1);
new_text = (*it)->iface_cluster->getName().c_str(); new_text = (*it)->iface_cluster->getName().c_str();
if (item == NULL) if (item == nullptr)
{ {
item = new QTableWidgetItem; item = new QTableWidgetItem;
item->setText(new_text); item->setText(new_text);
@ -241,7 +241,7 @@ void clusterMembersDialog::updateSelectedTable()
// Column "Master" // Column "Master"
item = m_dialog->fwSelectedTable->item(row, 2); item = m_dialog->fwSelectedTable->item(row, 2);
Qt::CheckState state = (*it)->is_master ? Qt::Checked : Qt::Unchecked; Qt::CheckState state = (*it)->is_master ? Qt::Checked : Qt::Unchecked;
if (item == NULL) if (item == nullptr)
{ {
item = new QTableWidgetItem; item = new QTableWidgetItem;
item->setCheckState(state); item->setCheckState(state);
@ -305,15 +305,15 @@ ClusterMember*
clusterMembersDialog::createMember(Firewall *fw, clusterMembersDialog::createMember(Firewall *fw,
Interface *cluster_iface, bool master) Interface *cluster_iface, bool master)
{ {
if (fw == NULL) if (fw == nullptr)
{ {
return NULL; return nullptr;
} }
ClusterMember *new_member = new ClusterMember; ClusterMember *new_member = new ClusterMember;
new_member->fwobj = fw; new_member->fwobj = fw;
new_member->is_master = master; new_member->is_master = master;
if (cluster_iface != NULL) if (cluster_iface != nullptr)
{ {
new_member->iface_cluster = cluster_iface; new_member->iface_cluster = cluster_iface;
} }

View File

@ -50,13 +50,13 @@ conntrackOptionsDialog::conntrackOptionsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *gropt = FWOptions::cast(obj); FWOptions *gropt = FWOptions::cast(obj);
assert(gropt != NULL); assert(gropt != nullptr);
FWObject *p = obj; FWObject *p = obj;
while (p && Cluster::cast(p)==NULL) p = p->getParent(); while (p && Cluster::cast(p)==nullptr) p = p->getParent();
assert(p != NULL); assert(p != nullptr);
Cluster *cluster = Cluster::cast(p); Cluster *cluster = Cluster::cast(p);
Resources *os_res = Resources::os_res[cluster->getStr("host_OS")]; Resources *os_res = Resources::os_res[cluster->getStr("host_OS")];
assert(os_res != NULL); assert(os_res != nullptr);
string default_address = string default_address =
os_res->getResourceStr("/FWBuilderResources/Target/protocols/conntrack/default_address"); os_res->getResourceStr("/FWBuilderResources/Target/protocols/conntrack/default_address");
@ -125,7 +125,7 @@ bool conntrackOptionsDialog::validate()
QMessageBox::critical( QMessageBox::critical(
this, "Firewall Builder", this, "Firewall Builder",
tr("Invalid IP address '%1'").arg(m_dialog->conntrack_address->text()), tr("Invalid IP address '%1'").arg(m_dialog->conntrack_address->text()),
tr("&Continue"), 0, 0, tr("&Continue"), nullptr, nullptr,
0 ); 0 );
return false; return false;
} }

View File

@ -60,10 +60,10 @@ freebsdAdvancedDialog::freebsdAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
QStringList threeStateMapping; QStringList threeStateMapping;
@ -117,7 +117,7 @@ void freebsdAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions *fwopt=(Firewall::cast(new_state))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(new_state))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
data.saveAll(fwopt); data.saveAll(fwopt);

View File

@ -50,13 +50,13 @@ heartbeatOptionsDialog::heartbeatOptionsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *gropt = FWOptions::cast(obj); FWOptions *gropt = FWOptions::cast(obj);
assert(gropt != NULL); assert(gropt != nullptr);
FWObject *p = obj; FWObject *p = obj;
while (p && Cluster::cast(p)==NULL) p = p->getParent(); while (p && Cluster::cast(p)==nullptr) p = p->getParent();
assert(p != NULL); assert(p != nullptr);
Cluster *cluster = Cluster::cast(p); Cluster *cluster = Cluster::cast(p);
Resources *os_res = Resources::os_res[cluster->getStr("host_OS")]; Resources *os_res = Resources::os_res[cluster->getStr("host_OS")];
assert(os_res != NULL); assert(os_res != nullptr);
string default_address = string default_address =
os_res->getResourceStr( os_res->getResourceStr(
@ -126,7 +126,7 @@ bool heartbeatOptionsDialog::validate()
QMessageBox::critical( QMessageBox::critical(
this, "Firewall Builder", this, "Firewall Builder",
tr("Invalid IP address '%1'").arg(m_dialog->heartbeat_address->text()), tr("Invalid IP address '%1'").arg(m_dialog->heartbeat_address->text()),
tr("&Continue"), 0, 0, tr("&Continue"), nullptr, nullptr,
0 ); 0 );
return false; return false;
} }

View File

@ -71,7 +71,7 @@ void ChooseObjectsPage::initializePage()
} catch (FWException &ex) } catch (FWException &ex)
{ {
QMessageBox::critical( NULL , "Firewall Builder", QMessageBox::critical( nullptr , "Firewall Builder",
ex.toString().c_str(), ex.toString().c_str(),
QString::null,QString::null); QString::null,QString::null);
} }

View File

@ -63,7 +63,7 @@ void CreateObjectsPage::initializePage()
m_dialog->progressBar->setFormat("%v / %m"); m_dialog->progressBar->setFormat("%v / %m");
m_dialog->progressBar->setMaximum(objects.size() / 2); m_dialog->progressBar->setMaximum(objects.size() / 2);
FWObject *last_object = NULL; FWObject *last_object = nullptr;
QString name; QString name;
QString addr; QString addr;
int counter = 1; int counter = 1;
@ -95,7 +95,7 @@ void CreateObjectsPage::initializePage()
if (! type.isEmpty()) if (! type.isEmpty())
{ {
Address *obj = Address::cast(mw->createObject(type, name)); Address *obj = Address::cast(mw->createObject(type, name));
assert(obj!=NULL); assert(obj!=nullptr);
obj->setName(name.toUtf8().constData()); obj->setName(name.toUtf8().constData());
obj->setAddress(InetAddr(addr.toStdString())); obj->setAddress(InetAddr(addr.toStdString()));
obj->setNetmask(InetAddr(InetAddr::getAllOnes())); obj->setNetmask(InetAddr(InetAddr::getAllOnes()));

View File

@ -63,7 +63,7 @@ bool IC_FileNamePage::validatePage()
if ( ! f.exists()) if ( ! f.exists())
{ {
QMessageBox::critical( NULL , "Firewall Builder", QMessageBox::critical( nullptr , "Firewall Builder",
tr("File %1 does not exist").arg(file_name), tr("File %1 does not exist").arg(file_name),
QString::null,QString::null); QString::null,QString::null);
return false; return false;
@ -71,7 +71,7 @@ bool IC_FileNamePage::validatePage()
if ( ! f.isReadable()) if ( ! f.isReadable())
{ {
QMessageBox::critical( NULL , "Firewall Builder", QMessageBox::critical( nullptr , "Firewall Builder",
tr("Can not read file %1").arg(file_name), tr("Can not read file %1").arg(file_name),
QString::null,QString::null); QString::null,QString::null);
return false; return false;

View File

@ -111,7 +111,7 @@ void IC_NetworkZonesPage::setNetworkZones()
Firewall *fw = Firewall *fw =
dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->getFirewall(); dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->getFirewall();
if (fw == NULL) return; if (fw == nullptr) return;
// read and configure network zones // read and configure network zones
list<FWObject*> all_interfaces = fw->getByTypeDeep(Interface::TYPENAME); list<FWObject*> all_interfaces = fw->getByTypeDeep(Interface::TYPENAME);
@ -128,11 +128,11 @@ void IC_NetworkZonesPage::setNetworkZones()
if ( ! ltwi.empty()) if ( ! ltwi.empty())
{ {
QTableWidgetItem *itm2 = ltwi[0]; QTableWidgetItem *itm2 = ltwi[0];
assert(itm2!=NULL); assert(itm2!=nullptr);
int row = itm2->row(); int row = itm2->row();
QComboBox *cb = dynamic_cast<QComboBox*>( QComboBox *cb = dynamic_cast<QComboBox*>(
m_dialog->iface_nz_list->cellWidget(row, 3)); m_dialog->iface_nz_list->cellWidget(row, 3));
assert(cb!=NULL); assert(cb!=nullptr);
int network_zone_int_id = int network_zone_int_id =
cb->itemData(cb->currentIndex(), Qt::UserRole).toInt(); cb->itemData(cb->currentIndex(), Qt::UserRole).toInt();
if (network_zone_int_id != 0) if (network_zone_int_id != 0)

View File

@ -48,7 +48,7 @@ IC_ProgressPage::IC_ProgressPage(QWidget *parent) : QWizardPage(parent)
{ {
m_dialog = new Ui::IC_ProgressPage_q; m_dialog = new Ui::IC_ProgressPage_q;
m_dialog->setupUi(this); m_dialog->setupUi(this);
importer = NULL; importer = nullptr;
errors_count = 0; errors_count = 0;
warnings_count = 0; warnings_count = 0;
@ -76,7 +76,7 @@ IC_ProgressPage::~IC_ProgressPage()
{ {
disconnect(this, SLOT(logLine(QString))); disconnect(this, SLOT(logLine(QString)));
disconnect(this, SLOT(importerFinished())); disconnect(this, SLOT(importerFinished()));
if (importer != NULL && importer->isRunning()) importer->stop(); if (importer != nullptr && importer->isRunning()) importer->stop();
} }
int IC_ProgressPage::nextId() const int IC_ProgressPage::nextId() const
@ -103,20 +103,20 @@ bool IC_ProgressPage::validatePage()
<< "importer=" << importer << "importer=" << importer
<< "isRunning=" << ((importer) ? importer->isRunning() : 0); << "isRunning=" << ((importer) ? importer->isRunning() : 0);
if (importer != NULL && importer->isRunning()) return false; if (importer != nullptr && importer->isRunning()) return false;
return true; return true;
} }
bool IC_ProgressPage::isComplete() const bool IC_ProgressPage::isComplete() const
{ {
if (importer != NULL && importer->isRunning()) return false; if (importer != nullptr && importer->isRunning()) return false;
return true; return true;
} }
void IC_ProgressPage::importerDestroyed(QObject *obj) void IC_ProgressPage::importerDestroyed(QObject *obj)
{ {
if (fwbdebug_ic) qDebug() << "IC_ProgressPage::importerDestroyed() obj=" << obj; if (fwbdebug_ic) qDebug() << "IC_ProgressPage::importerDestroyed() obj=" << obj;
if (obj == importer) importer = NULL; if (obj == importer) importer = nullptr;
} }
void IC_ProgressPage::initializePage() void IC_ProgressPage::initializePage()
@ -124,7 +124,7 @@ void IC_ProgressPage::initializePage()
if (fwbdebug_ic) if (fwbdebug_ic)
qDebug() << "IC_ProgressPage::initializePage()"; qDebug() << "IC_ProgressPage::initializePage()";
if (importer != NULL && importer->isRunning()) if (importer != nullptr && importer->isRunning())
{ {
if (fwbdebug_ic) qDebug() << "importer is still runnig; stopping"; if (fwbdebug_ic) qDebug() << "importer is still runnig; stopping";
importer->stop(); importer->stop();
@ -178,7 +178,7 @@ void IC_ProgressPage::cleanupPage()
if (fwbdebug_ic) qDebug() << "IC_ProgressPage::cleanupPage()"; if (fwbdebug_ic) qDebug() << "IC_ProgressPage::cleanupPage()";
disconnect(this, SLOT(logLine(QString))); disconnect(this, SLOT(logLine(QString)));
disconnect(this, SLOT(importerFinished())); disconnect(this, SLOT(importerFinished()));
if (importer != NULL && importer->isRunning()) importer->stop(); if (importer != nullptr && importer->isRunning()) importer->stop();
// if (importer != NULL && importer->isRunning()) importer->wait(); // if (importer != NULL && importer->isRunning()) importer->wait();
} }

View File

@ -53,7 +53,7 @@ using namespace libfwbuilder;
ImportFirewallConfigurationWizard::ImportFirewallConfigurationWizard( ImportFirewallConfigurationWizard::ImportFirewallConfigurationWizard(
QWidget *parent, FWObjectDatabase *_db) : QWizard(parent) QWidget *parent, FWObjectDatabase *_db) : QWizard(parent)
{ {
fw = NULL; fw = nullptr;
db_orig = _db; db_orig = _db;
db_copy = new FWObjectDatabase(); db_copy = new FWObjectDatabase();
db_copy->duplicate(_db, false); db_copy->duplicate(_db, false);
@ -104,7 +104,7 @@ void ImportFirewallConfigurationWizard::accept()
if (fwbdebug) qDebug() << "ImportFirewallConfigurationWizard::accept()" if (fwbdebug) qDebug() << "ImportFirewallConfigurationWizard::accept()"
<< "fw=" << fw; << "fw=" << fw;
if (fw != NULL && (platform == "pix" || platform == "fwsm")) if (fw != nullptr && (platform == "pix" || platform == "fwsm"))
dynamic_cast<IC_NetworkZonesPage*>( dynamic_cast<IC_NetworkZonesPage*>(
page(Page_NetworkZones))->setNetworkZones(); page(Page_NetworkZones))->setNetworkZones();

View File

@ -64,7 +64,7 @@ ImporterThread::ImporterThread(QWidget *ui,
this->firewallName = firewallName; this->firewallName = firewallName;
this->fileName = fileName; this->fileName = fileName;
this->deduplicate = deduplicate; this->deduplicate = deduplicate;
importer = NULL; importer = nullptr;
stopFlag = false; stopFlag = false;
addStandardComments = false; addStandardComments = false;
} }
@ -98,7 +98,7 @@ void ImporterThread::run()
std::istringstream instream(buffer.join("\n").toStdString()); std::istringstream instream(buffer.join("\n").toStdString());
importer = NULL; importer = nullptr;
if (platform == "iosacl") importer = new IOSImporter( if (platform == "iosacl") importer = new IOSImporter(
lib, instream, logger, firewallName.toUtf8().constData()); lib, instream, logger, firewallName.toUtf8().constData());

View File

@ -81,7 +81,7 @@ bool instDialog::runCompiler(Firewall *fw)
currentProgressBar->setFormat("%v/%m"); currentProgressBar->setFormat("%v/%m");
QTreeWidgetItem* item = opListMapping[fw->getId()]; QTreeWidgetItem* item = opListMapping[fw->getId()];
assert(item!=NULL); assert(item!=nullptr);
currentFWLabel->setText(QString::fromUtf8(fw->getName().c_str())); currentFWLabel->setText(QString::fromUtf8(fw->getName().c_str()));
m_dialog->fwWorkList->scrollToItem(item); m_dialog->fwWorkList->scrollToItem(item);

View File

@ -98,7 +98,7 @@ bool instDialog::runInstaller(Firewall *fw, bool installing_many_firewalls)
currentProgressBar->setFormat("%v/%m"); currentProgressBar->setFormat("%v/%m");
QTreeWidgetItem* item = opListMapping[fw->getId()]; QTreeWidgetItem* item = opListMapping[fw->getId()];
assert(item!=NULL); assert(item!=nullptr);
currentFWLabel->setText(QString::fromUtf8(fw->getName().c_str())); currentFWLabel->setText(QString::fromUtf8(fw->getName().c_str()));
m_dialog->fwWorkList->scrollToItem(item); m_dialog->fwWorkList->scrollToItem(item);
@ -113,7 +113,7 @@ bool instDialog::runInstaller(Firewall *fw, bool installing_many_firewalls)
if (fwbdebug) if (fwbdebug)
qDebug() << "instDialog::runInstaller:" << " cnf.user=" << cnf.user; qDebug() << "instDialog::runInstaller:" << " cnf.user=" << cnf.user;
if (installer!=NULL) if (installer!=nullptr)
delete installer; delete installer;
if (isCiscoFamily()) if (isCiscoFamily())
@ -161,13 +161,13 @@ void instDialog::stopInstall()
proc.terminate(); // try to close proc. proc.terminate(); // try to close proc.
QTimer::singleShot(1000, &proc, SLOT(kill())); //if it doesn't respond, kill it QTimer::singleShot(1000, &proc, SLOT(kill())); //if it doesn't respond, kill it
if (installer != NULL) if (installer != nullptr)
{ {
if (fwbdebug) if (fwbdebug)
qDebug() << "instDialog::stopInstall killing installer"; qDebug() << "instDialog::stopInstall killing installer";
installer->terminate(); installer->terminate();
delete installer; delete installer;
installer = NULL; installer = nullptr;
} }
// to terminate whole install sequence rather than just current // to terminate whole install sequence rather than just current

View File

@ -143,7 +143,7 @@ QTreeWidgetItem* instDialog::createTreeItem(QTreeWidgetItem* parent,
// Mark cluster members // Mark cluster members
// If parent!=NULL, new tree item corresponds to the cluster member // If parent!=NULL, new tree item corresponds to the cluster member
item->setData(1, Qt::UserRole, QVariant(parent!=NULL)); item->setData(1, Qt::UserRole, QVariant(parent!=nullptr));
// it is useful to know how many members does this cluster have. If this is // it is useful to know how many members does this cluster have. If this is
// not a cluster, store 0 // not a cluster, store 0
@ -196,8 +196,8 @@ void instDialog::setFlags(QTreeWidgetItem* item)
bool install_only_on_primary_member = Resources::getTargetCapabilityBool( bool install_only_on_primary_member = Resources::getTargetCapabilityBool(
platform, "install_only_on_primary"); platform, "install_only_on_primary");
Cluster *cluster = NULL; Cluster *cluster = nullptr;
FWObject *master_interface = NULL; FWObject *master_interface = nullptr;
if (parent) if (parent)
{ {
@ -250,7 +250,7 @@ void instDialog::setFlags(QTreeWidgetItem* item)
// If this platform requires installation only on // If this platform requires installation only on
// the master, disable and uncheck checkbox for the standby. // the master, disable and uncheck checkbox for the standby.
if (install_only_on_primary_member && master_interface != NULL) if (install_only_on_primary_member && master_interface != nullptr)
{ {
QString txt = item->text(0); QString txt = item->text(0);
if (master_interface->isChildOf(fw)) if (master_interface->isChildOf(fw))
@ -262,12 +262,12 @@ void instDialog::setFlags(QTreeWidgetItem* item)
// Standby // Standby
item->setText(0, QString("%1 (standby)").arg(txt)); item->setText(0, QString("%1 (standby)").arg(txt));
item->setCheckState(INSTALL_CHECKBOX_COLUMN, Qt::Unchecked); item->setCheckState(INSTALL_CHECKBOX_COLUMN, Qt::Unchecked);
item->setFlags(0); item->setFlags(nullptr);
} }
} }
} }
if (cluster==NULL) if (cluster==nullptr)
{ {
// we are adding firewall that is not cluster member, it // we are adding firewall that is not cluster member, it
// needs "compile" checkbox // needs "compile" checkbox
@ -572,7 +572,7 @@ void instDialog::fillCompileSelectList()
{ {
cl = *i; cl = *i;
QTreeWidgetItem* cluster_item = createTreeItem(NULL, cl); QTreeWidgetItem* cluster_item = createTreeItem(nullptr, cl);
m_dialog->selectTable->addTopLevelItem(cluster_item); m_dialog->selectTable->addTopLevelItem(cluster_item);
list<Firewall*> members; list<Firewall*> members;
@ -591,7 +591,7 @@ void instDialog::fillCompileSelectList()
i!=working_list_of_firewalls.end(); ++i) i!=working_list_of_firewalls.end(); ++i)
{ {
fw = *i; fw = *i;
QTreeWidgetItem* fw_item = createTreeItem(NULL, fw); QTreeWidgetItem* fw_item = createTreeItem(nullptr, fw);
m_dialog->selectTable->addTopLevelItem(fw_item); m_dialog->selectTable->addTopLevelItem(fw_item);
} }
@ -706,13 +706,13 @@ void instDialog::cancelClicked()
proc.kill(); proc.kill();
} }
if (installer != NULL) if (installer != nullptr)
{ {
if (fwbdebug) if (fwbdebug)
qDebug() << "instDialog::cancelClicked killing installer"; qDebug() << "instDialog::cancelClicked killing installer";
installer->terminate(); installer->terminate();
delete installer; delete installer;
installer = NULL; installer = nullptr;
} }
QDialog::reject(); QDialog::reject();
@ -906,14 +906,14 @@ void instDialog::selectAllFirewalls()
if (fwbdebug) qDebug("instDialog::selectAllFirewalls"); if (fwbdebug) qDebug("instDialog::selectAllFirewalls");
setSelectStateAll(INSTALL_CHECKBOX_COLUMN, Qt::Checked); setSelectStateAll(INSTALL_CHECKBOX_COLUMN, Qt::Checked);
setSelectStateAll(COMPILE_CHECKBOX_COLUMN, Qt::Checked); setSelectStateAll(COMPILE_CHECKBOX_COLUMN, Qt::Checked);
tableItemChanged(NULL, 0); tableItemChanged(nullptr, 0);
} }
void instDialog::deselectAllFirewalls() void instDialog::deselectAllFirewalls()
{ {
setSelectStateAll(INSTALL_CHECKBOX_COLUMN, Qt::Unchecked); setSelectStateAll(INSTALL_CHECKBOX_COLUMN, Qt::Unchecked);
setSelectStateAll(COMPILE_CHECKBOX_COLUMN, Qt::Unchecked); setSelectStateAll(COMPILE_CHECKBOX_COLUMN, Qt::Unchecked);
tableItemChanged(NULL, 0); tableItemChanged(nullptr, 0);
} }
void instDialog::setSelectStateAll(int column, Qt::CheckState select) void instDialog::setSelectStateAll(int column, Qt::CheckState select)
@ -975,7 +975,7 @@ void instDialog::fillCompileUIList()
{ {
f = (*i); f = (*i);
item = new InstallFirewallViewItem( item = new InstallFirewallViewItem(
NULL,//m_dialog->fwWorkList, nullptr,//m_dialog->fwWorkList,
QString::fromUtf8(f->getName().c_str()), QString::fromUtf8(f->getName().c_str()),
false); false);
@ -1023,7 +1023,7 @@ void instDialog::fillInstallUIList()
{ {
f = (*i); f = (*i);
item = new InstallFirewallViewItem( item = new InstallFirewallViewItem(
NULL, nullptr,
QString::fromUtf8(f->getName().c_str()), QString::fromUtf8(f->getName().c_str()),
false); false);
@ -1106,14 +1106,14 @@ bool instDialog::getInstOptions(Firewall *fw, bool installing_many_firewalls)
{ {
canceledAll = true; canceledAll = true;
delete inst_opt_dlg; delete inst_opt_dlg;
inst_opt_dlg = NULL; inst_opt_dlg = nullptr;
return false; return false;
} }
if (resultCode == QDialog::Rejected) if (resultCode == QDialog::Rejected)
{ {
delete inst_opt_dlg; delete inst_opt_dlg;
inst_opt_dlg = NULL; inst_opt_dlg = nullptr;
return false; return false;
} }
@ -1156,7 +1156,7 @@ void instDialog::readInstallerOptionsFromFirewallObject(Firewall *fw)
<< "fw=" << fw << "fw=" << fw
<< QString( (fw) ? QString::fromUtf8(fw->getName().c_str()) : ""); << QString( (fw) ? QString::fromUtf8(fw->getName().c_str()) : "");
FWOptions *fwopt = NULL; FWOptions *fwopt = nullptr;
if (fw) if (fw)
{ {
fwopt = fw->getOptionsObject(); fwopt = fw->getOptionsObject();
@ -1300,7 +1300,7 @@ void instDialog::readInstallerOptionsFromDialog(Firewall *fw,
QString adm_user; QString adm_user;
FWOptions *fwopt = NULL; FWOptions *fwopt = nullptr;
if (fw) if (fw)
{ {
fwopt = cnf.fwobj->getOptionsObject(); fwopt = cnf.fwobj->getOptionsObject();
@ -1440,12 +1440,12 @@ void instDialog::closeEvent(QCloseEvent *)
qDebug() << "instDialog::closeEvent killing process"; qDebug() << "instDialog::closeEvent killing process";
proc.kill(); proc.kill();
} }
if (installer != NULL) if (installer != nullptr)
{ {
if (fwbdebug) if (fwbdebug)
qDebug() << "instDialog::closeEvent killing installer"; qDebug() << "instDialog::closeEvent killing installer";
installer->terminate(); installer->terminate();
delete installer; delete installer;
installer = NULL; installer = nullptr;
} }
} }

View File

@ -62,10 +62,10 @@ iosAdvancedDialog::iosAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
/* Page "General" */ /* Page "General" */
data.registerOption( m_dialog->ios_set_host_name , fwoptions, "ios_set_host_name" ); data.registerOption( m_dialog->ios_set_host_name , fwoptions, "ios_set_host_name" );
@ -87,7 +87,7 @@ void iosAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -79,7 +79,7 @@ iosaclAdvancedDialog::iosaclAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
string vers="version_"+obj->getStr("version"); string vers="version_"+obj->getStr("version");
string platform = obj->getStr("platform"); // should be 'iosacl' string platform = obj->getStr("platform"); // should be 'iosacl'
@ -193,7 +193,7 @@ iosaclAdvancedDialog::iosaclAdvancedDialog(QWidget *parent,FWObject *o)
} }
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.registerOption(m_dialog->ipv4before_2, fwoptions, data.registerOption(m_dialog->ipv4before_2, fwoptions,
"ipv4_6_order", "ipv4_6_order",
@ -324,10 +324,10 @@ void iosaclAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* options = Firewall::cast(new_state)->getOptionsObject(); FWOptions* options = Firewall::cast(new_state)->getOptionsObject();
assert(options!=NULL); assert(options!=nullptr);
Management *mgmt = (Firewall::cast(new_state))->getManagementObject(); Management *mgmt = (Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(options); data.saveAll(options);

View File

@ -74,10 +74,10 @@ ipcopAdvancedDialog::ipcopAdvancedDialog(QWidget *parent,FWObject *o)
setWindowTitle(QObject::tr("%1 advanced settings").arg(description.c_str())); setWindowTitle(QObject::tr("%1 advanced settings").arg(description.c_str()));
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
/* /*
fwoptions->setStr("firewall_dir", "/etc/rc.d/"); fwoptions->setStr("firewall_dir", "/etc/rc.d/");
@ -182,10 +182,10 @@ void ipcopAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt=(Firewall::cast(new_state))->getManagementObject(); Management *mgmt=(Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -67,10 +67,10 @@ ipcoposAdvancedDialog::ipcoposAdvancedDialog(QWidget *parent,FWObject *o)
setWindowTitle(QObject::tr("%1 advanced settings").arg(description.c_str())); setWindowTitle(QObject::tr("%1 advanced settings").arg(description.c_str()));
FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
QStringList threeStateMapping; QStringList threeStateMapping;
@ -190,7 +190,7 @@ void ipcoposAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -65,10 +65,10 @@ ipfAdvancedDialog::ipfAdvancedDialog(QWidget *parent,FWObject *o)
QStringList slm; QStringList slm;
FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
if (fwbdebug) if (fwbdebug)
qDebug("%s",Resources::getTargetOptionStr( qDebug("%s",Resources::getTargetOptionStr(
@ -164,10 +164,10 @@ void ipfAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt = (Firewall::cast(new_state))->getManagementObject(); Management *mgmt = (Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -64,10 +64,10 @@ ipfwAdvancedDialog::ipfwAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
if (fwbdebug) if (fwbdebug)
qDebug("%s",Resources::getTargetOptionStr( qDebug("%s",Resources::getTargetOptionStr(
@ -144,10 +144,10 @@ void ipfwAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt = (Firewall::cast(new_state))->getManagementObject(); Management *mgmt = (Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -70,10 +70,10 @@ iptAdvancedDialog::iptAdvancedDialog(QWidget *parent,FWObject *o)
setWindowTitle(QObject::tr("%1 advanced settings").arg(description.c_str())); setWindowTitle(QObject::tr("%1 advanced settings").arg(description.c_str()));
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
if (fwbdebug) if (fwbdebug)
qDebug("%s",Resources::getTargetOptionStr( qDebug("%s",Resources::getTargetOptionStr(
@ -246,10 +246,10 @@ void iptAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt = (Firewall::cast(new_state))->getManagementObject(); Management *mgmt = (Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -62,10 +62,10 @@ junosAdvancedDialog::junosAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
/* Page "General" */ /* Page "General" */
data.registerOption( m_dialog->junos_set_host_name , fwoptions, "junos_set_host_name" ); data.registerOption( m_dialog->junos_set_host_name , fwoptions, "junos_set_host_name" );
@ -87,7 +87,7 @@ void junosAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -79,7 +79,7 @@ junosaclAdvancedDialog::junosaclAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
string vers="version_"+obj->getStr("version"); string vers="version_"+obj->getStr("version");
string platform = obj->getStr("platform"); // should be 'junosacl' string platform = obj->getStr("platform"); // should be 'junosacl'
@ -193,7 +193,7 @@ junosaclAdvancedDialog::junosaclAdvancedDialog(QWidget *parent,FWObject *o)
} }
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.registerOption(m_dialog->ipv4before_2, fwoptions, data.registerOption(m_dialog->ipv4before_2, fwoptions,
"ipv4_6_order", "ipv4_6_order",
@ -315,10 +315,10 @@ void junosaclAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* options = Firewall::cast(new_state)->getOptionsObject(); FWOptions* options = Firewall::cast(new_state)->getOptionsObject();
assert(options!=NULL); assert(options!=nullptr);
Management *mgmt = (Firewall::cast(new_state))->getManagementObject(); Management *mgmt = (Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(options); data.saveAll(options);

View File

@ -61,10 +61,10 @@ linksysAdvancedDialog::linksysAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
/* /*
* since v2.0.3 we do not need to know shell prompt on linksys. Will * since v2.0.3 we do not need to know shell prompt on linksys. Will
* remove the page completely when code becomes stable. * remove the page completely when code becomes stable.
@ -139,7 +139,7 @@ void linksysAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);
@ -157,7 +157,7 @@ void linksysAdvancedDialog::reject()
void linksysAdvancedDialog::setDefaultPrompts() void linksysAdvancedDialog::setDefaultPrompts()
{ {
FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
m_dialog->linksys_prompt1->setText( m_dialog->linksys_prompt1->setText(
Resources::getTargetOptionStr("sveasoft","default/prompt1").c_str() ); Resources::getTargetOptionStr("sveasoft","default/prompt1").c_str() );
m_dialog->linksys_prompt2->setText( m_dialog->linksys_prompt2->setText(

View File

@ -68,10 +68,10 @@ linux24AdvancedDialog::linux24AdvancedDialog(QWidget *parent,FWObject *o)
setWindowTitle(QObject::tr("%1 advanced settings").arg(description.c_str())); setWindowTitle(QObject::tr("%1 advanced settings").arg(description.c_str()));
FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
QStringList threeStateMapping; QStringList threeStateMapping;
@ -205,10 +205,10 @@ void linux24AdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt = (Firewall::cast(new_state))->getManagementObject(); Management *mgmt = (Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -54,7 +54,7 @@ linux24IfaceOptsDialog::linux24IfaceOptsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *ifopt = (Interface::cast(obj))->getOptionsObject(); FWOptions *ifopt = (Interface::cast(obj))->getOptionsObject();
cluster_interface = (Cluster::cast(obj->getParent()) != NULL); cluster_interface = (Cluster::cast(obj->getParent()) != nullptr);
setInterfaceTypes(m_dialog->iface_type, Interface::cast(obj), setInterfaceTypes(m_dialog->iface_type, Interface::cast(obj),
ifopt->getStr("type").c_str()); ifopt->getStr("type").c_str());
@ -105,7 +105,7 @@ void linux24IfaceOptsDialog::accept()
// new_state is a copy of the interface object // new_state is a copy of the interface object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* ifopt = Interface::cast(new_state)->getOptionsObject(); FWOptions* ifopt = Interface::cast(new_state)->getOptionsObject();
assert(ifopt!=NULL); assert(ifopt!=nullptr);
if (cluster_interface) if (cluster_interface)
{ {
@ -182,7 +182,7 @@ bool linux24IfaceOptsDialog::validate()
QString combobox = m_dialog->iface_type->currentText(); QString combobox = m_dialog->iface_type->currentText();
QString type = m_dialog->iface_type->itemData( QString type = m_dialog->iface_type->itemData(
m_dialog->iface_type->currentIndex()).toString(); m_dialog->iface_type->currentIndex()).toString();
QWidget *focus = NULL; QWidget *focus = nullptr;
QString message; QString message;
if (type == "vrrp") if (type == "vrrp")

View File

@ -59,17 +59,17 @@ void ListOfLibrariesModel::addStaticItems()
Qt::ItemFlags ListOfLibrariesModel::flags(const QModelIndex &index) const Qt::ItemFlags ListOfLibrariesModel::flags(const QModelIndex &index) const
{ {
int row = index.row(); int row = index.row();
if (row < 0 || row >= items.size()) return 0; if (row < 0 || row >= items.size()) return nullptr;
FWObject *lib = items.at(index.row()).lib; FWObject *lib = items.at(index.row()).lib;
if (lib == NULL) return Qt::ItemIsEnabled; if (lib == nullptr) return Qt::ItemIsEnabled;
else return QStringListModel::flags(index); else return QStringListModel::flags(index);
} }
bool ListOfLibrariesModel::insertRows(int row, int count, const QModelIndex & parent) bool ListOfLibrariesModel::insertRows(int row, int count, const QModelIndex & parent)
{ {
for (int c=0; c < count; ++c) for (int c=0; c < count; ++c)
items.insert(row, _item_data("", NULL, NULL)); items.insert(row, _item_data("", nullptr, nullptr));
return QStringListModel::insertRows(row, count, parent); return QStringListModel::insertRows(row, count, parent);
} }
@ -103,7 +103,7 @@ void ListOfLibrariesModel::sort(int column, Qt::SortOrder order)
for (int i=0; i<rowCount(); ++i) for (int i=0; i<rowCount(); ++i)
{ {
FWObject *l = getLibrary(i); FWObject *l = getLibrary(i);
if (l==NULL) continue; if (l==nullptr) continue;
list.append(items.at(i)); list.append(items.at(i));
} }
@ -115,7 +115,7 @@ void ListOfLibrariesModel::sort(int column, Qt::SortOrder order)
int pos = 0; int pos = 0;
foreach(QString itm, top_static_items) foreach(QString itm, top_static_items)
{ {
list.insert(pos, _item_data(itm, NULL, NULL)); list.insert(pos, _item_data(itm, nullptr, nullptr));
pos++; pos++;
} }
@ -127,7 +127,7 @@ void ListOfLibrariesModel::sort(int column, Qt::SortOrder order)
QString text = list.at(i).name; QString text = list.at(i).name;
insertRows(i, 1); insertRows(i, 1);
QModelIndex idx = index(i, 0); QModelIndex idx = index(i, 0);
QStringListModel::setData(idx, indentLibName(text, list.at(i).lib!=NULL), Qt::DisplayRole); QStringListModel::setData(idx, indentLibName(text, list.at(i).lib!=nullptr), Qt::DisplayRole);
items[i] = list[i]; items[i] = list[i];
} }
} }
@ -157,7 +157,7 @@ FWObject* ListOfLibrariesModel::getLibrary(QModelIndex idx)
FWObject* ListOfLibrariesModel::getLibrary(int row) FWObject* ListOfLibrariesModel::getLibrary(int row)
{ {
if (row < 0 || row >= items.size()) return NULL; if (row < 0 || row >= items.size()) return nullptr;
return items[row].lib; return items[row].lib;
} }
@ -168,7 +168,7 @@ ObjectTreeView* ListOfLibrariesModel::getTreeWidget(QModelIndex idx)
ObjectTreeView* ListOfLibrariesModel::getTreeWidget(int row) ObjectTreeView* ListOfLibrariesModel::getTreeWidget(int row)
{ {
if (row < 0 || row >= items.size()) return NULL; if (row < 0 || row >= items.size()) return nullptr;
return items[row].tree; return items[row].tree;
} }
@ -177,7 +177,7 @@ void ListOfLibrariesModel::setData(QModelIndex idx, const QString &name, FWObjec
int row = idx.row(); int row = idx.row();
if (row < 0 || row >= items.size()) return ; if (row < 0 || row >= items.size()) return ;
items[row] = _item_data(name, lib, otv); items[row] = _item_data(name, lib, otv);
QStringListModel::setData(idx, indentLibName(name, lib!=NULL), Qt::DisplayRole); QStringListModel::setData(idx, indentLibName(name, lib!=nullptr), Qt::DisplayRole);
} }
void ListOfLibrariesModel::setName(QModelIndex idx, const QString &name) void ListOfLibrariesModel::setName(QModelIndex idx, const QString &name)
@ -185,7 +185,7 @@ void ListOfLibrariesModel::setName(QModelIndex idx, const QString &name)
int row = idx.row(); int row = idx.row();
if (row < 0 || row >= items.size()) return ; if (row < 0 || row >= items.size()) return ;
items[row].name = name; items[row].name = name;
QStringListModel::setData(idx, indentLibName(name, items.at(row).lib!=NULL), Qt::DisplayRole); QStringListModel::setData(idx, indentLibName(name, items.at(row).lib!=nullptr), Qt::DisplayRole);
} }
QString ListOfLibrariesModel::indentLibName(const QString &name, bool indent) QString ListOfLibrariesModel::indentLibName(const QString &name, bool indent)

View File

@ -60,10 +60,10 @@ macosxAdvancedDialog::macosxAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
QStringList threeStateMapping; QStringList threeStateMapping;
@ -107,7 +107,7 @@ void macosxAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -74,10 +74,10 @@ void NetworkZoneManager::load(FWObjectDatabase *_db)
if ( library->getId()==FWObjectDatabase::DELETED_OBJECTS_ID ) continue; if ( library->getId()==FWObjectDatabase::DELETED_OBJECTS_ID ) continue;
o1 = library->findObjectByName(ObjectGroup::TYPENAME, "Objects"); o1 = library->findObjectByName(ObjectGroup::TYPENAME, "Objects");
assert(o1!=NULL); assert(o1!=nullptr);
o2 = o1->findObjectByName(ObjectGroup::TYPENAME, "Groups"); o2 = o1->findObjectByName(ObjectGroup::TYPENAME, "Groups");
if (o2==NULL) if (o2==nullptr)
{ {
if (fwbdebug) if (fwbdebug)
qDebug() << "NetworkZoneManager::NetworkZoneManager():" qDebug() << "NetworkZoneManager::NetworkZoneManager():"
@ -96,7 +96,7 @@ void NetworkZoneManager::load(FWObjectDatabase *_db)
} }
o2=o1->findObjectByName(ObjectGroup::TYPENAME,"Networks"); o2=o1->findObjectByName(ObjectGroup::TYPENAME,"Networks");
if (o2==NULL) if (o2==nullptr)
{ {
if (fwbdebug) if (fwbdebug)
qDebug() << "NetworkZoneManager::NetworkZoneManager():" qDebug() << "NetworkZoneManager::NetworkZoneManager():"

View File

@ -55,7 +55,7 @@ using namespace std;
newClusterDialog::newClusterDialog(QWidget *parentw, FWObject *_p) newClusterDialog::newClusterDialog(QWidget *parentw, FWObject *_p)
: QDialog(parentw), ncl(NULL), fwlist(NULL), tmpldb(NULL) : QDialog(parentw), ncl(nullptr), fwlist(nullptr), tmpldb(nullptr)
{ {
parent = _p; parent = _p;
db = parent->getRoot(); db = parent->getRoot();
@ -307,7 +307,7 @@ void newClusterDialog::finishClicked()
if (unloadTemplatesLib) if (unloadTemplatesLib)
{ {
delete tmpldb; delete tmpldb;
tmpldb = NULL; tmpldb = nullptr;
unloadTemplatesLib = false; unloadTemplatesLib = false;
} }

View File

@ -60,7 +60,7 @@ void newClusterDialog::createNewCluster()
this->m_dialog->interfaceSelector->getInterfaces(); this->m_dialog->interfaceSelector->getInterfaces();
typedef QPair<Firewall*, bool> fwpair; typedef QPair<Firewall*, bool> fwpair;
Firewall *master = NULL; Firewall *master = nullptr;
QList<QPair<Firewall*, bool> > member_firewalls = QList<QPair<Firewall*, bool> > member_firewalls =
this->m_dialog->firewallSelector->getSelectedFirewalls(); this->m_dialog->firewallSelector->getSelectedFirewalls();
foreach(fwpair member, member_firewalls) foreach(fwpair member, member_firewalls)
@ -71,7 +71,7 @@ void newClusterDialog::createNewCluster()
FWObject *o; FWObject *o;
o = db->create(Cluster::TYPENAME); o = db->create(Cluster::TYPENAME);
if (o == NULL) if (o == nullptr)
{ {
QDialog::accept(); QDialog::accept();
return; return;
@ -196,7 +196,7 @@ void newClusterDialog::createNewCluster()
failover_grp->addRef(member_intf); failover_grp->addRef(member_intf);
if (master!=NULL && member_fw == master) if (master!=nullptr && member_fw == master)
{ {
std::string masteriface_id = std::string masteriface_id =
FWObjectDatabase::getStringId(member_intf->getId()); FWObjectDatabase::getStringId(member_intf->getId());
@ -220,7 +220,7 @@ void newClusterDialog::createNewCluster()
StateSyncClusterGroup::cast(state_sync_members)); StateSyncClusterGroup::cast(state_sync_members));
// Copy rule sets if requested // Copy rule sets if requested
Firewall *source = NULL; Firewall *source = nullptr;
foreach (QRadioButton* btn, copy_rules_from_buttons.keys()) foreach (QRadioButton* btn, copy_rules_from_buttons.keys())
{ {
if (btn->isChecked() && btn != noPolicy) if (btn->isChecked() && btn != noPolicy)
@ -236,7 +236,7 @@ void newClusterDialog::createNewCluster()
QString filename = pp->getFileName(); QString filename = pp->getFileName();
if (source == NULL) if (source == nullptr)
{ {
if (fwbdebug) if (fwbdebug)
qDebug() << "newClusterDialog::createNewCluster() checkpoint 5"; qDebug() << "newClusterDialog::createNewCluster() checkpoint 5";
@ -256,9 +256,9 @@ void newClusterDialog::createNewCluster()
// <source>, need to close it because we are about to delete that // <source>, need to close it because we are about to delete that
// rule set object // rule set object
RuleSet* current_ruleset = NULL; RuleSet* current_ruleset = nullptr;
RuleSetView* rsv = pp->getCurrentRuleSetView(); RuleSetView* rsv = pp->getCurrentRuleSetView();
RuleSetModel* md = NULL; RuleSetModel* md = nullptr;
if (rsv) if (rsv)
{ {
md = (RuleSetModel*)rsv->model(); md = (RuleSetModel*)rsv->model();
@ -283,7 +283,7 @@ void newClusterDialog::createNewCluster()
string name_bak = fw->getName() + "-bak"; string name_bak = fw->getName() + "-bak";
FWCmdAddObject *cmd = new FWCmdAddObject( FWCmdAddObject *cmd = new FWCmdAddObject(
mw->activeProject(), fwgroup, NULL, mw->activeProject(), fwgroup, nullptr,
QString("Create new Firewall %1") QString("Create new Firewall %1")
.arg(QString::fromUtf8(name_bak.c_str()))); .arg(QString::fromUtf8(name_bak.c_str())));
cmd->setNeedTreeReload(true); cmd->setNeedTreeReload(true);

View File

@ -75,7 +75,7 @@ void newFirewallDialog::createFirewallFromTemplate()
{ {
QListWidgetItem *itm = m_dialog->templateList->currentItem(); QListWidgetItem *itm = m_dialog->templateList->currentItem();
FWObject *template_fw = templates[itm]; FWObject *template_fw = templates[itm];
assert (template_fw!=NULL); assert (template_fw!=nullptr);
string platform = readPlatform(m_dialog->platform).toLatin1().constData(); string platform = readPlatform(m_dialog->platform).toLatin1().constData();
string host_os = readHostOS(m_dialog->hostOS).toLatin1().constData(); string host_os = readHostOS(m_dialog->hostOS).toLatin1().constData();

View File

@ -62,10 +62,10 @@ nxosAdvancedDialog::nxosAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
/* Page "General" */ /* Page "General" */
data.registerOption( m_dialog->nxos_set_host_name , fwoptions, "nxos_set_host_name" ); data.registerOption( m_dialog->nxos_set_host_name , fwoptions, "nxos_set_host_name" );
@ -87,7 +87,7 @@ void nxosAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -79,7 +79,7 @@ nxosaclAdvancedDialog::nxosaclAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
string vers="version_"+obj->getStr("version"); string vers="version_"+obj->getStr("version");
string platform = obj->getStr("platform"); // should be 'nxosacl' string platform = obj->getStr("platform"); // should be 'nxosacl'
@ -193,7 +193,7 @@ nxosaclAdvancedDialog::nxosaclAdvancedDialog(QWidget *parent,FWObject *o)
} }
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.registerOption(m_dialog->ipv4before_2, fwoptions, data.registerOption(m_dialog->ipv4before_2, fwoptions,
"ipv4_6_order", "ipv4_6_order",
@ -327,10 +327,10 @@ void nxosaclAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* options = Firewall::cast(new_state)->getOptionsObject(); FWOptions* options = Firewall::cast(new_state)->getOptionsObject();
assert(options!=NULL); assert(options!=nullptr);
Management *mgmt = (Firewall::cast(new_state))->getManagementObject(); Management *mgmt = (Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(options); data.saveAll(options);

View File

@ -51,13 +51,13 @@ openaisOptionsDialog::openaisOptionsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *gropt = FWOptions::cast(obj); FWOptions *gropt = FWOptions::cast(obj);
assert(gropt != NULL); assert(gropt != nullptr);
FWObject *p = obj; FWObject *p = obj;
while (p && Cluster::cast(p)==NULL) p = p->getParent(); while (p && Cluster::cast(p)==nullptr) p = p->getParent();
assert(p != NULL); assert(p != nullptr);
Cluster *cluster = Cluster::cast(p); Cluster *cluster = Cluster::cast(p);
Resources *os_res = Resources::os_res[cluster->getStr("host_OS")]; Resources *os_res = Resources::os_res[cluster->getStr("host_OS")];
assert(os_res != NULL); assert(os_res != nullptr);
string default_address = string default_address =
os_res->getResourceStr( os_res->getResourceStr(
@ -123,7 +123,7 @@ bool openaisOptionsDialog::validate()
QMessageBox::critical( QMessageBox::critical(
this, "Firewall Builder", this, "Firewall Builder",
tr("Invalid IP address '%1'").arg(m_dialog->openais_address->text()), tr("Invalid IP address '%1'").arg(m_dialog->openais_address->text()),
tr("&Continue"), 0, 0, tr("&Continue"), nullptr, nullptr,
0 ); 0 );
return false; return false;
} }

View File

@ -61,10 +61,10 @@ openbsdAdvancedDialog::openbsdAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
QStringList threeStateMapping; QStringList threeStateMapping;
@ -117,10 +117,10 @@ void openbsdAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt = (Firewall::cast(new_state))->getManagementObject(); Management *mgmt = (Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -67,10 +67,10 @@ pfAdvancedDialog::pfAdvancedDialog(QWidget *parent,FWObject *o)
string version = obj->getStr("version"); string version = obj->getStr("version");
FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
if (fwbdebug) if (fwbdebug)
qDebug("%s", Resources::getTargetOptionStr( qDebug("%s", Resources::getTargetOptionStr(
@ -460,10 +460,10 @@ void pfAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt = (Firewall::cast(new_state))->getManagementObject(); Management *mgmt = (Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -49,7 +49,7 @@ pfsyncOptionsDialog::pfsyncOptionsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *gropt = FWOptions::cast(obj); FWOptions *gropt = FWOptions::cast(obj);
assert(gropt != NULL); assert(gropt != nullptr);
data.registerOption(m_dialog->syncpeer, data.registerOption(m_dialog->syncpeer,
gropt, gropt,

View File

@ -170,7 +170,7 @@ pixAdvancedDialog::pixAdvancedDialog(QWidget*parent, FWObject *o)
syslogFacilityMapping.push_back("23"); syslogFacilityMapping.push_back("23");
FWOptions *fwoptions = (Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions = (Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
/* Page Script */ /* Page Script */
@ -193,7 +193,7 @@ pixAdvancedDialog::pixAdvancedDialog(QWidget*parent, FWObject *o)
} }
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.registerOption( m_dialog->short_script, fwoptions, "short_script"); data.registerOption( m_dialog->short_script, fwoptions, "short_script");
@ -371,137 +371,137 @@ pixAdvancedDialog::pixAdvancedDialog(QWidget*parent, FWObject *o)
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_ctiqbe_switch, m_dialog->pix_ctiqbe_switch,
m_dialog->pix_ctiqbe_port, m_dialog->pix_ctiqbe_port,
NULL, nullptr,
NULL, nullptr,
"ctiqbe_fixup", "ctiqbe", 0)); "ctiqbe_fixup", "ctiqbe", 0));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_dns_switch, m_dialog->pix_dns_switch,
m_dialog->pix_dns_max_length, m_dialog->pix_dns_max_length,
NULL, nullptr,
NULL, nullptr,
"dns_fixup", "dns", 1)); "dns_fixup", "dns", 1));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_espike_switch, m_dialog->pix_espike_switch,
NULL, nullptr,
NULL, nullptr,
NULL, nullptr,
"espike_fixup", "esp-ike", 2)); "espike_fixup", "esp-ike", 2));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_ftp_switch, m_dialog->pix_ftp_switch,
m_dialog->pix_ftp_port, m_dialog->pix_ftp_port,
NULL, nullptr,
m_dialog->pix_ftp_strict, m_dialog->pix_ftp_strict,
"ftp_fixup", "ftp", 3)); "ftp_fixup", "ftp", 3));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_h323h225_switch, m_dialog->pix_h323h225_switch,
m_dialog->pix_h323h225_port1, m_dialog->pix_h323h225_port1,
m_dialog->pix_h323h225_port2, m_dialog->pix_h323h225_port2,
NULL, nullptr,
"h323_h225_fixup", "h323 h225", 4)); "h323_h225_fixup", "h323 h225", 4));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_h323ras_switch, m_dialog->pix_h323ras_switch,
m_dialog->pix_h323ras_port1, m_dialog->pix_h323ras_port1,
m_dialog->pix_h323ras_port2, m_dialog->pix_h323ras_port2,
NULL, nullptr,
"h323_ras_fixup", "h323 ras", 5)); "h323_ras_fixup", "h323 ras", 5));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_http_switch, m_dialog->pix_http_switch,
m_dialog->pix_http_port1, m_dialog->pix_http_port1,
m_dialog->pix_http_port2, m_dialog->pix_http_port2,
NULL, nullptr,
"http_fixup", "http", 6)); "http_fixup", "http", 6));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_icmperror_switch, m_dialog->pix_icmperror_switch,
NULL, nullptr,
NULL, nullptr,
NULL, nullptr,
"icmp_error_fixup", "icmp error", 7)); "icmp_error_fixup", "icmp error", 7));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_ils_switch, m_dialog->pix_ils_switch,
m_dialog->pix_ils_port1, m_dialog->pix_ils_port1,
m_dialog->pix_ils_port2, m_dialog->pix_ils_port2,
NULL, nullptr,
"ils_fixup", "ils", 8)); "ils_fixup", "ils", 8));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_mgcp_switch, m_dialog->pix_mgcp_switch,
m_dialog->pix_mgcp_gateway_port, m_dialog->pix_mgcp_gateway_port,
m_dialog->pix_mgcp_call_agent_port, m_dialog->pix_mgcp_call_agent_port,
NULL, nullptr,
"mgcp_fixup", "mgcp", 9)); "mgcp_fixup", "mgcp", 9));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_pptp_switch, m_dialog->pix_pptp_switch,
m_dialog->pix_pptp_port, m_dialog->pix_pptp_port,
NULL, nullptr,
NULL, nullptr,
"pptp_fixup", "pptp", 10)); "pptp_fixup", "pptp", 10));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_rsh_switch, m_dialog->pix_rsh_switch,
m_dialog->pix_rsh_port1, m_dialog->pix_rsh_port1,
NULL, nullptr,
NULL, nullptr,
"rsh_fixup", "rsh", 11)); "rsh_fixup", "rsh", 11));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_rtsp_switch, m_dialog->pix_rtsp_switch,
m_dialog->pix_rtsp_port, m_dialog->pix_rtsp_port,
NULL, nullptr,
NULL, nullptr,
"rtsp_fixup", "rtsp", 12)); "rtsp_fixup", "rtsp", 12));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_sip_switch, m_dialog->pix_sip_switch,
m_dialog->pix_sip_port1, m_dialog->pix_sip_port1,
m_dialog->pix_sip_port2, m_dialog->pix_sip_port2,
NULL, nullptr,
"sip_fixup", "sip", 13)); "sip_fixup", "sip", 13));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_sipudp_switch, m_dialog->pix_sipudp_switch,
m_dialog->pix_sip_udp_port1, m_dialog->pix_sip_udp_port1,
NULL, nullptr,
NULL, nullptr,
"sip_udp_fixup", "sip udp", 14)); "sip_udp_fixup", "sip udp", 14));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_skinny_switch, m_dialog->pix_skinny_switch,
m_dialog->pix_skinny_port1, m_dialog->pix_skinny_port1,
m_dialog->pix_skinny_port2, m_dialog->pix_skinny_port2,
NULL, nullptr,
"skinny_fixup", "skinny", 15)); "skinny_fixup", "skinny", 15));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_smtp_switch, m_dialog->pix_smtp_switch,
m_dialog->pix_smtp_port1, m_dialog->pix_smtp_port1,
m_dialog->pix_smtp_port2, m_dialog->pix_smtp_port2,
NULL, nullptr,
"smtp_fixup", "smtp", 16)); "smtp_fixup", "smtp", 16));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_sqlnet_switch, m_dialog->pix_sqlnet_switch,
m_dialog->pix_sqlnet_port1, m_dialog->pix_sqlnet_port1,
m_dialog->pix_sqlnet_port2, m_dialog->pix_sqlnet_port2,
NULL, nullptr,
"sqlnet_fixup", "sqlnet", 17)); "sqlnet_fixup", "sqlnet", 17));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_tftp_switch, m_dialog->pix_tftp_switch,
m_dialog->pix_tftp_port, m_dialog->pix_tftp_port,
NULL, nullptr,
NULL, nullptr,
"tftp_fixup", "tftp", 18)); "tftp_fixup", "tftp", 18));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_ip_options_eool_switch, m_dialog->pix_ip_options_eool_switch,
NULL, nullptr,
NULL, nullptr,
NULL, nullptr,
"ip_options_eool_fixup", "IP options", 19)); "ip_options_eool_fixup", "IP options", 19));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_ip_options_nop_switch, m_dialog->pix_ip_options_nop_switch,
NULL, nullptr,
NULL, nullptr,
NULL, nullptr,
"ip_options_nop_fixup", "IP options", 20)); "ip_options_nop_fixup", "IP options", 20));
allFixups.push_back(fixupControl( allFixups.push_back(fixupControl(
m_dialog->pix_ip_options_rtralt_switch, m_dialog->pix_ip_options_rtralt_switch,
NULL, nullptr,
NULL, nullptr,
NULL, nullptr,
"ip_options_rtralt_fixup", "IP options", 21)); "ip_options_rtralt_fixup", "IP options", 21));
QStringList allowed_fixups = QStringList allowed_fixups =
@ -521,17 +521,17 @@ pixAdvancedDialog::pixAdvancedDialog(QWidget*parent, FWObject *o)
qDebug() << "pixAdvancedDialog::pixAdvancedDialog fwopt:" qDebug() << "pixAdvancedDialog::pixAdvancedDialog fwopt:"
<< fi->fwoption; << fi->fwoption;
if (fi->switch_widget!=NULL) if (fi->switch_widget!=nullptr)
connect( fi->switch_widget, SIGNAL(activated(int)), connect( fi->switch_widget, SIGNAL(activated(int)),
this, SLOT(fixupCmdChanged())); this, SLOT(fixupCmdChanged()));
if (fi->arg1!=NULL) connect( fi->arg1, SIGNAL(valueChanged(int)), if (fi->arg1!=nullptr) connect( fi->arg1, SIGNAL(valueChanged(int)),
this, SLOT(fixupCmdChanged())); this, SLOT(fixupCmdChanged()));
if (fi->arg2!=NULL) connect( fi->arg2, SIGNAL(valueChanged(int)), if (fi->arg2!=nullptr) connect( fi->arg2, SIGNAL(valueChanged(int)),
this, SLOT(fixupCmdChanged())); this, SLOT(fixupCmdChanged()));
if (fi->arg3!=NULL) connect( fi->arg3, SIGNAL(clicked()), if (fi->arg3!=nullptr) connect( fi->arg3, SIGNAL(clicked()),
this, SLOT(fixupCmdChanged())); this, SLOT(fixupCmdChanged()));
bool active = allowed_fixups.contains(fi->fwoption); bool active = allowed_fixups.contains(fi->fwoption);
@ -718,7 +718,7 @@ void pixAdvancedDialog::changeAllFixups(int state)
void pixAdvancedDialog::loadFixups() void pixAdvancedDialog::loadFixups()
{ {
FWOptions *options=(Firewall::cast(obj))->getOptionsObject(); FWOptions *options=(Firewall::cast(obj))->getOptionsObject();
assert(options!=NULL); assert(options!=nullptr);
for (list<fixupControl>::iterator fi=allFixups.begin(); fi!=allFixups.end(); fi++) for (list<fixupControl>::iterator fi=allFixups.begin(); fi!=allFixups.end(); fi++)
{ {
@ -801,7 +801,7 @@ void pixAdvancedDialog::displayCommands()
* object back * object back
*/ */
FWOptions *options = (Firewall::cast(obj))->getOptionsObject(); FWOptions *options = (Firewall::cast(obj))->getOptionsObject();
assert(options!=NULL); assert(options!=nullptr);
FWOptions *backup_options = new FWOptions(); FWOptions *backup_options = new FWOptions();
backup_options->duplicate(options, false); backup_options->duplicate(options, false);
@ -838,10 +838,10 @@ void pixAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt = (Firewall::cast(new_state))->getManagementObject(); Management *mgmt = (Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);
@ -910,7 +910,7 @@ void pixAdvancedDialog::setDefaultTimeoutValue(const QString &option)
{ {
string platform = obj->getStr("platform"); // could be 'pix' or 'fwsm' string platform = obj->getStr("platform"); // could be 'pix' or 'fwsm'
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
string vers="version_"+obj->getStr("version"); string vers="version_"+obj->getStr("version");
@ -927,7 +927,7 @@ void pixAdvancedDialog::setDefaultTimeoutValue(const QString &option)
void pixAdvancedDialog::defaultTimeouts() void pixAdvancedDialog::defaultTimeouts()
{ {
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
string vers="version_"+obj->getStr("version"); string vers="version_"+obj->getStr("version");

View File

@ -50,7 +50,7 @@ pixFailoverOptionsDialog::pixFailoverOptionsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *gropt = FWOptions::cast(obj); FWOptions *gropt = FWOptions::cast(obj);
assert(gropt != NULL); assert(gropt != nullptr);
data.registerOption(m_dialog->pix_failover_key, data.registerOption(m_dialog->pix_failover_key,
gropt, gropt,
@ -90,7 +90,7 @@ void pixFailoverOptionsDialog::reject()
bool pixFailoverOptionsDialog::validate() bool pixFailoverOptionsDialog::validate()
{ {
bool valid = true; bool valid = true;
QWidget *focus = NULL; QWidget *focus = nullptr;
QString message; QString message;
// key must be set // key must be set

View File

@ -63,10 +63,10 @@ pixosAdvancedDialog::pixosAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
/* Page "General" */ /* Page "General" */
data.registerOption( data.registerOption(
@ -130,7 +130,7 @@ void pixosAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -52,7 +52,7 @@ pixosIfaceOptsDialog::pixosIfaceOptsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *ifopt = (Interface::cast(obj))->getOptionsObject(); FWOptions *ifopt = (Interface::cast(obj))->getOptionsObject();
cluster_interface = (Cluster::cast(obj->getParent()) != NULL); cluster_interface = (Cluster::cast(obj->getParent()) != nullptr);
setInterfaceTypes(m_dialog->iface_type, Interface::cast(obj), setInterfaceTypes(m_dialog->iface_type, Interface::cast(obj),
ifopt->getStr("type").c_str()); ifopt->getStr("type").c_str());
@ -97,7 +97,7 @@ void pixosIfaceOptsDialog::accept()
// new_state is a copy of the interface object // new_state is a copy of the interface object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* ifopt = Interface::cast(new_state)->getOptionsObject(); FWOptions* ifopt = Interface::cast(new_state)->getOptionsObject();
assert(ifopt!=NULL); assert(ifopt!=nullptr);
if (cluster_interface) if (cluster_interface)
{ {
@ -156,7 +156,7 @@ bool pixosIfaceOptsDialog::validate()
QString combobox = m_dialog->iface_type->currentText(); QString combobox = m_dialog->iface_type->currentText();
QString type = m_dialog->iface_type->itemData( QString type = m_dialog->iface_type->itemData(
m_dialog->iface_type->currentIndex()).toString(); m_dialog->iface_type->currentIndex()).toString();
QWidget *focus = NULL; QWidget *focus = nullptr;
QString message; QString message;
if (type == "8021q") if (type == "8021q")

View File

@ -196,15 +196,15 @@ bool isDefaultPolicyRuleOptions(FWOptions *opt)
{ {
bool res = true; bool res = true;
FWObject *p; FWObject *p;
PolicyRule *rule = NULL; PolicyRule *rule = nullptr;
p = opt; p = opt;
do { do {
p = p->getParent(); p = p->getParent();
if (PolicyRule::cast(p)!=NULL) rule = PolicyRule::cast(p); if (PolicyRule::cast(p)!=nullptr) rule = PolicyRule::cast(p);
} while ( p!=NULL && Firewall::cast(p)==NULL ); } while ( p!=nullptr && Firewall::cast(p)==nullptr );
if (p==NULL) if (p==nullptr)
{ {
qDebug() << "isDefaultPolicyRuleOptions()" qDebug() << "isDefaultPolicyRuleOptions()"
<< "Can not locate parent Firewall object for the options object"; << "Can not locate parent Firewall object for the options object";
@ -315,7 +315,7 @@ bool isDefaultPolicyRuleOptions(FWOptions *opt)
res = true; res = true;
} }
if (rule!=NULL) if (rule!=nullptr)
{ {
PolicyRule::Action act = rule->getAction(); PolicyRule::Action act = rule->getAction();
@ -348,9 +348,9 @@ bool isDefaultNATRuleOptions(FWOptions *opt)
p=opt; p=opt;
do { p=p->getParent(); do { p=p->getParent();
} while ( p!=NULL && Firewall::cast(p)==NULL ); } while ( p!=nullptr && Firewall::cast(p)==nullptr );
assert(p!=NULL); assert(p!=nullptr);
QString platform = p->getStr("platform").c_str(); QString platform = p->getStr("platform").c_str();
@ -496,7 +496,7 @@ void getVersionsForPlatform(const QString &platform, std::list<QStringPair> &res
void getStateSyncTypesForOS(const QString &host_os, std::list<QStringPair> &res) void getStateSyncTypesForOS(const QString &host_os, std::list<QStringPair> &res)
{ {
Resources* os_res = Resources::os_res[host_os.toStdString()]; Resources* os_res = Resources::os_res[host_os.toStdString()];
if (os_res==NULL) return; if (os_res==nullptr) return;
list<string> protocols; list<string> protocols;
os_res->getResourceStrList("/FWBuilderResources/Target/protocols/state_sync", os_res->getResourceStrList("/FWBuilderResources/Target/protocols/state_sync",
protocols); protocols);
@ -506,7 +506,7 @@ void getStateSyncTypesForOS(const QString &host_os, std::list<QStringPair> &res)
void getFailoverTypesForOS(const QString &host_os, std::list<QStringPair> &res) void getFailoverTypesForOS(const QString &host_os, std::list<QStringPair> &res)
{ {
Resources* os_res = Resources::os_res[host_os.toStdString()]; Resources* os_res = Resources::os_res[host_os.toStdString()];
if (os_res==NULL) return; if (os_res==nullptr) return;
list<string> protocols; list<string> protocols;
os_res->getResourceStrList("/FWBuilderResources/Target/protocols/failover", os_res->getResourceStrList("/FWBuilderResources/Target/protocols/failover",
protocols); protocols);
@ -518,7 +518,7 @@ void getInterfaceTypes(Interface *iface, list<QStringPair> &res)
FWObject *fw = iface->getParent(); FWObject *fw = iface->getParent();
string host_os = fw->getStr("host_OS"); string host_os = fw->getStr("host_OS");
Resources* os_res = Resources::os_res[host_os]; Resources* os_res = Resources::os_res[host_os];
if (os_res==NULL) return; if (os_res==nullptr) return;
list<string> interface_types; list<string> interface_types;
if (Cluster::isA(fw)) if (Cluster::isA(fw))
@ -546,11 +546,11 @@ void getSubInterfaceTypes(Interface *iface, list<QStringPair> &res)
{ {
FWObject *p = Host::getParentHost(iface); FWObject *p = Host::getParentHost(iface);
//FWObject *p = iface->getParentHost(); //FWObject *p = iface->getParentHost();
assert(p!=NULL); assert(p!=nullptr);
QString host_os = p->getStr("host_OS").c_str(); QString host_os = p->getStr("host_OS").c_str();
Resources* os_res = Resources::os_res[host_os.toStdString()]; Resources* os_res = Resources::os_res[host_os.toStdString()];
if (os_res==NULL) return; if (os_res==nullptr) return;
FWOptions *ifopt; FWOptions *ifopt;
ifopt = Interface::cast(iface)->getOptionsObject(); ifopt = Interface::cast(iface)->getOptionsObject();
@ -589,13 +589,13 @@ void setInterfaceTypes(QComboBox *iface_type,
// it could be one. // it could be one.
FWObject *p = Host::getParentHost(iface); FWObject *p = Host::getParentHost(iface);
//FWObject *p = iface->getParentHost(); //FWObject *p = iface->getParentHost();
assert(p!=NULL); assert(p!=nullptr);
QString host_os = p->getStr("host_OS").c_str(); QString host_os = p->getStr("host_OS").c_str();
QString obj_name = iface->getName().c_str(); QString obj_name = iface->getName().c_str();
Resources* os_res = Resources::os_res[p->getStr("host_OS")]; Resources* os_res = Resources::os_res[p->getStr("host_OS")];
string os_family = p->getStr("host_OS"); string os_family = p->getStr("host_OS");
if (os_res!=NULL) if (os_res!=nullptr)
os_family = os_res->getResourceStr("/FWBuilderResources/Target/family"); os_family = os_res->getResourceStr("/FWBuilderResources/Target/family");
std::unique_ptr<interfaceProperties> int_prop( std::unique_ptr<interfaceProperties> int_prop(
@ -746,7 +746,7 @@ QString getRuleAction(Rule *rule)
QString getActionNameForPlatform(Firewall *fw, Rule *rule) QString getActionNameForPlatform(Firewall *fw, Rule *rule)
{ {
if (fw==NULL) return ""; if (fw==nullptr) return "";
PolicyRule *policy_rule = PolicyRule::cast(rule); PolicyRule *policy_rule = PolicyRule::cast(rule);
NATRule *nat_rule = NATRule::cast(rule); NATRule *nat_rule = NATRule::cast(rule);
string act; string act;
@ -757,7 +757,7 @@ QString getActionNameForPlatform(Firewall *fw, Rule *rule)
QString getActionNameForPlatform(Firewall *fw, const std::string &action) QString getActionNameForPlatform(Firewall *fw, const std::string &action)
{ {
if (fw==NULL) return ""; if (fw==nullptr) return "";
string platform = fw->getStr("platform"); string platform = fw->getStr("platform");
string name; string name;
try try
@ -1052,11 +1052,11 @@ void _repackStringList(list<string> &list1, list<QStringPair> &list2)
void setDefaultStateSyncGroupAttributes(StateSyncClusterGroup *grp) void setDefaultStateSyncGroupAttributes(StateSyncClusterGroup *grp)
{ {
FWObject *p = grp; FWObject *p = grp;
while (p && Cluster::cast(p)==NULL) p = p->getParent(); while (p && Cluster::cast(p)==nullptr) p = p->getParent();
assert(p != NULL); assert(p != nullptr);
Cluster *cluster = Cluster::cast(p); Cluster *cluster = Cluster::cast(p);
Resources *os_res = Resources::os_res[cluster->getStr("host_OS")]; Resources *os_res = Resources::os_res[cluster->getStr("host_OS")];
assert(os_res != NULL); assert(os_res != nullptr);
list<string> protocols; list<string> protocols;
os_res->getResourceStrList("/FWBuilderResources/Target/protocols/state_sync", os_res->getResourceStrList("/FWBuilderResources/Target/protocols/state_sync",
@ -1071,14 +1071,14 @@ void setDefaultStateSyncGroupAttributes(StateSyncClusterGroup *grp)
void setDefaultFailoverGroupAttributes(FailoverClusterGroup *grp) void setDefaultFailoverGroupAttributes(FailoverClusterGroup *grp)
{ {
FWObject *p = grp; FWObject *p = grp;
while (p && Cluster::cast(p)==NULL) p = p->getParent(); while (p && Cluster::cast(p)==nullptr) p = p->getParent();
assert(p != NULL); assert(p != nullptr);
Cluster *cluster = Cluster::cast(p); Cluster *cluster = Cluster::cast(p);
Resources *os_res = Resources::os_res[cluster->getStr("host_OS")]; Resources *os_res = Resources::os_res[cluster->getStr("host_OS")];
assert(os_res != NULL); assert(os_res != nullptr);
FWOptions *gropt = grp-> getOptionsObject(); FWOptions *gropt = grp-> getOptionsObject();
assert(gropt != NULL); assert(gropt != nullptr);
string failover_protocol = grp->getStr("type"); string failover_protocol = grp->getStr("type");

View File

@ -79,7 +79,7 @@ procurveaclAdvancedDialog::procurveaclAdvancedDialog(QWidget *parent,FWObject *o
obj=o; obj=o;
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
// As of 4.1.0 we do not support scp install method for Procurve // As of 4.1.0 we do not support scp install method for Procurve
// I could not figure out how to copy configuration to the switch // I could not figure out how to copy configuration to the switch
@ -201,7 +201,7 @@ procurveaclAdvancedDialog::procurveaclAdvancedDialog(QWidget *parent,FWObject *o
} }
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.registerOption(m_dialog->ipv4before_2, fwoptions, data.registerOption(m_dialog->ipv4before_2, fwoptions,
"ipv4_6_order", "ipv4_6_order",
@ -326,10 +326,10 @@ void procurveaclAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* options = Firewall::cast(new_state)->getOptionsObject(); FWOptions* options = Firewall::cast(new_state)->getOptionsObject();
assert(options!=NULL); assert(options!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(options); data.saveAll(options);

View File

@ -62,10 +62,10 @@ secuwallAdvancedDialog::secuwallAdvancedDialog(QWidget *parent, FWObject *o)
setWindowTitle(QObject::tr("%1 advanced settings").arg(description.c_str())); setWindowTitle(QObject::tr("%1 advanced settings").arg(description.c_str()));
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.registerOption(m_dialog->logTCPseq, fwoptions, "log_tcp_seq"); data.registerOption(m_dialog->logTCPseq, fwoptions, "log_tcp_seq");
data.registerOption(m_dialog->logTCPopt, fwoptions, "log_tcp_opt"); data.registerOption(m_dialog->logTCPopt, fwoptions, "log_tcp_opt");
@ -198,10 +198,10 @@ void secuwallAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
Management *mgmt = (Firewall::cast(new_state))->getManagementObject(); Management *mgmt = (Firewall::cast(new_state))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -41,7 +41,7 @@ secuwallIfaceOptsDialog::secuwallIfaceOptsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *ifopt = (Interface::cast(obj))->getOptionsObject(); FWOptions *ifopt = (Interface::cast(obj))->getOptionsObject();
cluster_interface = (Cluster::cast(obj->getParent()) != NULL); cluster_interface = (Cluster::cast(obj->getParent()) != nullptr);
setInterfaceTypes(m_dialog->iface_type, Interface::cast(obj), setInterfaceTypes(m_dialog->iface_type, Interface::cast(obj),
ifopt->getStr("type").c_str()); ifopt->getStr("type").c_str());
@ -100,7 +100,7 @@ void secuwallIfaceOptsDialog::accept()
// new_state is a copy of the interface object // new_state is a copy of the interface object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* ifopt = Interface::cast(new_state)->getOptionsObject(); FWOptions* ifopt = Interface::cast(new_state)->getOptionsObject();
assert(ifopt!=NULL); assert(ifopt!=nullptr);
if (cluster_interface) if (cluster_interface)
{ {

View File

@ -55,7 +55,7 @@ secuwallosAdvancedDialog::secuwallosAdvancedDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *fwopt = (Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt = (Firewall::cast(obj))->getOptionsObject();
assert(fwopt != NULL); assert(fwopt != nullptr);
// mappings from value to QComboBox index // mappings from value to QComboBox index
QStringList threeStateMapping; QStringList threeStateMapping;
@ -235,7 +235,7 @@ void secuwallosAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);
@ -328,7 +328,7 @@ void secuwallosAdvancedDialog::buttonOpenURLClicked()
bool secuwallosAdvancedDialog::validate() bool secuwallosAdvancedDialog::validate()
{ {
bool valid = true; bool valid = true;
QWidget *focus = NULL; QWidget *focus = nullptr;
QString message; QString message;
// widgets to verify // widgets to verify

View File

@ -100,7 +100,7 @@ void ND_ChooseObjectTypePage::changeTargetObject(const QString &buf)
{ {
QTreeWidgetItem* item = m_dialog->typeChangingList->topLevelItem(0); QTreeWidgetItem* item = m_dialog->typeChangingList->topLevelItem(0);
while (item!=0) while (item!=nullptr)
{ {
if (item->isSelected()) if (item->isSelected())
{ {

View File

@ -77,7 +77,7 @@ void ND_CreateObjectsPage::initializePage()
m_dialog->progressBar->setFormat("%v / %m"); m_dialog->progressBar->setFormat("%v / %m");
m_dialog->progressBar->setMaximum(objectsToUse->size() / 2 + networks->size()); m_dialog->progressBar->setMaximum(objectsToUse->size() / 2 + networks->size());
FWObject *last_object = NULL; FWObject *last_object = nullptr;
string type, name, a; string type, name, a;
int counter = 0; int counter = 0;
@ -90,7 +90,7 @@ void ND_CreateObjectsPage::initializePage()
Address *net = Address::cast( Address *net = Address::cast(
mw->createObject(type.c_str(), name.c_str())); mw->createObject(type.c_str(), name.c_str()));
assert(net!=NULL); assert(net!=nullptr);
net->setName(name); net->setName(name);
net->setAddress(od.addr); net->setAddress(od.addr);
@ -123,7 +123,7 @@ void ND_CreateObjectsPage::initializePage()
if (type==Host::TYPENAME || type==Firewall::TYPENAME) if (type==Host::TYPENAME || type==Firewall::TYPENAME)
{ {
FWObject *o=NULL; FWObject *o=nullptr;
o = mw->createObject(type.c_str(), name.c_str()); o = mw->createObject(type.c_str(), name.c_str());
o->setName(name); o->setName(name);
@ -239,7 +239,7 @@ void ND_CreateObjectsPage::initializePage()
"important to review and fix generated objects if you " "important to review and fix generated objects if you "
"use MAC address spoofing." "use MAC address spoofing."
), ),
tr("&Continue"), 0, 0, tr("&Continue"), nullptr, nullptr,
0 ); 0 );
@ -254,7 +254,7 @@ void ND_CreateObjectsPage::initializePage()
FWObject *intf = addInterface( FWObject *intf = addInterface(
o, in, in->subinterfaces.size()!=0); o, in, in->subinterfaces.size()!=0);
if (intf == NULL) continue; if (intf == nullptr) continue;
list<InterfaceData*>::iterator sit; list<InterfaceData*>::iterator sit;
for (sit=in->subinterfaces.begin(); for (sit=in->subinterfaces.begin();
@ -281,7 +281,7 @@ void ND_CreateObjectsPage::initializePage()
Network *net=dynamic_cast<Network*>( Network *net=dynamic_cast<Network*>(
mw->createObject(type.c_str(),name.c_str()) mw->createObject(type.c_str(),name.c_str())
); );
assert(net!=NULL); assert(net!=nullptr);
net->setName(name); net->setName(name);
net->setAddress(InetAddr(a)); net->setAddress(InetAddr(a));
net->setNetmask(InetAddr(InetAddr(a))); net->setNetmask(InetAddr(InetAddr(a)));
@ -291,7 +291,7 @@ void ND_CreateObjectsPage::initializePage()
IPv4 *obj=dynamic_cast<IPv4*>( IPv4 *obj=dynamic_cast<IPv4*>(
mw->createObject(type.c_str(),name.c_str()) mw->createObject(type.c_str(),name.c_str())
); );
assert(obj!=NULL); assert(obj!=nullptr);
obj->setName(name); obj->setName(name);
obj->setAddress(InetAddr(a)); obj->setAddress(InetAddr(a));
obj->setNetmask(InetAddr(InetAddr::getAllOnes())); obj->setNetmask(InetAddr(InetAddr::getAllOnes()));
@ -322,13 +322,13 @@ FWObject* ND_CreateObjectsPage::addInterface(FWObject *parent, InterfaceData *in
if ( ! includeUnnumbered && ! skip_ip_address_check) if ( ! includeUnnumbered && ! skip_ip_address_check)
{ {
if (in->addr_mask.size()==0) return NULL; if (in->addr_mask.size()==0) return nullptr;
if (in->addr_mask.front()->getAddressPtr()->isAny()) if (in->addr_mask.front()->getAddressPtr()->isAny())
return NULL; return nullptr;
} }
QString obj_name = in->name.c_str(); QString obj_name = in->name.c_str();
Interface *itf = NULL; Interface *itf = nullptr;
itf = Interface::cast( itf = Interface::cast(
mw->createObject(parent, mw->createObject(parent,
QString(Interface::TYPENAME), obj_name)); QString(Interface::TYPENAME), obj_name));

View File

@ -60,10 +60,10 @@ solarisAdvancedDialog::solarisAdvancedDialog(QWidget *parent,FWObject *o)
obj=o; obj=o;
FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject(); FWOptions *fwopt=(Firewall::cast(obj))->getOptionsObject();
assert(fwopt!=NULL); assert(fwopt!=nullptr);
Management *mgmt=(Firewall::cast(obj))->getManagementObject(); Management *mgmt=(Firewall::cast(obj))->getManagementObject();
assert(mgmt!=NULL); assert(mgmt!=nullptr);
QStringList threeStateMapping; QStringList threeStateMapping;
@ -119,7 +119,7 @@ void solarisAdvancedDialog::accept()
// new_state is a copy of the fw object // new_state is a copy of the fw object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject(); FWOptions* fwoptions = Firewall::cast(new_state)->getOptionsObject();
assert(fwoptions!=NULL); assert(fwoptions!=nullptr);
data.saveAll(fwoptions); data.saveAll(fwoptions);

View File

@ -52,7 +52,7 @@ vlanOnlyIfaceOptsDialog::vlanOnlyIfaceOptsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *ifopt = (Interface::cast(obj))->getOptionsObject(); FWOptions *ifopt = (Interface::cast(obj))->getOptionsObject();
cluster_interface = (Cluster::cast(obj->getParent()) != NULL); cluster_interface = (Cluster::cast(obj->getParent()) != nullptr);
setInterfaceTypes(m_dialog->iface_type, Interface::cast(obj), setInterfaceTypes(m_dialog->iface_type, Interface::cast(obj),
ifopt->getStr("type").c_str()); ifopt->getStr("type").c_str());
@ -95,7 +95,7 @@ void vlanOnlyIfaceOptsDialog::accept()
// new_state is a copy of the interface object // new_state is a copy of the interface object
FWObject* new_state = cmd->getNewState(); FWObject* new_state = cmd->getNewState();
FWOptions* ifopt = Interface::cast(new_state)->getOptionsObject(); FWOptions* ifopt = Interface::cast(new_state)->getOptionsObject();
assert(ifopt!=NULL); assert(ifopt!=nullptr);
if (cluster_interface) if (cluster_interface)
{ {
@ -150,7 +150,7 @@ bool vlanOnlyIfaceOptsDialog::validate()
QString combobox = m_dialog->iface_type->currentText(); QString combobox = m_dialog->iface_type->currentText();
QString type = m_dialog->iface_type->itemData( QString type = m_dialog->iface_type->itemData(
m_dialog->iface_type->currentIndex()).toString(); m_dialog->iface_type->currentIndex()).toString();
QWidget *focus = NULL; QWidget *focus = nullptr;
QString message; QString message;
if (type == "vrrp") if (type == "vrrp")

View File

@ -50,7 +50,7 @@ vrrpOptionsDialog::vrrpOptionsDialog(QWidget *parent, FWObject *o)
obj = o; obj = o;
FWOptions *gropt = FWOptions::cast(obj); FWOptions *gropt = FWOptions::cast(obj);
assert(gropt != NULL); assert(gropt != nullptr);
data.registerOption(m_dialog->vrrp_secret, data.registerOption(m_dialog->vrrp_secret,
gropt, gropt,
@ -99,7 +99,7 @@ void vrrpOptionsDialog::reject()
bool vrrpOptionsDialog::validate() bool vrrpOptionsDialog::validate()
{ {
bool valid = true; bool valid = true;
QWidget *focus = NULL; QWidget *focus = nullptr;
QString message; QString message;
// vrrp secret must be set // vrrp secret must be set

View File

@ -65,7 +65,7 @@ using namespace libfwbuilder;
using namespace fwcompiler; using namespace fwcompiler;
FWObjectDatabase *objdb = NULL; FWObjectDatabase *objdb = nullptr;
class UpgradePredicate: public XMLTools::UpgradePredicate class UpgradePredicate: public XMLTools::UpgradePredicate
{ {

View File

@ -61,7 +61,7 @@ TableFactory::TableFactory(BaseCompiler *comp, Firewall *fwall,
firewall = fwall; firewall = fwall;
ruleSetName = ""; ruleSetName = "";
group_registry = _group_registry; group_registry = _group_registry;
dbroot = NULL; dbroot = nullptr;
persistent_tables = new ObjectGroup(); persistent_tables = new ObjectGroup();
persistent_tables->setName("PF Tables"); persistent_tables->setName("PF Tables");
persistent_objects->add(persistent_tables); persistent_objects->add(persistent_tables);
@ -93,7 +93,7 @@ string TableFactory::generateTblID(RuleElement *re)
for (FWObject::iterator i=re->begin(); i!=re->end(); i++) for (FWObject::iterator i=re->begin(); i!=re->end(); i++)
{ {
FWObject *o = *i; FWObject *o = *i;
if (FWReference::cast(o)!=NULL) o=FWReference::cast(o)->getPointer(); if (FWReference::cast(o)!=nullptr) o=FWReference::cast(o)->getPointer();
lids.push_back(FWObjectDatabase::getStringId(o->getId())); lids.push_back(FWObjectDatabase::getStringId(o->getId()));
} }
lids.sort(); lids.sort();
@ -165,7 +165,7 @@ void TableFactory::createTablesForRE(RuleElement *re, Rule *rule)
string tblID = generateTblID(re); string tblID = generateTblID(re);
FWObject *tblgrp = NULL; FWObject *tblgrp = nullptr;
list<FWObject*> objects_in_groups; list<FWObject*> objects_in_groups;
list<FWObject*> objects; list<FWObject*> objects;
@ -309,7 +309,7 @@ string TableFactory::PrintTables()
output << "table "; output << "table ";
output << "<" << grp->getName() << "> "; output << "<" << grp->getName() << "> ";
MultiAddressRunTime *atrt = MultiAddressRunTime::cast(grp); MultiAddressRunTime *atrt = MultiAddressRunTime::cast(grp);
if (atrt!=NULL && if (atrt!=nullptr &&
atrt->getSubstitutionTypeName()==AddressTable::TYPENAME) atrt->getSubstitutionTypeName()==AddressTable::TYPENAME)
{ {
output << "persist"; output << "persist";
@ -332,10 +332,10 @@ string TableFactory::PrintTables()
{ {
if (i!=grp->begin()) output << ", "; if (i!=grp->begin()) output << ", ";
FWObject *o = FWReference::getObject(*i); FWObject *o = FWReference::getObject(*i);
if (o==NULL) compiler->abort("broken table object "); if (o==nullptr) compiler->abort("broken table object ");
MultiAddressRunTime *atrt = MultiAddressRunTime::cast(o); MultiAddressRunTime *atrt = MultiAddressRunTime::cast(o);
if (atrt!=NULL) if (atrt!=nullptr)
{ {
if (atrt->getSubstitutionTypeName()==DNSName::TYPENAME) if (atrt->getSubstitutionTypeName()==DNSName::TYPENAME)
{ {
@ -353,7 +353,7 @@ string TableFactory::PrintTables()
} else } else
{ {
Address *A=Address::cast( o ); Address *A=Address::cast( o );
if (A==NULL) if (A==nullptr)
compiler->abort("table object must be an address: '" + compiler->abort("table object must be an address: '" +
o->getTypeName()+"'"); o->getTypeName()+"'");

View File

@ -65,7 +65,7 @@ using namespace libfwbuilder;
using namespace fwcompiler; using namespace fwcompiler;
FWObjectDatabase *objdb = NULL; FWObjectDatabase *objdb = nullptr;
class UpgradePredicate: public XMLTools::UpgradePredicate class UpgradePredicate: public XMLTools::UpgradePredicate

View File

@ -65,7 +65,7 @@ using namespace libfwbuilder;
using namespace fwcompiler; using namespace fwcompiler;
FWObjectDatabase *objdb = NULL; FWObjectDatabase *objdb = nullptr;
class UpgradePredicate: public XMLTools::UpgradePredicate class UpgradePredicate: public XMLTools::UpgradePredicate
{ {