From b70a115a281d2a5a59eb0d3fc68ba581c0d01851 Mon Sep 17 00:00:00 2001 From: psychon Date: Sun, 24 Aug 2008 12:49:40 +0000 Subject: [PATCH] Add a new function CModule::PutModule(const CTable&) This function displays a CTable via PutModule(), something that is often needed. The function returns the number of lines displayed. The idea for this function is from the user-contributed admin module by Sebastian Ramacher. Thanks. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1168 726aef4b-f618-498e-8847-2d620e286838 --- Modules.cpp | 10 ++++++++++ Modules.h | 1 + 2 files changed, 11 insertions(+) diff --git a/Modules.cpp b/Modules.cpp index 173ea357..773d4830 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -503,6 +503,16 @@ bool CModule::PutUser(const CString& sLine) { bool CModule::PutStatus(const CString& sLine) { return (m_pUser) ? m_pUser->PutStatus(sLine, m_pClient) : false; } +unsigned int CModule::PutModule(const CTable& table, const CString& sIdent, const CString& sHost) { + if (!m_pUser) + return 0; + + unsigned int idx = 0; + CString sLine; + while (table.GetLine(idx++, sLine)) + PutModule(sLine, sIdent, sHost); + return idx - 1; +} bool CModule::PutModule(const CString& sLine, const CString& sIdent, const CString& sHost) { if (!m_pUser) return false; diff --git a/Modules.h b/Modules.h index 03212399..6e5d94f5 100644 --- a/Modules.h +++ b/Modules.h @@ -283,6 +283,7 @@ public: virtual bool PutUser(const CString& sLine); virtual bool PutStatus(const CString& sLine); virtual bool PutModule(const CString& sLine, const CString& sIdent = "", const CString& sHost = "znc.com"); + virtual unsigned int PutModule(const CTable& table, const CString& sIdent = "", const CString& sHost = "znc.com"); virtual bool PutModNotice(const CString& sLine, const CString& sIdent = "", const CString& sHost = "znc.com"); const CString& GetModName() const { return m_sModName; }