diff --git a/Chan.cpp b/Chan.cpp index 3efa7203..fe059003 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -50,16 +50,18 @@ bool CChan::WriteConfig(CFile& File) { return false; } - File.Write("\t\n"); + File.Write("\t\n"); if (m_pUser->GetBufferCount() != GetBufferCount()) - File.Write("\t\tBuffer = " + CString(GetBufferCount()) + "\n"); + m_pUser->PrintLine(File, "\tBuffer", CString(GetBufferCount())); if (m_pUser->KeepBuffer() != KeepBuffer()) - File.Write("\t\tKeepBuffer = " + CString(KeepBuffer()) + "\n"); + m_pUser->PrintLine(File, "\tKeepBuffer", CString(KeepBuffer())); if (IsDetached()) - File.Write("\t\tDetached = true\n"); - if (!GetKey().empty()) { File.Write("\t\tKey = " + GetKey() + "\n"); } - if (!GetDefaultModes().empty()) { File.Write("\t\tModes = " + GetDefaultModes() + "\n"); } + m_pUser->PrintLine(File, "\tDetached", "true"); + if (!GetKey().empty()) + m_pUser->PrintLine(File, "\tKey", GetKey()); + if (!GetDefaultModes().empty()) + m_pUser->PrintLine(File, "\tModes", GetDefaultModes()); File.Write("\t\n"); return true; diff --git a/User.cpp b/User.cpp index e3614c6d..8823b2f7 100644 --- a/User.cpp +++ b/User.cpp @@ -554,11 +554,12 @@ bool CUser::PrintLine(CFile& File, const CString& sName, const CString& sValue) return false; } - return File.Write("\t" + sName + " = " + sValue + "\n"); + return File.Write("\t" + sName.FirstLine() + + " = " + sValue.FirstLine() + "\n"); } bool CUser::WriteConfig(CFile& File) { - File.Write("\n"); + File.Write("\n"); if (IsPassHashed()) { if (m_sPassSalt.empty()) { diff --git a/ZNCString.h b/ZNCString.h index c7b07c60..85b20108 100644 --- a/ZNCString.h +++ b/ZNCString.h @@ -104,6 +104,7 @@ public: CString Left(unsigned int uCount) const; CString Right(unsigned int uCount) const; + CString FirstLine() const { return Token(0, false, "\n"); } CString Token(unsigned int uPos, bool bRest = false, const CString& sSep = " ") const; unsigned int URLSplit(MCString& msRet) const; unsigned int Split(const CString& sDelim, VCString& vsRet, bool bAllowEmpty = true, const CString& sLeft = "", const CString& sRight = "") const; diff --git a/znc.cpp b/znc.cpp index b78b83f5..c386a90d 100644 --- a/znc.cpp +++ b/znc.cpp @@ -514,7 +514,7 @@ bool CZNC::WriteConfig() { CString sHostPortion = pListener->GetBindHost(); if (!sHostPortion.empty()) { - sHostPortion += " "; + sHostPortion = sHostPortion.FirstLine() + " "; } CString s6 = (pListener->IsIPV6()) ? "6" : " "; @@ -525,32 +525,39 @@ bool CZNC::WriteConfig() { File.Write("ConnectDelay = " + CString(m_uiConnectDelay) + "\n"); if (!m_sISpoofFile.empty()) { - File.Write("ISpoofFile = " + m_sISpoofFile + "\n"); - if (!m_sISpoofFormat.empty()) { File.Write("ISpoofFormat = " + m_sISpoofFormat + "\n"); } + File.Write("ISpoofFile = " + m_sISpoofFile.FirstLine() + "\n"); + if (!m_sISpoofFormat.empty()) { + File.Write("ISpoofFormat = " + m_sISpoofFormat.FirstLine() + "\n"); + } } - if (!m_sPidFile.empty()) { File.Write("PidFile = " + m_sPidFile + "\n"); } - if (!m_sStatusPrefix.empty()) { File.Write("StatusPrefix = " + m_sStatusPrefix + "\n"); } + if (!m_sPidFile.empty()) { + File.Write("PidFile = " + m_sPidFile.FirstLine() + "\n"); + } + if (!m_sStatusPrefix.empty()) { + File.Write("StatusPrefix = " + m_sStatusPrefix.FirstLine() + "\n"); + } for (unsigned int m = 0; m < m_vsMotd.size(); m++) { - File.Write("Motd = " + m_vsMotd[m] + "\n"); + File.Write("Motd = " + m_vsMotd[m].FirstLine() + "\n"); } for (unsigned int v = 0; v < m_vsVHosts.size(); v++) { - File.Write("VHost = " + m_vsVHosts[v] + "\n"); + File.Write("VHost = " + m_vsVHosts[v].FirstLine() + "\n"); } #ifdef _MODULES CGlobalModules& Mods = GetModules(); for (unsigned int a = 0; a < Mods.size(); a++) { + CString sName = Mods[a]->GetModName(); CString sArgs = Mods[a]->GetArgs(); if (!sArgs.empty()) { - sArgs = " " + sArgs; + sArgs = " " + sArgs.FirstLine(); } - File.Write("LoadModule = " + Mods[a]->GetModName() + sArgs + "\n"); + File.Write("LoadModule = " + sName.FirstLine() + sArgs + "\n"); } #endif