diff --git a/include/znc/Modules.h b/include/znc/Modules.h index 6f1531c3..f6ab6dd9 100644 --- a/include/znc/Modules.h +++ b/include/znc/Modules.h @@ -509,7 +509,7 @@ public: virtual EModRet OnBroadcast(CString& sMessage); /** This module hook is called when a user mode on a channel changes. - * @param pOpNick The nick who sent the mode change, or NULL if set by server. + * @param pOpNick The nick who sent the mode change, or nullptr if set by server. * @param Nick The nick whose channel mode changes. * @param Channel The channel on which the user mode is changed. * @param uMode The mode character that is changed, e.g. '@' for op. @@ -534,7 +534,7 @@ public: virtual void OnDevoice2(const CNick* pOpNick, const CNick& Nick, CChan& Channel, bool bNoChange); virtual void OnDevoice(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange); /** Called on an individual channel mode change. - * @param pOpNick The nick who changes the channel mode, or NULL if set by server. + * @param pOpNick The nick who changes the channel mode, or nullptr if set by server. * @param Channel The channel whose mode is changed. * @param uMode The mode character that is changed. * @param sArg The argument to the mode character, if any. @@ -545,7 +545,7 @@ public: virtual void OnMode(const CNick& OpNick, CChan& Channel, char uMode, const CString& sArg, bool bAdded, bool bNoChange); /** Called on any channel mode change. This is called before the more * detailed mode hooks like e.g. OnOp() and OnMode(). - * @param pOpNick The nick who changes the channel mode, or NULL if set by server. + * @param pOpNick The nick who changes the channel mode, or nullptr if set by server. * @param Channel The channel whose mode is changed. * @param sModes The raw mode change, e.g. "+s-io". * @param sArgs All arguments to the mode change from sModes. @@ -953,7 +953,7 @@ public: bool AddCommand(const CString& sCmd, const CString& sArgs, const CString& sDesc, std::function func); /// @return True if the command was successfully removed. bool RemCommand(const CString& sCmd); - /// @return The CModCommand instance or NULL if none was found. + /// @return The CModCommand instance or nullptr if none was found. const CModCommand* FindCommand(const CString& sCmd) const; /** This function tries to dispatch the given command via the correct * instance of CModCommand. Before this can be called, commands have to @@ -999,12 +999,12 @@ public: const CString& GetModPath() const { return m_sModPath; } /** @returns For user modules this returns the user for which this - * module was loaded. For global modules this returns NULL, + * module was loaded. For global modules this returns nullptr, * except when we are in a user-specific module hook in which * case this is the user pointer. */ CUser* GetUser() const { return m_pUser; } - /** @returns NULL except when we are in a client-specific module hook in + /** @returns nullptr except when we are in a client-specific module hook in * which case this is the client for which the hook is called. */ CIRCNetwork* GetNetwork() const { return m_pNetwork; } diff --git a/include/znc/Utils.h b/include/znc/Utils.h index b1a314ed..5333d4e3 100644 --- a/include/znc/Utils.h +++ b/include/znc/Utils.h @@ -310,9 +310,9 @@ public: } /** - * @brief Performs a Cleanup() and returns a pointer to the object, or NULL + * @brief Performs a Cleanup() and returns a pointer to the object, or nullptr * @param Item The item to check for - * @return Pointer to the item or NULL if there is no suitable one + * @return Pointer to the item or nullptr if there is no suitable one */ V* GetItem(const K& Item) { Cleanup(); diff --git a/include/znc/main.h b/include/znc/main.h index 254937e3..db173d5e 100644 --- a/include/znc/main.h +++ b/include/znc/main.h @@ -107,7 +107,7 @@ extern bool ZNC_NO_NEED_TO_DO_ANYTHING_ON_MODULE_CALL_EXITER; *macEXITER = true; \ break; \ } \ - if (macNETWORK != NULL) { \ + if (macNETWORK != nullptr) { \ CModules& NMods = macNETWORK->GetModules(); \ CClient* pOldNClient = NMods.GetClient(); \ NMods.SetClient(macCLIENT); \ @@ -120,10 +120,10 @@ extern bool ZNC_NO_NEED_TO_DO_ANYTHING_ON_MODULE_CALL_EXITER; } while (false) #define GLOBALMODULECALL(macFUNC, macEXITER) \ - _GLOBALMODULECALL(macFUNC, NULL, NULL, NULL, macEXITER) + _GLOBALMODULECALL(macFUNC, nullptr, nullptr, nullptr, macEXITER) #define USERMODULECALL(macFUNC, macUSER, macCLIENT, macEXITER) \ - _USERMODULECALL(macFUNC, macUSER, NULL, macCLIENT, macEXITER) + _USERMODULECALL(macFUNC, macUSER, nullptr, macCLIENT, macEXITER) /** @mainpage * Welcome to the API documentation for ZNC. diff --git a/modules/alias.cpp b/modules/alias.cpp index 149f3256..3777d83a 100644 --- a/modules/alias.cpp +++ b/modules/alias.cpp @@ -72,7 +72,7 @@ public: } // constructors - CAlias() : parent(NULL) {} + CAlias() : parent(nullptr) {} CAlias(CModule *new_parent, const CString &new_name) : parent(new_parent) { SetName(new_name); } // produce a command string from this alias' command list @@ -330,7 +330,7 @@ public: } catch (std::exception &e) { - CString my_nick = (GetNetwork() == NULL ? "" : GetNetwork()->GetCurNick()); + CString my_nick = (GetNetwork() == nullptr ? "" : GetNetwork()->GetCurNick()); if (my_nick.empty()) my_nick = "*"; PutUser(CString(":znc.in 461 " + my_nick + " " + current_alias.GetName() + " :ZNC alias error: ") + e.what()); return HALTCORE; diff --git a/modules/autoop.cpp b/modules/autoop.cpp index 77e590d2..18421afc 100644 --- a/modules/autoop.cpp +++ b/modules/autoop.cpp @@ -401,7 +401,7 @@ public: CAutoOpUser* FindUser(const CString& sUser) { map::iterator it = m_msUsers.find(sUser.AsLower()); - return (it != m_msUsers.end()) ? it->second : NULL; + return (it != m_msUsers.end()) ? it->second : nullptr; } CAutoOpUser* FindUserByHost(const CString& sHostmask, const CString& sChannel = "") { @@ -413,7 +413,7 @@ public: } } - return NULL; + return nullptr; } bool CheckAutoOp(const CNick& Nick, CChan& Channel) { @@ -452,7 +452,7 @@ public: CAutoOpUser* AddUser(const CString& sUser, const CString& sKey, const CString& sHosts, const CString& sChans) { if (m_msUsers.find(sUser) != m_msUsers.end()) { PutModule("That user already exists"); - return NULL; + return nullptr; } CAutoOpUser* pUser = new CAutoOpUser(sUser, sKey, sHosts, sChans); @@ -465,7 +465,7 @@ public: // Validate before responding - don't blindly trust everyone bool bValid = false; bool bMatchedHost = false; - CAutoOpUser* pUser = NULL; + CAutoOpUser* pUser = nullptr; for (map::iterator it = m_msUsers.begin(); it != m_msUsers.end(); ++it) { pUser = it->second; diff --git a/modules/autovoice.cpp b/modules/autovoice.cpp index c47cf61a..6e449bf1 100644 --- a/modules/autovoice.cpp +++ b/modules/autovoice.cpp @@ -267,7 +267,7 @@ public: CAutoVoiceUser* FindUser(const CString& sUser) { map::iterator it = m_msUsers.find(sUser.AsLower()); - return (it != m_msUsers.end()) ? it->second : NULL; + return (it != m_msUsers.end()) ? it->second : nullptr; } CAutoVoiceUser* FindUserByHost(const CString& sHostmask, const CString& sChannel = "") { @@ -279,7 +279,7 @@ public: } } - return NULL; + return nullptr; } void DelUser(const CString& sUser) { @@ -298,7 +298,7 @@ public: CAutoVoiceUser* AddUser(const CString& sUser, const CString& sHost, const CString& sChans) { if (m_msUsers.find(sUser) != m_msUsers.end()) { PutModule("That user already exists"); - return NULL; + return nullptr; } CAutoVoiceUser* pUser = new CAutoVoiceUser(sUser, sHost, sChans); diff --git a/modules/awaystore.cpp b/modules/awaystore.cpp index 116d8fda..1a706641 100644 --- a/modules/awaystore.cpp +++ b/modules/awaystore.cpp @@ -355,7 +355,7 @@ public: else if (!sReason.empty()) m_sReason = sReason; - time_t iTime = time(NULL); + time_t iTime = time(nullptr); char *pTime = ctime(&iTime); CString sTime; if (pTime) @@ -393,14 +393,14 @@ public: EModRet OnPrivMsg(CNick& Nick, CString& sMessage) override { if (m_bIsAway) - AddMessage(time(NULL), Nick, sMessage); + AddMessage(time(nullptr), Nick, sMessage); return(CONTINUE); } EModRet OnPrivAction(CNick& Nick, CString& sMessage) override { if (m_bIsAway) { - AddMessage(time(NULL), Nick, "* " + sMessage); + AddMessage(time(nullptr), Nick, "* " + sMessage); } return(CONTINUE); } @@ -433,7 +433,7 @@ public: } time_t GetTimeStamp() const { return(m_iLastSentData); } - void Ping() { m_iLastSentData = time(NULL); } + void Ping() { m_iLastSentData = time(nullptr); } time_t GetAwayTime() { return m_iAutoAway; } void SetAwayTime(time_t u) { m_iAutoAway = u; } @@ -505,7 +505,7 @@ void CAwayJob::RunJob() if (!p->IsAway()) { - time_t iNow = time(NULL); + time_t iNow = time(nullptr); if ((iNow - p->GetTimeStamp()) > p->GetAwayTime() && p->GetAwayTime() != 0) p->Away(); diff --git a/modules/bouncedcc.cpp b/modules/bouncedcc.cpp index af21ee8b..c429b5fb 100644 --- a/modules/bouncedcc.cpp +++ b/modules/bouncedcc.cpp @@ -278,7 +278,7 @@ CDCCBounce::CDCCBounce(CBounceDCCMod* pMod, unsigned long uLongIP, unsigned shor m_pModule = pMod; m_bIsChat = bIsChat; m_sLocalIP = pMod->GetLocalDCCIP(); - m_pPeer = NULL; + m_pPeer = nullptr; m_bIsRemote = false; if (bIsChat) { @@ -294,7 +294,7 @@ CDCCBounce::CDCCBounce(CBounceDCCMod* pMod, const CString& sHostname, unsigned s m_uRemotePort = 0; m_bIsChat = bIsChat; m_pModule = pMod; - m_pPeer = NULL; + m_pPeer = nullptr; m_sRemoteNick = sRemoteNick; m_sFileName = sFileName; m_sRemoteIP = sRemoteIP; @@ -311,7 +311,7 @@ CDCCBounce::CDCCBounce(CBounceDCCMod* pMod, const CString& sHostname, unsigned s CDCCBounce::~CDCCBounce() { if (m_pPeer) { m_pPeer->Shutdown(); - m_pPeer = NULL; + m_pPeer = nullptr; } } @@ -409,7 +409,7 @@ void CDCCBounce::Disconnected() { } void CDCCBounce::Shutdown() { - m_pPeer = NULL; + m_pPeer = nullptr; DEBUG(GetSockName() << " == Close(); because my peer told me to"); Close(); } diff --git a/modules/certauth.cpp b/modules/certauth.cpp index 6f017ec4..d4e46101 100644 --- a/modules/certauth.cpp +++ b/modules/certauth.cpp @@ -51,7 +51,7 @@ public: for (MCString::const_iterator it1 = BeginNV(); it1 != EndNV(); ++it1) { VCString vsKeys; - if (CZNC::Get().FindUser(it1->first) == NULL) { + if (CZNC::Get().FindUser(it1->first) == nullptr) { DEBUG("Unknown user in saved data [" + it1->first + "]"); continue; } @@ -106,7 +106,7 @@ public: Csock *pSock = Auth->GetSocket(); CUser *pUser = CZNC::Get().FindUser(sUser); - if (pSock == NULL || pUser == NULL) + if (pSock == nullptr || pUser == nullptr) return CONTINUE; const CString sPubKey = GetKey(pSock); diff --git a/modules/clientnotify.cpp b/modules/clientnotify.cpp index 40d96d34..d2cf2d34 100644 --- a/modules/clientnotify.cpp +++ b/modules/clientnotify.cpp @@ -35,10 +35,10 @@ protected: void SendNotification(const CString& sMessage) { if(m_sMethod == "message") { - GetUser()->PutStatus(sMessage, NULL, GetClient()); + GetUser()->PutStatus(sMessage, nullptr, GetClient()); } else if(m_sMethod == "notice") { - GetUser()->PutStatusNotice(sMessage, NULL, GetClient()); + GetUser()->PutStatusNotice(sMessage, nullptr, GetClient()); } } diff --git a/modules/controlpanel.cpp b/modules/controlpanel.cpp index 04ae64ca..c1aad504 100644 --- a/modules/controlpanel.cpp +++ b/modules/controlpanel.cpp @@ -149,11 +149,11 @@ class CAdminMod : public CModule { CUser *pUser = CZNC::Get().FindUser(sUsername); if (!pUser) { PutModule("Error: User [" + sUsername + "] not found."); - return NULL; + return nullptr; } if (pUser != GetUser() && !GetUser()->IsAdmin()) { PutModule("Error: You need to have admin rights to modify other users!"); - return NULL; + return nullptr; } return pUser; } @@ -440,7 +440,7 @@ class CAdminMod : public CModule { const CString sUsername = sLine.Token(2); const CString sNetwork = sLine.Token(3); - CIRCNetwork *pNetwork = NULL; + CIRCNetwork *pNetwork = nullptr; if (sUsername.empty()) { pNetwork = CModule::GetNetwork(); @@ -497,8 +497,8 @@ class CAdminMod : public CModule { const CString sNetwork = sLine.Token(3); const CString sValue = sLine.Token(4, true); - CUser *pUser = NULL; - CIRCNetwork *pNetwork = NULL; + CUser *pUser = nullptr; + CIRCNetwork *pNetwork = nullptr; if (sUsername.empty()) { pUser = GetUser(); @@ -1285,7 +1285,7 @@ class CAdminMod : public CModule { if (!pUser) return; - LoadModuleFor(pUser->GetModules(), sModName, sArgs, CModInfo::UserModule, pUser, NULL); + LoadModuleFor(pUser->GetModules(), sModName, sArgs, CModInfo::UserModule, pUser, nullptr); } void LoadModuleForNetwork(const CString& sLine) { diff --git a/modules/crypt.cpp b/modules/crypt.cpp index bf7c0aef..67438d4f 100644 --- a/modules/crypt.cpp +++ b/modules/crypt.cpp @@ -69,7 +69,7 @@ public: if (pChan) { if (!pChan->AutoClearChanBuffer()) pChan->AddBuffer(":" + NickPrefix() + _NAMEDFMT(sNickMask) + " PRIVMSG " + _NAMEDFMT(sTarget) + " :{text}", sMessage); - GetUser()->PutUser(":" + NickPrefix() + sNickMask + " PRIVMSG " + sTarget + " :" + sMessage, NULL, GetClient()); + GetUser()->PutUser(":" + NickPrefix() + sNickMask + " PRIVMSG " + sTarget + " :" + sMessage, nullptr, GetClient()); } CString sMsg = MakeIvec() + sMessage; diff --git a/modules/ctcpflood.cpp b/modules/ctcpflood.cpp index e3111366..db43cde6 100644 --- a/modules/ctcpflood.cpp +++ b/modules/ctcpflood.cpp @@ -66,8 +66,8 @@ public: if (sMessage.Token(0).Equals("ACTION")) return CONTINUE; - if (m_tLastCTCP + m_iThresholdSecs < time(NULL)) { - m_tLastCTCP = time(NULL); + if (m_tLastCTCP + m_iThresholdSecs < time(nullptr)) { + m_tLastCTCP = time(nullptr); m_iNumCTCP = 0; } @@ -79,7 +79,7 @@ public: PutModule("Limit reached by [" + Nick.GetHostMask() + "], blocking all CTCP"); // Reset the timeout so that we continue blocking messages - m_tLastCTCP = time(NULL); + m_tLastCTCP = time(nullptr); return HALT; } diff --git a/modules/cyrusauth.cpp b/modules/cyrusauth.cpp index 6167bd51..6595fe5e 100644 --- a/modules/cyrusauth.cpp +++ b/modules/cyrusauth.cpp @@ -72,7 +72,7 @@ public: return false; } - if (sasl_server_init(NULL, NULL) != SASL_OK) { + if (sasl_server_init(nullptr, nullptr) != SASL_OK) { sMessage = "SASL Could Not Be Initialized - Halting Startup"; return false; } @@ -81,8 +81,8 @@ public: m_cbs[0].proc = reinterpret_cast(CSASLAuthMod::getopt); m_cbs[0].context = this; m_cbs[1].id = SASL_CB_LIST_END; - m_cbs[1].proc = NULL; - m_cbs[1].context = NULL; + m_cbs[1].proc = nullptr; + m_cbs[1].context = nullptr; return true; } @@ -91,7 +91,7 @@ public: const CString& sUsername = Auth->GetUsername(); const CString& sPassword = Auth->GetPassword(); CUser *pUser(CZNC::Get().FindUser(sUsername)); - sasl_conn_t *sasl_conn(NULL); + sasl_conn_t *sasl_conn(nullptr); bool bSuccess = false; if (!pUser && !CreateUser()) { @@ -102,7 +102,7 @@ public: if (m_Cache.HasItem(sCacheKey)) { bSuccess = true; DEBUG("saslauth: Found [" + sUsername + "] in cache"); - } else if (sasl_server_new("znc", NULL, NULL, NULL, NULL, m_cbs, 0, &sasl_conn) == SASL_OK && + } else if (sasl_server_new("znc", nullptr, nullptr, nullptr, nullptr, m_cbs, 0, &sasl_conn) == SASL_OK && sasl_checkpass(sasl_conn, sUsername.c_str(), sUsername.size(), sPassword.c_str(), sPassword.size()) == SASL_OK) { m_Cache.AddItem(sCacheKey); @@ -124,13 +124,13 @@ public: if (!pBaseUser) { DEBUG("saslauth: Clone User [" << CloneUser() << "] User not found"); delete pUser; - pUser = NULL; + pUser = nullptr; } if (pUser && !pUser->Clone(*pBaseUser, sErr)) { DEBUG("saslauth: Clone User [" << CloneUser() << "] failed: " << sErr); delete pUser; - pUser = NULL; + pUser = nullptr; } } @@ -142,7 +142,7 @@ public: if (pUser && !CZNC::Get().AddUser(pUser, sErr)) { DEBUG("saslauth: Add user [" << sUsername << "] failed: " << sErr); delete pUser; - pUser = NULL; + pUser = nullptr; } } diff --git a/modules/dcc.cpp b/modules/dcc.cpp index dd928476..0da2e6e7 100644 --- a/modules/dcc.cpp +++ b/modules/dcc.cpp @@ -24,7 +24,7 @@ class CDCCMod; class CDCCSock : public CSocket { public: - CDCCSock(CDCCMod* pMod, const CString& sRemoteNick, const CString& sLocalFile, unsigned long uFileSize = 0, CFile* pFile = NULL); + CDCCSock(CDCCMod* pMod, const CString& sRemoteNick, const CString& sLocalFile, unsigned long uFileSize = 0, CFile* pFile = nullptr); CDCCSock(CDCCMod* pMod, const CString& sRemoteNick, const CString& sRemoteIP, unsigned short uRemotePort, const CString& sLocalFile, unsigned long uFileSize); virtual ~CDCCSock(); @@ -274,7 +274,7 @@ CDCCSock::CDCCSock(CDCCMod* pMod, const CString& sRemoteNick, const CString& sRe m_uFileSize = uFileSize; m_uBytesSoFar = 0; m_pModule = pMod; - m_pFile = NULL; + m_pFile = nullptr; m_sLocalFile = sLocalFile; m_bSend = false; m_bNoDelFile = false; @@ -417,7 +417,7 @@ Csock* CDCCSock::GetSockObj(const CString& sHost, unsigned short uPort) { CFile* CDCCSock::OpenFile(bool bWrite) { if ((m_pFile) || (m_sLocalFile.empty())) { m_pModule->PutModule(((bWrite) ? "DCC <- [" : "DCC -> [") + m_sRemoteNick + "][" + m_sLocalFile + "] - Unable to open file."); - return NULL; + return nullptr; } m_pFile = new CFile(m_sLocalFile); @@ -425,30 +425,30 @@ CFile* CDCCSock::OpenFile(bool bWrite) { if (bWrite) { if (m_pFile->Exists()) { delete m_pFile; - m_pFile = NULL; + m_pFile = nullptr; m_pModule->PutModule("DCC <- [" + m_sRemoteNick + "] - File already exists [" + m_sLocalFile + "]"); - return NULL; + return nullptr; } if (!m_pFile->Open(O_WRONLY | O_TRUNC | O_CREAT)) { delete m_pFile; - m_pFile = NULL; + m_pFile = nullptr; m_pModule->PutModule("DCC <- [" + m_sRemoteNick + "] - Could not open file [" + m_sLocalFile + "]"); - return NULL; + return nullptr; } } else { if (!m_pFile->IsReg()) { delete m_pFile; - m_pFile = NULL; + m_pFile = nullptr; m_pModule->PutModule("DCC -> [" + m_sRemoteNick + "] - Not a file [" + m_sLocalFile + "]"); - return NULL; + return nullptr; } if (!m_pFile->Open()) { delete m_pFile; - m_pFile = NULL; + m_pFile = nullptr; m_pModule->PutModule("DCC -> [" + m_sRemoteNick + "] - Could not open file [" + m_sLocalFile + "]"); - return NULL; + return nullptr; } // The DCC specs only allow file transfers with files smaller @@ -456,9 +456,9 @@ CFile* CDCCSock::OpenFile(bool bWrite) { unsigned long long uFileSize = m_pFile->GetSize(); if (uFileSize > (unsigned long long) 0xffffffffULL) { delete m_pFile; - m_pFile = NULL; + m_pFile = nullptr; m_pModule->PutModule("DCC -> [" + m_sRemoteNick + "] - File too large (>4 GiB) [" + m_sLocalFile + "]"); - return NULL; + return nullptr; } m_uFileSize = uFileSize; diff --git a/modules/fail2ban.cpp b/modules/fail2ban.cpp index f2f483fc..2cffee80 100644 --- a/modules/fail2ban.cpp +++ b/modules/fail2ban.cpp @@ -62,7 +62,7 @@ public: void OnClientConnect(CZNCSock* pClient, const CString& sHost, unsigned short uPort) override { unsigned int *pCount = m_Cache.GetItem(sHost); - if (sHost.empty() || pCount == NULL || *pCount < m_uiAllowedFailed) { + if (sHost.empty() || pCount == nullptr || *pCount < m_uiAllowedFailed) { return; } diff --git a/modules/flooddetach.cpp b/modules/flooddetach.cpp index f1ea4e13..a2fb722d 100644 --- a/modules/flooddetach.cpp +++ b/modules/flooddetach.cpp @@ -70,7 +70,7 @@ public: void Cleanup() { Limits::iterator it; - time_t now = time(NULL); + time_t now = time(nullptr); for (it = m_chans.begin(); it != m_chans.end(); ++it) { // The timeout for this channel did not expire yet? @@ -106,7 +106,7 @@ public: void Message(CChan& Channel) { Limits::iterator it; - time_t now = time(NULL); + time_t now = time(nullptr); // First: Clean up old entries and reattach where necessary Cleanup(); diff --git a/modules/identfile.cpp b/modules/identfile.cpp index b9f4f322..b2f7ca55 100644 --- a/modules/identfile.cpp +++ b/modules/identfile.cpp @@ -35,8 +35,8 @@ public: ""); AddCommand("Show", static_cast(&CIdentFileModule::Show)); - m_pISpoofLockFile = NULL; - m_pIRCSock = NULL; + m_pISpoofLockFile = nullptr; + m_pIRCSock = nullptr; } virtual ~CIdentFileModule() { @@ -94,14 +94,14 @@ public: } bool WriteISpoof() { - if (m_pISpoofLockFile != NULL) { + if (m_pISpoofLockFile != nullptr) { return false; } m_pISpoofLockFile = new CFile; if (!m_pISpoofLockFile->TryExLock(GetNV("File"), O_RDWR | O_CREAT)) { delete m_pISpoofLockFile; - m_pISpoofLockFile = NULL; + m_pISpoofLockFile = nullptr; return false; } @@ -112,7 +112,7 @@ public: if (!m_pISpoofLockFile->Seek(0) || !m_pISpoofLockFile->Truncate()) { delete m_pISpoofLockFile; - m_pISpoofLockFile = NULL; + m_pISpoofLockFile = nullptr; return false; } @@ -135,21 +135,21 @@ public: DEBUG("Releasing ident spoof for user/network [" + (m_pIRCSock ? m_pIRCSock->GetNetwork()->GetUser()->GetUserName() + "/" + m_pIRCSock->GetNetwork()->GetName() : "") + "]"); - SetIRCSock(NULL); + SetIRCSock(nullptr); - if (m_pISpoofLockFile != NULL) { + if (m_pISpoofLockFile != nullptr) { if (m_pISpoofLockFile->Seek(0) && m_pISpoofLockFile->Truncate()) { m_pISpoofLockFile->Write(m_sOrigISpoof); } delete m_pISpoofLockFile; - m_pISpoofLockFile = NULL; + m_pISpoofLockFile = nullptr; } } bool OnLoad(const CString& sArgs, CString& sMessage) override { - m_pISpoofLockFile = NULL; - m_pIRCSock = NULL; + m_pISpoofLockFile = nullptr; + m_pIRCSock = nullptr; if (GetNV("Format").empty()) { SetNV("Format", "global { reply \"%ident%\" }"); @@ -163,7 +163,7 @@ public: } EModRet OnIRCConnecting(CIRCSock *pIRCSock) override { - if (m_pISpoofLockFile != NULL) { + if (m_pISpoofLockFile != nullptr) { DEBUG("Aborting connection, ident spoof lock file exists"); PutModule("Aborting connection, another user or network is currently connecting and using the ident spoof file"); return HALTCORE; diff --git a/modules/keepnick.cpp b/modules/keepnick.cpp index 57fd95a2..328fe068 100644 --- a/modules/keepnick.cpp +++ b/modules/keepnick.cpp @@ -44,7 +44,7 @@ public: ~CKeepNickMod() {} bool OnLoad(const CString& sArgs, CString& sMessage) override { - m_pTimer = NULL; + m_pTimer = nullptr; // Check if we need to start the timer if (GetNetwork()->IsIRCConnected()) @@ -135,7 +135,7 @@ public: m_pTimer->Stop(); RemTimer(m_pTimer); - m_pTimer = NULL; + m_pTimer = nullptr; } EModRet OnUserRaw(CString& sLine) override { @@ -191,7 +191,7 @@ public: } private: - // If this is NULL, we are turned off for some reason + // If this is nullptr, we are turned off for some reason CKeepNickTimer* m_pTimer; }; diff --git a/modules/lastseen.cpp b/modules/lastseen.cpp index af91b51e..416a111c 100644 --- a/modules/lastseen.cpp +++ b/modules/lastseen.cpp @@ -28,7 +28,7 @@ private: } void SetTime(const CUser *pUser) { - SetNV(pUser->GetUserName(), CString(time(NULL))); + SetNV(pUser->GetUserName(), CString(time(nullptr))); } const CString FormatLastSeen(const CUser *pUser, const char* sDefault = "") { @@ -98,7 +98,7 @@ public: bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) override { if (sPageName == "index") { CModules& GModules = CZNC::Get().GetModules(); - Tmpl["WebAdminLoaded"] = CString(GModules.FindModule("webadmin") != NULL); + Tmpl["WebAdminLoaded"] = CString(GModules.FindModule("webadmin") != nullptr); MTimeMulti mmSorted; const MUsers& mUsers = CZNC::Get().GetUserMap(); diff --git a/modules/modperl.cpp b/modules/modperl.cpp index 74a9e42a..d585125a 100644 --- a/modules/modperl.cpp +++ b/modules/modperl.cpp @@ -50,7 +50,7 @@ class CModPerl: public CModule { PerlInterpreter *m_pPerl; public: MODCONSTRUCTOR(CModPerl) { - m_pPerl = NULL; + m_pPerl = nullptr; } #define PSTART dSP; I32 ax; int ret = 0; ENTER; SAVETMPS; PUSHMARK(SP) @@ -69,7 +69,7 @@ public: int argc = 6; char *pArgv[] = {"", "-T", "-w", "-I", const_cast(sTmp.c_str()), - const_cast(sModPath.c_str()), NULL}; + const_cast(sModPath.c_str()), nullptr}; char **argv = pArgv; char *** const pEnviron = #if defined(__APPLE__) && defined(__MACH__) @@ -87,7 +87,7 @@ public: } perl_free(m_pPerl); PERL_SYS_TERM(); - m_pPerl = NULL; + m_pPerl = nullptr; DEBUG(__PRETTY_FUNCTION__ << " can't init perl"); return false; } @@ -319,7 +319,7 @@ void CPerlSocket::ReadLine(const CString& sLine) { } Csock* CPerlSocket::GetSockObj(const CString& sHost, unsigned short uPort) { CPerlModule* pMod = AsPerlModule(GetModule()); - Csock* result = NULL; + Csock* result = nullptr; if (pMod) { SOCKSTART; PUSH_STR("_Accepted"); diff --git a/modules/modperl/codegen.pl b/modules/modperl/codegen.pl index 89b7379a..de4e3cf6 100755 --- a/modules/modperl/codegen.pl +++ b/modules/modperl/codegen.pl @@ -65,7 +65,7 @@ namespace { if (SWIG_IsOK(res)) { return result; } - return NULL; + return nullptr; } }; @@ -94,7 +94,7 @@ while (<$in>) { when ('bool') { $default = 'true' } when ('CModule::EModRet') { $default = 'CONTINUE' } when ('CString') { $default = '""' } - when (/\*$/) { $default = "($type)NULL" } + when (/\*$/) { $default = "($type)nullptr" } } } my @arg = map { diff --git a/modules/modperl/module.h b/modules/modperl/module.h index 88094db3..92bb658e 100644 --- a/modules/modperl/module.h +++ b/modules/modperl/module.h @@ -31,7 +31,7 @@ class CPerlModule : public CModule { public: CPerlModule(CUser* pUser, CIRCNetwork* pNetwork, const CString& sModName, const CString& sDataPath, SV* perlObj) - : CModule(NULL, pUser, pNetwork, sModName, sDataPath) { + : CModule(nullptr, pUser, pNetwork, sModName, sDataPath) { m_perlObj = newSVsv(perlObj); } SV* GetPerlObj() { diff --git a/modules/modperl/pstring.h b/modules/modperl/pstring.h index bf623a6d..a81e9e8f 100644 --- a/modules/modperl/pstring.h +++ b/modules/modperl/pstring.h @@ -54,7 +54,7 @@ class PString : public CString { SV* GetSV(bool bMakeMortal = true) const { - SV* pSV = NULL; + SV* pSV = nullptr; switch (GetType()) { case NUM: pSV = newSVnv(ToDouble()); diff --git a/modules/modpython.cpp b/modules/modpython.cpp index ed263192..de013ea8 100644 --- a/modules/modpython.cpp +++ b/modules/modpython.cpp @@ -54,7 +54,7 @@ public: ptraceback = Py_None; } PyErr_NormalizeException(&ptype, &pvalue, &ptraceback); - PyObject* strlist = PyObject_CallFunctionObjArgs(m_PyFormatException, ptype, pvalue, ptraceback, NULL); + PyObject* strlist = PyObject_CallFunctionObjArgs(m_PyFormatException, ptype, pvalue, ptraceback, nullptr); Py_CLEAR(ptype); Py_CLEAR(pvalue); Py_CLEAR(ptraceback); @@ -83,8 +83,8 @@ public: MODCONSTRUCTOR(CModPython) { Py_Initialize(); - m_PyFormatException = NULL; - m_PyZNCModule = NULL; + m_PyFormatException = nullptr; + m_PyZNCModule = nullptr; } bool OnLoad(const CString& sArgsi, CString& sMessage) override { @@ -205,7 +205,7 @@ public: bSuccess = false; return HALT; } - PyObject* pyRes = PyObject_CallFunctionObjArgs(pyFunc, pMod->GetPyObj(), NULL); + PyObject* pyRes = PyObject_CallFunctionObjArgs(pyFunc, pMod->GetPyObj(), nullptr); if (!pyRes) { sRetMsg = GetPyExceptionStr(); DEBUG("modpython: " << sRetMsg); @@ -351,7 +351,7 @@ public: DEBUG("~CModPython(): couldn't find unload_all: " << sRetMsg); return; } - PyObject* pyRes = PyObject_CallFunctionObjArgs(pyFunc, NULL); + PyObject* pyRes = PyObject_CallFunctionObjArgs(pyFunc, nullptr); if (!pyRes) { CString sRetMsg = GetPyExceptionStr(); DEBUG("modpython tried to unload all modules in its destructor, but: " << sRetMsg); @@ -434,7 +434,7 @@ void CPySocket::ReadLine(const CString& sLine) { } Csock* CPySocket::GetSockObj(const CString& sHost, unsigned short uPort) { - CPySocket* result = NULL; + CPySocket* result = nullptr; PyObject* pyRes = PyObject_CallMethod(m_pyObj, const_cast("_Accepted"), const_cast("sH"), sHost.c_str(), uPort); if (!pyRes) { CString sRetMsg = m_pModPython->GetPyExceptionStr(); @@ -445,7 +445,7 @@ Csock* CPySocket::GetSockObj(const CString& sHost, unsigned short uPort) { if (!SWIG_IsOK(res)) { DEBUG("python socket was expected to return new socket from OnAccepted, but error=" << res); Close(); - result = NULL; + result = nullptr; } if (!result) { DEBUG("modpython: OnAccepted didn't return new socket"); diff --git a/modules/modpython/codegen.pl b/modules/modpython/codegen.pl index 3a77b40d..b18179e4 100755 --- a/modules/modpython/codegen.pl +++ b/modules/modpython/codegen.pl @@ -57,7 +57,7 @@ namespace { m_sType = sType; } bool operator()(PyObject* py, T** result) { - T* x = NULL; + T* x = nullptr; int res = SWIG_ConvertPtr(sv, (void**)&x, SWIG_TypeQuery(m_sType.c_str()), 0); if (SWIG_IsOK(res)) { *result = x; @@ -218,7 +218,7 @@ bool OnFoo(const CString& x) { Py_CLEAR(pyArg2); return default; } - PyObject* pyRes = PyObject_CallMethodObjArgs(m_pyObj, pyName, pyArg1, pyArg2, pyArg3, NULL); + PyObject* pyRes = PyObject_CallMethodObjArgs(m_pyObj, pyName, pyArg1, pyArg2, pyArg3, nullptr); if (!pyRes) { CString s = ...; DEBUG("modpython: username/module/OnFoo failed: " << s); @@ -253,7 +253,7 @@ while (<$in>) { when ('bool') { $default = 'true' } when ('CModule::EModRet') { $default = 'CONTINUE' } when ('CString') { $default = '""' } - when (/\*$/) { $default = "($type)NULL" } + when (/\*$/) { $default = "($type)nullptr" } } } my @arg = map { @@ -367,7 +367,7 @@ while (<$in>) { print $out "\tPyObject* pyRes = PyObject_CallMethodObjArgs(m_pyObj"; print $out ", $_->{pyvar}" for @arg; - say $out ", NULL);"; + say $out ", nullptr);"; say $out "\tif (!pyRes) {"; say $out "\t\tCString sPyErr = m_pModPython->GetPyExceptionStr();"; say $out "\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUserName() : CString("")) << "/" << GetModName() << '."\"/$name failed: \" << sPyErr);"; @@ -393,13 +393,13 @@ while (<$in>) { say $out "\t\t}"; } when ('CString') { - say $out "\t\tCString* p = NULL;"; + say $out "\t\tCString* p = nullptr;"; say $out "\t\tint res = SWIG_AsPtr_std_string(pyRes, &p);"; say $out "\t\tif (!SWIG_IsOK(res)) {"; say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUserName() : CString(\"\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but error=\" << res);"; say $out "\t\t\tresult = $default;"; say $out "\t\t} else if (!p) {"; - say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUserName() : CString(\"\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but returned NULL\");"; + say $out "\t\t\tDEBUG(\"modpython: \" << (GetUser() ? GetUser()->GetUserName() : CString(\"\")) << \"/\" << GetModName() << \"/$name was expected to return '$type' but returned nullptr\");"; say $out "\t\t\tresult = $default;"; say $out "\t\t} else result = *p;"; say $out "\t\tif (SWIG_IsNewObj(res)) free((char*)p); // Don't ask me, that's how SWIG works..."; diff --git a/modules/modpython/modpython.i b/modules/modpython/modpython.i index ed578cd0..9bb9904c 100644 --- a/modules/modpython/modpython.i +++ b/modules/modpython/modpython.i @@ -206,12 +206,12 @@ class CPyRetBool { PyObject* WriteBytes(PyObject* data) { if (!PyBytes_Check(data)) { PyErr_SetString(PyExc_TypeError, "socket.WriteBytes needs bytes as argument"); - return NULL; + return nullptr; } char* buffer; Py_ssize_t length; if (-1 == PyBytes_AsStringAndSize(data, &buffer, &length)) { - return NULL; + return nullptr; } if ($self->Write(buffer, length)) { Py_RETURN_TRUE; diff --git a/modules/modpython/module.h b/modules/modpython/module.h index 2c741880..0a3e2b81 100644 --- a/modules/modpython/module.h +++ b/modules/modpython/module.h @@ -33,7 +33,7 @@ class CPyModule : public CModule { public: CPyModule(CUser* pUser, CIRCNetwork* pNetwork, const CString& sModName, const CString& sDataPath, PyObject* pyObj, CModPython* pModPython) - : CModule(NULL, pUser, pNetwork, sModName, sDataPath) { + : CModule(nullptr, pUser, pNetwork, sModName, sDataPath) { m_pyObj = pyObj; Py_INCREF(pyObj); m_pModPython = pModPython; diff --git a/modules/modtcl.cpp b/modules/modtcl.cpp index ebd72954..6ff4044a 100644 --- a/modules/modtcl.cpp +++ b/modules/modtcl.cpp @@ -30,7 +30,7 @@ using std::map; #define BADARGS(nl, nh, example) do { \ if ((argc < (nl)) || (argc > (nh))) { \ Tcl_AppendResult(irp, "wrong # args: should be \"", \ - argv[0], (example), "\"", NULL); \ + argv[0], (example), "\"", nullptr); \ return TCL_ERROR; \ } \ } while (0) @@ -40,7 +40,7 @@ class CModTcl; class CModTclTimer : public CTimer { public: - CModTclTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription) : CTimer(pModule, uInterval, uCycles, sLabel, sDescription), m_pParent(NULL) {} + CModTclTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription) : CTimer(pModule, uInterval, uCycles, sLabel, sDescription), m_pParent(nullptr) {} virtual ~CModTclTimer() {} protected: void RunJob() override; @@ -50,7 +50,7 @@ protected: class CModTclStartTimer : public CTimer { public: - CModTclStartTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription) : CTimer(pModule, uInterval, uCycles, sLabel, sDescription), m_pParent(NULL) {} + CModTclStartTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription) : CTimer(pModule, uInterval, uCycles, sLabel, sDescription), m_pParent(nullptr) {} virtual ~CModTclStartTimer() {} protected: void RunJob() override; @@ -61,7 +61,7 @@ protected: class CModTcl : public CModule { public: MODCONSTRUCTOR(CModTcl) { - interp = NULL; + interp = nullptr; } virtual ~CModTcl() { @@ -87,32 +87,32 @@ public: interp = Tcl_CreateInterp(); Tcl_Init(interp); - Tcl_CreateCommand(interp, "Binds::ProcessPubm", tcl_Bind, this, NULL); - Tcl_CreateCommand(interp, "Binds::ProcessMsgm", tcl_Bind, this, NULL); - Tcl_CreateCommand(interp, "Binds::ProcessTime", tcl_Bind, this, NULL); - Tcl_CreateCommand(interp, "Binds::ProcessEvnt", tcl_Bind, this, NULL); - Tcl_CreateCommand(interp, "Binds::ProcessNick", tcl_Bind, this, NULL); - Tcl_CreateCommand(interp, "Binds::ProcessKick", tcl_Bind, this, NULL); - Tcl_CreateCommand(interp, "PutIRC", tcl_PutIRC, this, NULL); - Tcl_CreateCommand(interp, "PutModule", tcl_PutModule, this, NULL); - Tcl_CreateCommand(interp, "PutStatus", tcl_PutStatus, this, NULL); - Tcl_CreateCommand(interp, "PutStatusNotice", tcl_PutStatusNotice, this, NULL); - Tcl_CreateCommand(interp, "PutUser", tcl_PutUser, this, NULL); + Tcl_CreateCommand(interp, "Binds::ProcessPubm", tcl_Bind, this, nullptr); + Tcl_CreateCommand(interp, "Binds::ProcessMsgm", tcl_Bind, this, nullptr); + Tcl_CreateCommand(interp, "Binds::ProcessTime", tcl_Bind, this, nullptr); + Tcl_CreateCommand(interp, "Binds::ProcessEvnt", tcl_Bind, this, nullptr); + Tcl_CreateCommand(interp, "Binds::ProcessNick", tcl_Bind, this, nullptr); + Tcl_CreateCommand(interp, "Binds::ProcessKick", tcl_Bind, this, nullptr); + Tcl_CreateCommand(interp, "PutIRC", tcl_PutIRC, this, nullptr); + Tcl_CreateCommand(interp, "PutModule", tcl_PutModule, this, nullptr); + Tcl_CreateCommand(interp, "PutStatus", tcl_PutStatus, this, nullptr); + Tcl_CreateCommand(interp, "PutStatusNotice", tcl_PutStatusNotice, this, nullptr); + Tcl_CreateCommand(interp, "PutUser", tcl_PutUser, this, nullptr); - Tcl_CreateCommand(interp, "GetCurNick", tcl_GetCurNick, this, NULL); - Tcl_CreateCommand(interp, "GetUsername", tcl_GetUsername, this, NULL); - Tcl_CreateCommand(interp, "GetRealName", tcl_GetRealName, this, NULL); - Tcl_CreateCommand(interp, "GetVHost", tcl_GetBindHost, this, NULL); - Tcl_CreateCommand(interp, "GetBindHost", tcl_GetBindHost, this, NULL); - Tcl_CreateCommand(interp, "GetChans", tcl_GetChans, this, NULL); - Tcl_CreateCommand(interp, "GetChannelUsers", tcl_GetChannelUsers, this, NULL); - Tcl_CreateCommand(interp, "GetChannelModes", tcl_GetChannelModes, this, NULL); - Tcl_CreateCommand(interp, "GetServer", tcl_GetServer, this, NULL); - Tcl_CreateCommand(interp, "GetServerOnline", tcl_GetServerOnline, this, NULL); - Tcl_CreateCommand(interp, "GetModules", tcl_GetModules, this, NULL); - Tcl_CreateCommand(interp, "GetClientCount", tcl_GetClientCount, this, NULL); + Tcl_CreateCommand(interp, "GetCurNick", tcl_GetCurNick, this, nullptr); + Tcl_CreateCommand(interp, "GetUsername", tcl_GetUsername, this, nullptr); + Tcl_CreateCommand(interp, "GetRealName", tcl_GetRealName, this, nullptr); + Tcl_CreateCommand(interp, "GetVHost", tcl_GetBindHost, this, nullptr); + Tcl_CreateCommand(interp, "GetBindHost", tcl_GetBindHost, this, nullptr); + Tcl_CreateCommand(interp, "GetChans", tcl_GetChans, this, nullptr); + Tcl_CreateCommand(interp, "GetChannelUsers", tcl_GetChannelUsers, this, nullptr); + Tcl_CreateCommand(interp, "GetChannelModes", tcl_GetChannelModes, this, nullptr); + Tcl_CreateCommand(interp, "GetServer", tcl_GetServer, this, nullptr); + Tcl_CreateCommand(interp, "GetServerOnline", tcl_GetServerOnline, this, nullptr); + Tcl_CreateCommand(interp, "GetModules", tcl_GetModules, this, nullptr); + Tcl_CreateCommand(interp, "GetClientCount", tcl_GetClientCount, this, nullptr); - Tcl_CreateCommand(interp, "exit", tcl_exit, this, NULL); + Tcl_CreateCommand(interp, "exit", tcl_exit, this, nullptr); if (!sMyArgs.empty()) { i = Tcl_EvalFile(interp, sMyArgs.c_str()); diff --git a/modules/notify_connect.cpp b/modules/notify_connect.cpp index b9ece199..b05177ff 100644 --- a/modules/notify_connect.cpp +++ b/modules/notify_connect.cpp @@ -31,7 +31,7 @@ public: private: void SendAdmins(const CString &msg) { - CZNC::Get().Broadcast(msg, true, NULL, GetClient()); + CZNC::Get().Broadcast(msg, true, nullptr, GetClient()); } }; diff --git a/modules/partyline.cpp b/modules/partyline.cpp index 5ec57d08..834b2c15 100644 --- a/modules/partyline.cpp +++ b/modules/partyline.cpp @@ -431,7 +431,7 @@ public: } } - SendNickList(pUser, NULL, ssNicks, pChannel->GetName()); + SendNickList(pUser, nullptr, ssNicks, pChannel->GetName()); /* Tell the other clients we have op or voice, the current user's clients already know from NAMES list */ @@ -464,7 +464,7 @@ public: } if (cPrefix == CHAN_PREFIX_1C) { - if (FindChannel(sTarget) == NULL) { + if (FindChannel(sTarget) == nullptr) { pClient->PutClient(":" + GetIRCServer(pNetwork) + " 401 " + pClient->GetNick() + " " + sTarget + " :No such channel"); return HALT; } @@ -526,10 +526,10 @@ public: return "irc.znc.in"; } - bool PutChan(const CString& sChan, const CString& sLine, bool bIncludeCurUser = true, bool bIncludeClient = true, CUser* pUser = NULL, CClient* pClient = NULL) { + bool PutChan(const CString& sChan, const CString& sLine, bool bIncludeCurUser = true, bool bIncludeClient = true, CUser* pUser = nullptr, CClient* pClient = nullptr) { CPartylineChannel* pChannel = FindChannel(sChan); - if (pChannel != NULL) { + if (pChannel != nullptr) { PutChan(pChannel->GetNicks(), sLine, bIncludeCurUser, bIncludeClient, pUser, pClient); return true; } @@ -537,7 +537,7 @@ public: return false; } - void PutChan(const set& ssNicks, const CString& sLine, bool bIncludeCurUser = true, bool bIncludeClient = true, CUser* pUser = NULL, CClient* pClient = NULL) { + void PutChan(const set& ssNicks, const CString& sLine, bool bIncludeCurUser = true, bool bIncludeClient = true, CUser* pUser = nullptr, CClient* pClient = nullptr) { const map& msUsers = CZNC::Get().GetUserMap(); if (!pUser) @@ -549,7 +549,7 @@ public: if (ssNicks.find(it->first) != ssNicks.end()) { if (it->second == pUser) { if (bIncludeCurUser) { - it->second->PutAllUser(sLine, NULL, (bIncludeClient ? NULL : pClient)); + it->second->PutAllUser(sLine, nullptr, (bIncludeClient ? nullptr : pClient)); } } else { it->second->PutAllUser(sLine); @@ -609,7 +609,7 @@ public: return *it; } - return NULL; + return nullptr; } CPartylineChannel* GetChannel(const CString& sChannel) { diff --git a/modules/route_replies.cpp b/modules/route_replies.cpp index 45a883c6..22274b02 100644 --- a/modules/route_replies.cpp +++ b/modules/route_replies.cpp @@ -33,21 +33,21 @@ static const struct { {"315", true}, /* rfc1459 RPL_ENDOFWHO */ {"354", false}, // e.g. Quaknet uses this for WHO #chan %n {"403", true}, // No such chan - {NULL, true} + {nullptr, true} }}, {"LIST", { {"402", true}, /* rfc1459 ERR_NOSUCHSERVER */ {"321", false}, /* rfc1459 RPL_LISTSTART */ {"322", false}, /* rfc1459 RPL_LIST */ {"323", true}, /* rfc1459 RPL_LISTEND */ - {NULL, true} + {nullptr, true} }}, {"NAMES", { {"353", false}, /* rfc1459 RPL_NAMREPLY */ {"366", true}, /* rfc1459 RPL_ENDOFNAMES */ // No such nick/channel {"401", true}, - {NULL, true}, + {nullptr, true}, }}, {"LUSERS", { {"251", false}, /* rfc1459 RPL_LUSERCLIENT */ @@ -59,7 +59,7 @@ static const struct { {"266", true}, // We don't handle 250 here since some IRCds don't sent it //{"250", true}, - {NULL, true} + {nullptr, true} }}, {"WHOIS", { {"311", false}, /* rfc1459 RPL_WHOISUSER */ @@ -81,23 +81,23 @@ static const struct { {"401", true}, /* rfc1459 ERR_NOSUCHNICK */ {"402", true}, /* rfc1459 ERR_NOSUCHSERVER */ {"431", true}, /* rfc1459 ERR_NONICKNAMEGIVEN */ - {NULL, true} + {nullptr, true} }}, {"PING", { {"PONG", true}, {"402", true}, /* rfc1459 ERR_NOSUCHSERVER */ {"409", true}, /* rfc1459 ERR_NOORIGIN */ - {NULL, true} + {nullptr, true} }}, {"USERHOST", { {"302", true}, {"461", true}, /* rfc1459 ERR_NEEDMOREPARAMS */ - {NULL, true} + {nullptr, true} }}, {"TIME", { {"391", true}, /* rfc1459 RPL_TIME */ {"402", true}, /* rfc1459 ERR_NOSUCHSERVER */ - {NULL, true} + {nullptr, true} }}, {"WHOWAS", { {"406", false}, /* rfc1459 ERR_WASNOSUCHNICK */ @@ -105,18 +105,18 @@ static const struct { {"314", false}, /* rfc1459 RPL_WHOWASUSER */ {"369", true}, /* rfc1459 RPL_ENDOFWHOWAS */ {"431", true}, /* rfc1459 ERR_NONICKNAMEGIVEN */ - {NULL, true} + {nullptr, true} }}, {"ISON", { {"303", true}, /* rfc1459 RPL_ISON */ {"461", true}, /* rfc1459 ERR_NEEDMOREPARAMS */ - {NULL, true} + {nullptr, true} }}, {"LINKS", { {"364", false}, /* rfc1459 RPL_LINKS */ {"365", true}, /* rfc1459 RPL_ENDOFLINKS */ {"402", true}, /* rfc1459 ERR_NOSUCHSERVER */ - {NULL, true} + {nullptr, true} }}, {"MAP", { {"006", false}, @@ -127,7 +127,7 @@ static const struct { {"017", true}, {"007", true}, {"481", true}, /* rfc1459 ERR_NOPRIVILEGES */ - {NULL, true} + {nullptr, true} }}, {"TRACE", { {"200", false}, /* rfc1459 RPL_TRACELINK */ @@ -141,7 +141,7 @@ static const struct { {"261", false}, /* rfc1459 RPL_TRACELOG */ {"262", true}, {"402", true}, /* rfc1459 ERR_NOSUCHSERVER */ - {NULL, true} + {nullptr, true} }}, {"USERS", { {"265", false}, @@ -153,7 +153,7 @@ static const struct { {"402", true}, /* rfc1459 ERR_NOSUCHSERVER */ {"424", true}, /* rfc1459 ERR_FILEERROR */ {"446", true}, /* rfc1459 ERR_USERSDISABLED */ - {NULL, true}, + {nullptr, true}, }}, {"METADATA", { {"761", false}, /* ircv3.2 RPL_KEYVALUE */ @@ -163,7 +163,7 @@ static const struct { {"767", true}, /* ircv3.2 ERR_KEYINVALID */ {"768", true}, /* ircv3.2 ERR_KEYNOTSET */ {"769", true}, /* ircv3.2 ERR_KEYNOPERMISSION */ - {NULL, true}, + {nullptr, true}, }}, // This is just a list of all possible /mode replies stuffed together. // Since there should never be more than one of these going on, this @@ -184,10 +184,10 @@ static const struct { {"472", true}, /* rfc1459 ERR_UNKNOWNMODE */ {"501", true}, /* rfc1459 ERR_UMODEUNKNOWNFLAG */ {"502", true}, /* rfc1459 ERR_USERSDONTMATCH */ - {NULL, true}, + {nullptr, true}, }}, // END (last item!) - {NULL, {{NULL, true}}} + {nullptr, {{nullptr, true}}} }; class CRouteTimeout : public CTimer { @@ -213,8 +213,8 @@ class CRouteRepliesMod : public CModule public: MODCONSTRUCTOR(CRouteRepliesMod) { - m_pDoing = NULL; - m_pReplies = NULL; + m_pDoing = nullptr; + m_pReplies = nullptr; AddHelpCommand(); AddCommand("Silent", static_cast(&CRouteRepliesMod::SilentCommand), @@ -238,8 +238,8 @@ public: void OnIRCConnected() override { - m_pDoing = NULL; - m_pReplies = NULL; + m_pDoing = nullptr; + m_pReplies = nullptr; m_vsPending.clear(); // No way we get a reply, so stop the timer (If it's running) @@ -259,8 +259,8 @@ public: // The replies which aren't received yet will be // broadcasted to everyone, but at least nothing breaks RemTimer("RouteTimeout"); - m_pDoing = NULL; - m_pReplies = NULL; + m_pDoing = nullptr; + m_pReplies = nullptr; } it = m_vsPending.find(GetClient()); @@ -292,7 +292,7 @@ public: } } - while (m_pReplies[i].szReply != NULL) { + while (m_pReplies[i].szReply != nullptr) { if (m_pReplies[i].szReply == sCmd) { if (RouteReply(sLine, m_pReplies[i].bLastResponse, sCmd == "353")) return HALTCORE; @@ -349,7 +349,7 @@ public: // Fall through to the next loop } - for (size_t i = 0; vRouteReplies[i].szRequest != NULL; i++) { + for (size_t i = 0; vRouteReplies[i].szRequest != nullptr; i++) { if (vRouteReplies[i].szRequest == sCmd) { struct queued_req req = { sLine, vRouteReplies[i].vReplies @@ -375,7 +375,7 @@ public: PutModule("Last request: " + m_sLastRequest); PutModule("Expected replies: "); - for (size_t i = 0; m_pReplies[i].szReply != NULL; i++) { + for (size_t i = 0; m_pReplies[i].szReply != nullptr; i++) { if (m_pReplies[i].bLastResponse) PutModule(m_pReplies[i].szReply + CString(" (last)")); @@ -384,8 +384,8 @@ public: } } - m_pDoing = NULL; - m_pReplies = NULL; + m_pDoing = nullptr; + m_pReplies = nullptr; SendRequest(); } @@ -405,8 +405,8 @@ private: // Stop the timeout RemTimer("RouteTimeout"); - m_pDoing = NULL; - m_pReplies = NULL; + m_pDoing = nullptr; + m_pReplies = nullptr; SendRequest(); } diff --git a/modules/sasl.cpp b/modules/sasl.cpp index 6e331df2..3c72a7b1 100644 --- a/modules/sasl.cpp +++ b/modules/sasl.cpp @@ -24,7 +24,7 @@ static const struct { } SupportedMechanisms[] = { { "EXTERNAL", "TLS certificate, for use with the *cert module", false }, { "PLAIN", "Plain text negotiation, this should work always if the network supports SASL", true }, - { NULL, NULL, false } + { nullptr, nullptr, false } }; #define NV_REQUIRE_AUTH "require_auth" @@ -86,7 +86,7 @@ public: Mechanisms.AddColumn("Mechanism"); Mechanisms.AddColumn("Description"); - for (size_t i = 0; SupportedMechanisms[i].szName != NULL; i++) { + for (size_t i = 0; SupportedMechanisms[i].szName != nullptr; i++) { Mechanisms.AddRow(); Mechanisms.SetCell("Mechanism", SupportedMechanisms[i].szName); Mechanisms.SetCell("Description", SupportedMechanisms[i].szDescription); @@ -137,7 +137,7 @@ public: } bool SupportsMechanism(const CString& sMechanism) const { - for (size_t i = 0; SupportedMechanisms[i].szName != NULL; i++) { + for (size_t i = 0; SupportedMechanisms[i].szName != nullptr; i++) { if (sMechanism.Equals(SupportedMechanisms[i].szName)) { return true; } @@ -150,7 +150,7 @@ public: if (GetNV(NV_MECHANISMS).empty()) { CString sDefaults = ""; - for (size_t i = 0; SupportedMechanisms[i].szName != NULL; i++) { + for (size_t i = 0; SupportedMechanisms[i].szName != nullptr; i++) { if (SupportedMechanisms[i].bDefault) { if (!sDefaults.empty()) { sDefaults += " "; diff --git a/modules/savebuff.cpp b/modules/savebuff.cpp index c2bd3f4e..37db0b27 100644 --- a/modules/savebuff.cpp +++ b/modules/savebuff.cpp @@ -323,7 +323,7 @@ public: #ifdef LEGACY_SAVEBUFF /* event logging is deprecated now in savebuf. Use buffextras module along side of this */ CString SpoofChanMsg(const CString & sChannel, const CString & sMesg) { - CString sReturn = ":*" + GetModName() + "!znc@znc.in PRIVMSG " + sChannel + " :" + CString(time(NULL)) + " " + sMesg; + CString sReturn = ":*" + GetModName() + "!znc@znc.in PRIVMSG " + sChannel + " :" + CString(time(nullptr)) + " " + sMesg; return(sReturn); } diff --git a/modules/shell.cpp b/modules/shell.cpp index 06f69cfc..b1f7429b 100644 --- a/modules/shell.cpp +++ b/modules/shell.cpp @@ -122,7 +122,7 @@ void CShellSock::ReadLine(const CString& sData) { m_pParent->SetClient(m_pClient); m_pParent->PutShell(sLine); - m_pParent->SetClient(NULL); + m_pParent->SetClient(nullptr); } void CShellSock::Disconnected() { @@ -134,7 +134,7 @@ void CShellSock::Disconnected() { m_pParent->SetClient(m_pClient); m_pParent->PutShell("znc$"); - m_pParent->SetClient(NULL); + m_pParent->SetClient(nullptr); } template<> void TModInfo(CModInfo& Info) { diff --git a/modules/simple_away.cpp b/modules/simple_away.cpp index c07bd14f..57d6e7aa 100644 --- a/modules/simple_away.cpp +++ b/modules/simple_away.cpp @@ -183,7 +183,7 @@ private: if (sReason.empty()) sReason = SIMPLE_AWAY_DEFAULT_REASON; - time_t iTime = time(NULL); + time_t iTime = time(nullptr); CString sTime = CUtils::CTime(iTime, GetUser()->GetTimezone()); sReason.Replace("%s", sTime); diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp index 69588ead..0de853a6 100644 --- a/modules/webadmin.cpp +++ b/modules/webadmin.cpp @@ -28,7 +28,7 @@ using std::map; /* Stuff to be able to write this: // i will be name of local variable, see below - // pUser can be NULL if only global modules are needed + // pUser can be nullptr if only global modules are needed FOR_EACH_MODULE(i, pUser) { // i is local variable of type CModules::iterator, // so *i has type CModule* @@ -173,7 +173,7 @@ public: if (sUsername.empty()) { WebSock.PrintErrorPage("Invalid Submission [Username is required]"); - return NULL; + return nullptr; } if (pUser) { @@ -185,7 +185,7 @@ public: if (sArg != WebSock.GetParam("password2")) { WebSock.PrintErrorPage("Invalid Submission [Passwords do not match]"); - return NULL; + return nullptr; } CUser* pNewUser = new CUser(sUsername); @@ -308,7 +308,7 @@ public: pNewUser->SetMaxNetworks(pUser->MaxNetworks()); } - // If pUser is not NULL, we are editing an existing user. + // If pUser is not nullptr, we are editing an existing user. // Users must not be able to change their own admin flag. if (pUser != CZNC::Get().FindUser(WebSock.GetUser())) { pNewUser->SetAdmin(WebSock.GetParam("isadmin").ToBool()); @@ -343,7 +343,7 @@ public: CString sArgs = WebSock.GetParam("modargs_" + sModName); try { - if (!pNewUser->GetModules().LoadModule(sModName, sArgs, CModInfo::UserModule, pNewUser, NULL, sModRet)) { + if (!pNewUser->GetModules().LoadModule(sModName, sArgs, CModInfo::UserModule, pNewUser, nullptr, sModRet)) { sModLoadError = "Unable to load module [" + sModName + "] [" + sModRet + "]"; } } catch (...) { @@ -366,7 +366,7 @@ public: CString sModLoadError; try { - if (!pNewUser->GetModules().LoadModule(sModName, sArgs, CModInfo::UserModule, pNewUser, NULL, sModRet)) { + if (!pNewUser->GetModules().LoadModule(sModName, sArgs, CModInfo::UserModule, pNewUser, nullptr, sModRet)) { sModLoadError = "Unable to load module [" + sModName + "] [" + sModRet + "]"; } } catch (...) { @@ -409,7 +409,7 @@ public: CIRCNetwork* SafeGetNetworkFromParam(CWebSock& WebSock) { CUser* pUser = CZNC::Get().FindUser(SafeGetUserNameParam(WebSock)); - CIRCNetwork* pNetwork = NULL; + CIRCNetwork* pNetwork = nullptr; if (pUser) { pNetwork = pUser->FindNetwork(SafeGetNetworkParam(WebSock)); @@ -614,7 +614,7 @@ public: return false; } - bool ChanPage(CWebSock& WebSock, CTemplate& Tmpl, CIRCNetwork* pNetwork, CChan* pChan = NULL) { + bool ChanPage(CWebSock& WebSock, CTemplate& Tmpl, CIRCNetwork* pNetwork, CChan* pChan = nullptr) { std::shared_ptr spSession = WebSock.GetSession(); Tmpl.SetFile("add_edit_chan.tmpl"); CUser* pUser = pNetwork->GetUser(); @@ -760,7 +760,7 @@ public: return true; } - bool NetworkPage(CWebSock& WebSock, CTemplate& Tmpl, CUser* pUser, CIRCNetwork* pNetwork = NULL) { + bool NetworkPage(CWebSock& WebSock, CTemplate& Tmpl, CUser* pUser, CIRCNetwork* pNetwork = nullptr) { std::shared_ptr spSession = WebSock.GetSession(); Tmpl.SetFile("add_edit_network.tmpl"); @@ -789,11 +789,11 @@ public: // Check if module is loaded globally l["CanBeLoadedGlobally"] = CString(Info.SupportsType(CModInfo::GlobalModule)); - l["LoadedGlobally"] = CString(CZNC::Get().GetModules().FindModule(Info.GetName()) != NULL); + l["LoadedGlobally"] = CString(CZNC::Get().GetModules().FindModule(Info.GetName()) != nullptr); // Check if module is loaded by user l["CanBeLoadedByUser"] = CString(Info.SupportsType(CModInfo::UserModule)); - l["LoadedByUser"] = CString(pUser->GetModules().FindModule(Info.GetName()) != NULL); + l["LoadedByUser"] = CString(pUser->GetModules().FindModule(Info.GetName()) != nullptr); if (!spSession->IsAdmin() && pUser->DenyLoadMod()) { l["Disabled"] = "true"; @@ -1178,7 +1178,7 @@ public: return false; } - bool UserPage(CWebSock& WebSock, CTemplate& Tmpl, CUser* pUser = NULL) { + bool UserPage(CWebSock& WebSock, CTemplate& Tmpl, CUser* pUser = nullptr) { std::shared_ptr spSession = WebSock.GetSession(); Tmpl.SetFile("add_edit_user.tmpl"); @@ -1349,7 +1349,7 @@ public: l["HasArgs"] = CString(Info.GetHasArgs()); l["ArgsHelpText"] = Info.GetArgsHelpText(); - CModule *pModule = NULL; + CModule *pModule = nullptr; if (pUser) { pModule = pUser->GetModules().FindModule(Info.GetName()); // Check if module is loaded by all or some networks @@ -1375,7 +1375,7 @@ public: } l["CanBeLoadedGlobally"] = CString(Info.SupportsType(CModInfo::GlobalModule)); // Check if module is loaded globally - l["LoadedGlobally"] = CString(CZNC::Get().GetModules().FindModule(Info.GetName()) != NULL); + l["LoadedGlobally"] = CString(CZNC::Get().GetModules().FindModule(Info.GetName()) != nullptr); if (!spSession->IsAdmin() && pUser && pUser->DenyLoadMod()) { l["Disabled"] = "true"; @@ -1442,7 +1442,7 @@ public: return true; } - /* If pUser is NULL, we are adding a user, else we are editing this one */ + /* If pUser is nullptr, we are adding a user, else we are editing this one */ CString sUsername = WebSock.GetParam("user"); if (!pUser && CZNC::Get().FindUser(sUsername)) { @@ -1867,11 +1867,11 @@ public: CModule *pMod = CZNC::Get().GetModules().FindModule(sModName); if (!pMod) { - if (!CZNC::Get().GetModules().LoadModule(sModName, sArgs, CModInfo::GlobalModule, NULL, NULL, sModRet)) { + if (!CZNC::Get().GetModules().LoadModule(sModName, sArgs, CModInfo::GlobalModule, nullptr, nullptr, sModRet)) { sModLoadError = "Unable to load module [" + sModName + "] [" + sModRet + "]"; } } else if (pMod->GetArgs() != sArgs) { - if (!CZNC::Get().GetModules().ReloadModule(sModName, sArgs, NULL, NULL, sModRet)) { + if (!CZNC::Get().GetModules().ReloadModule(sModName, sArgs, nullptr, nullptr, sModRet)) { sModLoadError = "Unable to reload module [" + sModName + "] [" + sModRet + "]"; } } diff --git a/src/Chan.cpp b/src/Chan.cpp index 63f12d83..d419f3b8 100644 --- a/src/Chan.cpp +++ b/src/Chan.cpp @@ -583,7 +583,7 @@ void CChan::SendBuffer(CClient* pClient) { void CChan::SendBuffer(CClient* pClient, const CBuffer& Buffer) { if (m_pNetwork && m_pNetwork->IsUserAttached()) { - // in the event that pClient is NULL, need to send this to all clients for the user + // in the event that pClient is nullptr, need to send this to all clients for the user // I'm presuming here that pClient is listed inside vClients thus vClients at this // point can't be empty. // @@ -594,7 +594,7 @@ void CChan::SendBuffer(CClient* pClient, const CBuffer& Buffer) { // 4. OnChanBufferEnding // // With the exception of ClearBuffer(), this needs to happen per client, and - // if pClient is not NULL, the loops break after the first iteration. + // if pClient is not nullptr, the loops break after the first iteration. // // Rework this if you like ... if (!Buffer.IsEmpty()) { diff --git a/src/Client.cpp b/src/Client.cpp index 1a09cdd3..fe8d5d68 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -25,12 +25,12 @@ using std::map; using std::vector; #define CALLMOD(MOD, CLIENT, USER, NETWORK, FUNC) { \ - CModule *pModule = NULL; \ + CModule *pModule = nullptr; \ if (NETWORK && (pModule = (NETWORK)->GetModules().FindModule(MOD))) { \ try { \ pModule->SetClient(CLIENT); \ pModule->FUNC; \ - pModule->SetClient(NULL); \ + pModule->SetClient(nullptr); \ } catch (const CModule::EModException& e) { \ if (e == CModule::UNLOAD) { \ (NETWORK)->GetModules().UnloadModule(MOD); \ @@ -41,8 +41,8 @@ using std::vector; pModule->SetClient(CLIENT); \ pModule->SetNetwork(NETWORK); \ pModule->FUNC; \ - pModule->SetClient(NULL); \ - pModule->SetNetwork(NULL); \ + pModule->SetClient(nullptr); \ + pModule->SetNetwork(nullptr); \ } catch (const CModule::EModException& e) { \ if (e == CModule::UNLOAD) { \ (USER)->GetModules().UnloadModule(MOD); \ @@ -54,9 +54,9 @@ using std::vector; pModule->SetNetwork(NETWORK); \ pModule->SetUser(USER); \ pModule->FUNC; \ - pModule->SetClient(NULL); \ - pModule->SetNetwork(NULL); \ - pModule->SetUser(NULL); \ + pModule->SetClient(nullptr); \ + pModule->SetNetwork(nullptr); \ + pModule->SetUser(nullptr); \ } catch (const CModule::EModException& e) { \ if (e == CModule::UNLOAD) { \ CZNC::Get().GetModules().UnloadModule(MOD); \ diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 39d0e94e..511b183c 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -25,7 +25,7 @@ using std::set; using std::vector; using std::map; -#define IRCSOCKMODULECALL(macFUNC, macEXITER) NETWORKMODULECALL(macFUNC, m_pNetwork->GetUser(), m_pNetwork, NULL, macEXITER) +#define IRCSOCKMODULECALL(macFUNC, macEXITER) NETWORKMODULECALL(macFUNC, m_pNetwork->GetUser(), m_pNetwork, nullptr, macEXITER) // These are used in OnGeneralCTCP() const time_t CIRCSock::m_uCTCPFloodTime = 5; const unsigned int CIRCSock::m_uCTCPFloodCount = 5; @@ -630,7 +630,7 @@ void CIRCSock::ReadLine(const CString& sData) { CString sModeArg = sModes.Token(0); bool bAdd = true; /* no module call defined (yet?) - MODULECALL(OnRawUserMode(*pOpNick, *this, sModeArg, sArgs), m_pNetwork->GetUser(), NULL, ); + MODULECALL(OnRawUserMode(*pOpNick, *this, sModeArg, sArgs), m_pNetwork->GetUser(), nullptr, ); */ for (unsigned int a = 0; a < sModeArg.size(); a++) { const unsigned char& uMode = sModeArg[a]; diff --git a/src/Modules.cpp b/src/Modules.cpp index 388bd02b..ce99e9e3 100644 --- a/src/Modules.cpp +++ b/src/Modules.cpp @@ -39,12 +39,12 @@ bool ZNC_NO_NEED_TO_DO_ANYTHING_ON_MODULE_CALL_EXITER; try { \ CClient* pOldClient = pMod->GetClient(); \ pMod->SetClient(m_pClient); \ - CUser* pOldUser = NULL; \ + CUser* pOldUser = nullptr; \ if (m_pUser) { \ pOldUser = pMod->GetUser(); \ pMod->SetUser(m_pUser); \ } \ - CIRCNetwork* pNetwork = NULL; \ + CIRCNetwork* pNetwork = nullptr; \ if (m_pNetwork) { \ pNetwork = pMod->GetNetwork(); \ pMod->SetNetwork(m_pNetwork); \ @@ -70,12 +70,12 @@ bool ZNC_NO_NEED_TO_DO_ANYTHING_ON_MODULE_CALL_EXITER; CModule::EModRet e = CModule::CONTINUE; \ CClient* pOldClient = pMod->GetClient(); \ pMod->SetClient(m_pClient); \ - CUser* pOldUser = NULL; \ + CUser* pOldUser = nullptr; \ if (m_pUser) { \ pOldUser = pMod->GetUser(); \ pMod->SetUser(m_pUser); \ } \ - CIRCNetwork* pNetwork = NULL; \ + CIRCNetwork* pNetwork = nullptr; \ if (m_pNetwork) { \ pNetwork = pMod->GetNetwork(); \ pMod->SetNetwork(m_pNetwork); \ diff --git a/src/SSLVerifyHost.cpp b/src/SSLVerifyHost.cpp index 2b5af5ef..a5830add 100644 --- a/src/SSLVerifyHost.cpp +++ b/src/SSLVerifyHost.cpp @@ -190,7 +190,7 @@ static int hostmatch(char *hostname, char *pattern) pattern[len-1]=0; pattern_wildcard = strchr(pattern, '*'); - if(pattern_wildcard == NULL) + if(pattern_wildcard == nullptr) return Curl_raw_equal(pattern, hostname) ? CURL_HOST_MATCH : CURL_HOST_NOMATCH; @@ -206,7 +206,7 @@ static int hostmatch(char *hostname, char *pattern) match. */ wildcard_enabled = 1; pattern_label_end = strchr(pattern, '.'); - if(pattern_label_end == NULL || strchr(pattern_label_end+1, '.') == NULL || + if(pattern_label_end == nullptr || strchr(pattern_label_end+1, '.') == nullptr || pattern_wildcard > pattern_label_end || Curl_raw_nequal(pattern, "xn--", 4)) { wildcard_enabled = 0; @@ -216,7 +216,7 @@ static int hostmatch(char *hostname, char *pattern) CURL_HOST_MATCH : CURL_HOST_NOMATCH; hostname_label_end = strchr(hostname, '.'); - if(hostname_label_end == NULL || + if(hostname_label_end == nullptr || !Curl_raw_equal(pattern_label_end, hostname_label_end)) return CURL_HOST_NOMATCH; @@ -303,9 +303,9 @@ typedef enum { */ static HostnameValidationResult matches_common_name(const char *hostname, const X509 *server_cert) { int common_name_loc = -1; - X509_NAME_ENTRY *common_name_entry = NULL; - ASN1_STRING *common_name_asn1 = NULL; - char *common_name_str = NULL; + X509_NAME_ENTRY *common_name_entry = nullptr; + ASN1_STRING *common_name_asn1 = nullptr; + char *common_name_str = nullptr; // Find the position of the CN field in the Subject field of the certificate common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name((X509 *) server_cert), NID_commonName, -1); @@ -315,13 +315,13 @@ static HostnameValidationResult matches_common_name(const char *hostname, const // Extract the CN field common_name_entry = X509_NAME_get_entry(X509_get_subject_name((X509 *) server_cert), common_name_loc); - if (common_name_entry == NULL) { + if (common_name_entry == nullptr) { return Error; } // Convert the CN field to a C string common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry); - if (common_name_asn1 == NULL) { + if (common_name_asn1 == nullptr) { return Error; } common_name_str = (char *) ASN1_STRING_data(common_name_asn1); @@ -354,11 +354,11 @@ static HostnameValidationResult matches_subject_alternative_name(const char *hos HostnameValidationResult result = MatchNotFound; int i; int san_names_nb = -1; - STACK_OF(GENERAL_NAME) *san_names = NULL; + STACK_OF(GENERAL_NAME) *san_names = nullptr; // Try to extract the names within the SAN extension from the certificate - san_names = reinterpret_cast(X509_get_ext_d2i((X509 *) server_cert, NID_subject_alt_name, NULL, NULL)); - if (san_names == NULL) { + san_names = reinterpret_cast(X509_get_ext_d2i((X509 *) server_cert, NID_subject_alt_name, nullptr, nullptr)); + if (san_names == nullptr) { return NoSANPresent; } san_names_nb = sk_GENERAL_NAME_num(san_names); @@ -405,7 +405,7 @@ static HostnameValidationResult matches_subject_alternative_name(const char *hos static HostnameValidationResult validate_hostname(const char *hostname, const X509 *server_cert) { HostnameValidationResult result; - if((hostname == NULL) || (server_cert == NULL)) + if((hostname == nullptr) || (server_cert == nullptr)) return Error; // First try the Subject Alternative Names extension diff --git a/src/Socket.cpp b/src/Socket.cpp index 1c2e0a9a..6b838988 100644 --- a/src/Socket.cpp +++ b/src/Socket.cpp @@ -193,7 +193,7 @@ void CSockManager::CDNSJob::runMain() { if (0 != this->iRes) { DEBUG("Error in threaded DNS: " << gai_strerror(this->iRes)); if (this->aiResult) { - DEBUG("And aiResult is not NULL..."); + DEBUG("And aiResult is not nullptr..."); } this->aiResult = nullptr; // just for case. Maybe to call freeaddrinfo()? } @@ -413,7 +413,7 @@ CSocket::CSocket(CModule* pModule, const CString& sHostname, unsigned short uPor CSocket::~CSocket() { CUser *pUser = nullptr; - // CWebSock could cause us to have a NULL pointer here + // CWebSock could cause us to have a nullptr pointer here if (m_pModule) { pUser = m_pModule->GetUser(); m_pModule->UnlinkSocket(this); diff --git a/src/Utils.cpp b/src/Utils.cpp index e7009c7b..a0602e93 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -51,23 +51,23 @@ constexpr const char* szDefaultDH2048 = "-----END DH PARAMETERS-----\n"; void CUtils::GenerateCert(FILE *pOut, const CString& sHost) { - EVP_PKEY *pKey = NULL; - X509 *pCert = NULL; - X509_NAME *pName = NULL; + EVP_PKEY *pKey = nullptr; + X509 *pCert = nullptr; + X509_NAME *pName = nullptr; const int days = 365; const int years = 10; - unsigned int uSeed = (unsigned int)time(NULL); + unsigned int uSeed = (unsigned int)time(nullptr); int serial = (rand_r(&uSeed) % 9999); - RSA *pRSA = RSA_generate_key(2048, 0x10001, NULL, NULL); + RSA *pRSA = RSA_generate_key(2048, 0x10001, nullptr, nullptr); if ((pKey = EVP_PKEY_new())) { if (!EVP_PKEY_assign_RSA(pKey, pRSA)) { EVP_PKEY_free(pKey); return; } - PEM_write_RSAPrivateKey(pOut, pRSA, NULL, NULL, 0, NULL, NULL); + PEM_write_RSAPrivateKey(pOut, pRSA, nullptr, nullptr, 0, nullptr, nullptr); if (!(pCert = X509_new())) { EVP_PKEY_free(pKey); @@ -83,7 +83,7 @@ void CUtils::GenerateCert(FILE *pOut, const CString& sHost) { pName = X509_get_subject_name(pCert); const char *pLogName = getenv("LOGNAME"); - const char *pHostName = NULL; + const char *pHostName = nullptr; if (!sHost.empty()) { pHostName = sHost.c_str(); @@ -502,7 +502,7 @@ SCString CUtils::GetEncodings() { for (int st = 0; st < ucnv_countStandards(); ++st) { const char* pStdName = ucnv_getStandard(st, e); icu::LocalUEnumerationPointer ue(ucnv_openStandardNames(pConvName, pStdName, e)); - while (const char* pStdConvNameEnum = uenum_next(ue.getAlias(), NULL, e)) { + while (const char* pStdConvNameEnum = uenum_next(ue.getAlias(), nullptr, e)) { ssResult.insert(pStdConvNameEnum); } } diff --git a/src/znc.cpp b/src/znc.cpp index 15653bf8..c167b38a 100644 --- a/src/znc.cpp +++ b/src/znc.cpp @@ -1862,7 +1862,7 @@ public: } virtual ~CConnectQueueTimer() { // This is only needed when ZNC shuts down: - // CZNC::~CZNC() sets its CConnectQueueTimer pointer to NULL and + // CZNC::~CZNC() sets its CConnectQueueTimer pointer to nullptr and // calls the manager's Cleanup() which destroys all sockets and // timers. If something calls CZNC::EnableConnectQueue() here // (e.g. because a CIRCSock is destroyed), the socket manager diff --git a/test/ThreadTest.cpp b/test/ThreadTest.cpp index d95cbc19..4ba5f415 100644 --- a/test/ThreadTest.cpp +++ b/test/ThreadTest.cpp @@ -175,7 +175,7 @@ TEST(Thread, CancelJobWhenDone) { fd_set fds; FD_ZERO(&fds); FD_SET(CThreadPool::Get().getReadFD(), &fds); - EXPECT_EQ(1, select(1 + CThreadPool::Get().getReadFD(), &fds, NULL, NULL, NULL)); + EXPECT_EQ(1, select(1 + CThreadPool::Get().getReadFD(), &fds, nullptr, nullptr, nullptr)); // And only cancel it afterwards CThreadPool::Get().cancelJob(pJob);