summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/convto.h110
-rw-r--r--include/extensible.h2
-rw-r--r--include/inspircd.h86
-rw-r--r--include/isupportmanager.h6
-rw-r--r--include/modules.h10
-rw-r--r--include/modules/stats.h172
-rw-r--r--include/modules/whois.h54
-rw-r--r--include/numeric.h103
-rw-r--r--include/numericbuilder.h30
-rw-r--r--include/numerics.h2
-rw-r--r--include/typedefs.h5
-rw-r--r--include/users.h104
-rw-r--r--include/xline.h5
13 files changed, 560 insertions, 129 deletions
diff --git a/include/convto.h b/include/convto.h
new file mode 100644
index 000000000..eaf14f6dc
--- /dev/null
+++ b/include/convto.h
@@ -0,0 +1,110 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
+ * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
+ *
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+/** Template function to convert any input type to std::string
+ */
+template<typename T> inline std::string ConvNumeric(const T& in)
+{
+ if (in == 0)
+ return "0";
+ T quotient = in;
+ std::string out;
+ while (quotient)
+ {
+ out += "0123456789"[std::abs((long)quotient % 10)];
+ quotient /= 10;
+ }
+ if (in < 0)
+ out += '-';
+ std::reverse(out.begin(), out.end());
+ return out;
+}
+
+/** Template function to convert any input type to std::string
+ */
+inline std::string ConvToStr(const int in)
+{
+ return ConvNumeric(in);
+}
+
+/** Template function to convert any input type to std::string
+ */
+inline std::string ConvToStr(const long in)
+{
+ return ConvNumeric(in);
+}
+
+/** Template function to convert any input type to std::string
+ */
+inline std::string ConvToStr(const char* in)
+{
+ return in;
+}
+
+/** Template function to convert any input type to std::string
+ */
+inline std::string ConvToStr(const bool in)
+{
+ return (in ? "1" : "0");
+}
+
+/** Template function to convert any input type to std::string
+ */
+inline std::string ConvToStr(char in)
+{
+ return std::string(1, in);
+}
+
+inline const std::string& ConvToStr(const std::string& in)
+{
+ return in;
+}
+
+/** Template function to convert any input type to std::string
+ */
+template <class T> inline std::string ConvToStr(const T& in)
+{
+ std::stringstream tmp;
+ if (!(tmp << in))
+ return std::string();
+ return tmp.str();
+}
+
+/** Template function to convert any input type to any other type
+ * (usually an integer or numeric type)
+ */
+template<typename T> inline long ConvToInt(const T& in)
+{
+ std::stringstream tmp;
+ if (!(tmp << in))
+ return 0;
+ return atol(tmp.str().c_str());
+}
+
+inline uint64_t ConvToUInt64(const std::string& in)
+{
+ uint64_t ret;
+ std::istringstream tmp(in);
+ if (!(tmp >> ret))
+ return 0;
+ return ret;
+}
diff --git a/include/extensible.h b/include/extensible.h
index 9714e9654..07756fb59 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -19,8 +19,6 @@
#pragma once
-#include <stdint.h>
-
enum SerializeFormat
{
/** Shown to a human (does not need to be unserializable) */
diff --git a/include/inspircd.h b/include/inspircd.h
index 20a6508c9..ee09070f8 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -32,6 +32,7 @@
#include <cstdio>
#include <cstring>
#include <ctime>
+#include <stdint.h>
#include <algorithm>
#include <bitset>
@@ -64,6 +65,7 @@ struct fakederef
};
#include "config.h"
+#include "convto.h"
#include "dynref.h"
#include "consolecolors.h"
#include "caller.h"
@@ -71,6 +73,7 @@ struct fakederef
#include "extensible.h"
#include "fileutils.h"
#include "numerics.h"
+#include "numeric.h"
#include "uid.h"
#include "server.h"
#include "users.h"
@@ -94,88 +97,6 @@ struct fakederef
#include "bancache.h"
#include "isupportmanager.h"
-/** Template function to convert any input type to std::string
- */
-template<typename T> inline std::string ConvNumeric(const T &in)
-{
- if (in == 0)
- return "0";
- T quotient = in;
- std::string out;
- while (quotient)
- {
- out += "0123456789"[ std::abs( (long)quotient % 10 ) ];
- quotient /= 10;
- }
- if (in < 0)
- out += '-';
- std::reverse(out.begin(), out.end());
- return out;
-}
-
-/** Template function to convert any input type to std::string
- */
-inline std::string ConvToStr(const int in)
-{
- return ConvNumeric(in);
-}
-
-/** Template function to convert any input type to std::string
- */
-inline std::string ConvToStr(const long in)
-{
- return ConvNumeric(in);
-}
-
-/** Template function to convert any input type to std::string
- */
-inline std::string ConvToStr(const char* in)
-{
- return in;
-}
-
-/** Template function to convert any input type to std::string
- */
-inline std::string ConvToStr(const bool in)
-{
- return (in ? "1" : "0");
-}
-
-/** Template function to convert any input type to std::string
- */
-inline std::string ConvToStr(char in)
-{
- return std::string(1, in);
-}
-
-/** Template function to convert any input type to std::string
- */
-template <class T> inline std::string ConvToStr(const T &in)
-{
- std::stringstream tmp;
- if (!(tmp << in)) return std::string();
- return tmp.str();
-}
-
-/** Template function to convert any input type to any other type
- * (usually an integer or numeric type)
- */
-template<typename T> inline long ConvToInt(const T &in)
-{
- std::stringstream tmp;
- if (!(tmp << in)) return 0;
- return atol(tmp.str().c_str());
-}
-
-inline uint64_t ConvToUInt64(const std::string& in)
-{
- uint64_t ret;
- std::istringstream tmp(in);
- if (!(tmp >> ret))
- return 0;
- return ret;
-}
-
/** This class contains various STATS counters
* It is used by the InspIRCd class, which internally
* has an instance of it.
@@ -666,3 +587,4 @@ inline void stdalgo::culldeleter::operator()(classbase* item)
#include "numericbuilder.h"
#include "modules/whois.h"
+#include "modules/stats.h"
diff --git a/include/isupportmanager.h b/include/isupportmanager.h
index 1f41de5d2..3a0df78f9 100644
--- a/include/isupportmanager.h
+++ b/include/isupportmanager.h
@@ -24,7 +24,7 @@ class CoreExport ISupportManager
{
private:
/** The generated lines which are sent to clients. */
- std::vector<std::string> cachedlines;
+ std::vector<Numeric::Numeric> cachedlines;
public:
/** (Re)build the ISUPPORT vector.
@@ -34,9 +34,9 @@ class CoreExport ISupportManager
void Build();
/** Returns the cached std::vector of ISUPPORT lines.
- * @return A list of strings prepared for sending to users
+ * @return A list of Numeric::Numeric objects prepared for sending to users
*/
- const std::vector<std::string>& GetLines() const { return cachedlines; }
+ const std::vector<Numeric::Numeric>& GetLines() const { return cachedlines; }
/** Send the 005 numerics (ISUPPORT) to a user.
* @param user The user to send the ISUPPORT numerics to
diff --git a/include/modules.h b/include/modules.h
index 526c283b2..d97f02046 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -873,14 +873,10 @@ class CoreExport Module : public classbase, public usecountbase
/** Called on all /STATS commands
* This method is triggered for all /STATS use, including stats symbols handled by the core.
- * @param symbol the symbol provided to /STATS
- * @param user the user issuing the /STATS command
- * @param results A string_list to append results into. You should put all your results
- * into this string_list, rather than displaying them directly, so that your handler will
- * work when remote STATS queries are received.
+ * @param stats Context of the /STATS request, contains requesting user, list of answer rows etc.
* @return 1 to block the /STATS from being processed by the core, 0 to allow it
*/
- virtual ModResult OnStats(char symbol, User* user, string_list &results);
+ virtual ModResult OnStats(Stats::Context& stats);
/** Called whenever a change of a local users displayed host is attempted.
* Return 1 to deny the host change, or 0 to allow it.
@@ -987,7 +983,7 @@ class CoreExport Module : public classbase, public usecountbase
*/
virtual ModResult OnNamesListItem(User* issuer, Membership* item, std::string& prefixes, std::string& nick);
- virtual ModResult OnNumeric(User* user, unsigned int numeric, const std::string &text);
+ virtual ModResult OnNumeric(User* user, const Numeric::Numeric& numeric);
/** Called whenever a result from /WHO is about to be returned
* @param source The user running the /WHO query
diff --git a/include/modules/stats.h b/include/modules/stats.h
new file mode 100644
index 000000000..b1e27b4e7
--- /dev/null
+++ b/include/modules/stats.h
@@ -0,0 +1,172 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2016 Attila Molnar <attilamolnar@hush.com>
+ *
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+namespace Stats
+{
+ class Context;
+ class Row;
+}
+
+class Stats::Row : public Numeric::Numeric
+{
+ public:
+ Row(unsigned int num)
+ : Numeric(num)
+ {
+ }
+};
+
+class Stats::Context
+{
+ /** Source user of the STATS request
+ */
+ User* const source;
+
+ /** List of reply rows
+ */
+ std::vector<Row> rows;
+
+ /** Symbol indicating the type of this STATS request (usually a letter)
+ */
+ const char symbol;
+
+ public:
+ /** Constructor
+ * @param src Source user of the STATS request, can be a local or remote user
+ * @param sym Symbol (letter) indicating the type of the request
+ */
+ Context(User* src, char sym)
+ : source(src)
+ , symbol(sym)
+ {
+ }
+
+ /** Get the source user of the STATS request
+ * @return Source user of the STATS request
+ */
+ User* GetSource() const { return source; }
+
+ /** Get the list of reply rows
+ * @return List of rows generated as reply for the request
+ */
+ const std::vector<Row>& GetRows() const { return rows; }
+
+ /** Get the symbol (letter) indicating what type of STATS was requested
+ * @return Symbol specified by the requesting user
+ */
+ char GetSymbol() const { return symbol; }
+
+ /** Add a row to the reply list
+ * @param row Reply to add
+ */
+ void AddRow(const Row& row) { rows.push_back(row); }
+
+ template <typename T1>
+ void AddRow(unsigned int numeric, T1 p1)
+ {
+ Row n(numeric);
+ n.push(p1);
+ AddRow(n);
+ }
+
+ template <typename T1, typename T2>
+ void AddRow(unsigned int numeric, T1 p1, T2 p2)
+ {
+ Row n(numeric);
+ n.push(p1);
+ n.push(p2);
+ AddRow(n);
+ }
+
+ template <typename T1, typename T2, typename T3>
+ void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3)
+ {
+ Row n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ AddRow(n);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4>
+ void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
+ {
+ Row n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ n.push(p4);
+ AddRow(n);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5>
+ void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
+ {
+ Row n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ n.push(p4);
+ n.push(p5);
+ AddRow(n);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
+ void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6)
+ {
+ Row n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ n.push(p4);
+ n.push(p5);
+ n.push(p6);
+ AddRow(n);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
+ void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7)
+ {
+ Row n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ n.push(p4);
+ n.push(p5);
+ n.push(p6);
+ n.push(p7);
+ AddRow(n);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
+ void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8)
+ {
+ Row n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ n.push(p4);
+ n.push(p5);
+ n.push(p6);
+ n.push(p7);
+ AddRow(n);
+ }
+};
diff --git a/include/modules/whois.h b/include/modules/whois.h
index b64d46410..4f09d268b 100644
--- a/include/modules/whois.h
+++ b/include/modules/whois.h
@@ -55,12 +55,11 @@ class Whois::LineEventListener : public Events::ModuleEventListener
* the values numeric and text, but you cannot change the user the
* numeric is sent to.
* @param whois Whois context, can be used to send numerics
- * @param numeric The numeric of the line being sent
- * @param text The text of the numeric, including any parameters
+ * @param numeric Numeric being sent
* @return MOD_RES_DENY to drop the line completely so that the user does not
* receive it, or MOD_RES_PASSTHRU to allow the line to be sent.
*/
- virtual ModResult OnWhoisLine(Context& whois, unsigned int& numeric, std::string& text) = 0;
+ virtual ModResult OnWhoisLine(Context& whois, Numeric::Numeric& numeric) = 0;
};
class Whois::Context
@@ -97,20 +96,51 @@ class Whois::Context
User* GetTarget() const { return target; }
/** Send a line of WHOIS data to the source of the WHOIS
- * @param numeric Numeric to send
- * @param format Format string for the numeric
- * @param ... Parameters for the format string
*/
- void SendLine(unsigned int numeric, const char* format, ...) CUSTOM_PRINTF(3, 4)
+ template <typename T1>
+ void SendLine(unsigned int numeric, T1 p1)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(target->nick);
+ n.push(p1);
+ SendLine(n);
+ }
+
+ template <typename T1, typename T2>
+ void SendLine(unsigned int numeric, T1 p1, T2 p2)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(target->nick);
+ n.push(p1);
+ n.push(p2);
+ SendLine(n);
+ }
+
+ template <typename T1, typename T2, typename T3>
+ void SendLine(unsigned int numeric, T1 p1, T2 p2, T3 p3)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(target->nick);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ SendLine(n);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4>
+ void SendLine(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
{
- std::string textbuffer;
- VAFORMAT(textbuffer, format, format)
- SendLine(numeric, textbuffer);
+ Numeric::Numeric n(numeric);
+ n.push(target->nick);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ n.push(p4);
+ SendLine(n);
}
/** Send a line of WHOIS data to the source of the WHOIS
* @param numeric Numeric to send
- * @param text Text of the numeric
*/
- virtual void SendLine(unsigned int numeric, const std::string& text) = 0;
+ virtual void SendLine(Numeric::Numeric& numeric) = 0;
};
diff --git a/include/numeric.h b/include/numeric.h
new file mode 100644
index 000000000..8044fe5bf
--- /dev/null
+++ b/include/numeric.h
@@ -0,0 +1,103 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2016 Attila Molnar <attilamolnar@hush.com>
+ *
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+#include "numerics.h"
+
+namespace Numeric
+{
+ class Numeric;
+}
+
+class Numeric::Numeric
+{
+ /** Numeric number
+ */
+ unsigned int numeric;
+
+ /** Parameters of the numeric
+ */
+ std::vector<std::string> params;
+
+ /** Source server of the numeric, if NULL (the default) then it is the local server
+ */
+ Server* sourceserver;
+
+ public:
+ /** Constructor
+ * @param num Numeric number (RPL_*, ERR_*)
+ */
+ Numeric(unsigned int num)
+ : numeric(num)
+ , sourceserver(NULL)
+ {
+ }
+
+ /** Add a parameter to the numeric. The parameter will be converted to a string first with ConvToStr().
+ * @param x Parameter to add
+ */
+ template <typename T>
+ Numeric& push(const T& x)
+ {
+ params.push_back(ConvToStr(x));
+ return *this;
+ }
+
+ /** Set the source server of the numeric. The source server defaults to the local server.
+ * @param server Server to set as source
+ */
+ void SetServer(Server* server) { sourceserver = server; }
+
+ /** Get the source server of the numeric
+ * @return Source server or NULL if the source is the local server
+ */
+ Server* GetServer() const { return sourceserver; }
+
+ /** Get the number of the numeric as an unsigned integer
+ * @return Numeric number as an unsigned integer
+ */
+ unsigned int GetNumeric() const { return numeric; }
+
+ /** Get the parameters of the numeric
+ * @return Parameters of the numeric as a const vector of strings
+ */
+ const std::vector<std::string>& GetParams() const { return params; }
+
+ /** Get the parameters of the numeric
+ * @return Parameters of the numeric as a vector of strings
+ */
+ std::vector<std::string>& GetParams() { return params; }
+};
+
+namespace Numerics
+{
+ /** ERR_NOSUCHNICK numeric
+ */
+ class NoSuchNick : public Numeric::Numeric
+ {
+ public:
+ NoSuchNick(const std::string& nick)
+ : Numeric(ERR_NOSUCHNICK)
+ {
+ push(nick);
+ push("No such nick/channel");
+ }
+ };
+}
diff --git a/include/numericbuilder.h b/include/numericbuilder.h
index 36cfeedb4..726aeff3f 100644
--- a/include/numericbuilder.h
+++ b/include/numericbuilder.h
@@ -40,9 +40,9 @@ class Numeric::WriteNumericSink
{
}
- void operator()(unsigned int numeric, const std::string& params) const
+ void operator()(Numeric& numeric) const
{
- user->WriteNumeric(numeric, params);
+ user->WriteNumeric(numeric);
}
};
@@ -50,14 +50,12 @@ template <char Sep, bool SendEmpty, typename Sink>
class Numeric::GenericBuilder
{
Sink sink;
- std::string data;
- const unsigned int numeric;
+ Numeric numeric;
const std::string::size_type max;
- std::string::size_type beginpos;
bool HasRoom(const std::string::size_type additional) const
{
- return (data.size() + additional <= max);
+ return (numeric.GetParams().back().size() + additional <= max);
}
public:
@@ -67,28 +65,28 @@ class Numeric::GenericBuilder
, max(ServerInstance->Config->Limits.MaxLine - ServerInstance->Config->ServerName.size() - additionalsize - 9)
{
if (addparam)
- data.push_back(':');
- SaveBeginPos();
+ numeric.push(std::string());
}
- std::string& GetNumeric() { return data; }
+ Numeric& GetNumeric() { return numeric; }
void Add(const std::string& entry)
{
if (!HasRoom(entry.size()))
Flush();
- data.append(entry).push_back(Sep);
+ numeric.GetParams().back().append(entry).push_back(Sep);
}
void Add(const std::string& entry1, const std::string& entry2)
{
if (!HasRoom(entry1.size() + entry2.size()))
Flush();
- data.append(entry1).append(entry2).push_back(Sep);
+ numeric.GetParams().back().append(entry1).append(entry2).push_back(Sep);
}
void Flush()
{
+ std::string& data = numeric.GetParams().back();
if (IsEmpty())
{
if (!SendEmpty)
@@ -99,13 +97,11 @@ class Numeric::GenericBuilder
data.erase(data.size()-1);
}
- sink(numeric, data);
- if (data.size() > beginpos)
- data.erase(beginpos);
+ sink(numeric);
+ data.clear();
}
- bool IsEmpty() const { return (data.size() == beginpos); }
- void SaveBeginPos() { beginpos = data.size(); }
+ bool IsEmpty() const { return (numeric.GetParams().back().empty()); }
};
template <char Sep, bool SendEmpty>
@@ -113,7 +109,7 @@ class Numeric::Builder : public GenericBuilder<Sep, SendEmpty, WriteNumericSink>
{
public:
Builder(LocalUser* user, unsigned int num, bool addparam = true, size_t additionalsize = 0)
- : Numeric::GenericBuilder<Sep, SendEmpty, WriteNumericSink>(WriteNumericSink(user), num, addparam, additionalsize + user->nick.size())
+ : ::Numeric::GenericBuilder<Sep, SendEmpty, WriteNumericSink>(WriteNumericSink(user), num, addparam, additionalsize + user->nick.size())
{
}
};
diff --git a/include/numerics.h b/include/numerics.h
index 0447df353..72caaddcc 100644
--- a/include/numerics.h
+++ b/include/numerics.h
@@ -35,7 +35,7 @@
* Please note that the list may not be exhaustive, it'll be done when I have
* nothing better to do with my time. -- w00t (jul 13, 2008)
*/
-enum Numerics
+enum
{
/*
* Reply range of numerics.
diff --git a/include/typedefs.h b/include/typedefs.h
index dfecb0483..17c05d704 100644
--- a/include/typedefs.h
+++ b/include/typedefs.h
@@ -111,3 +111,8 @@ typedef XLineContainer::iterator ContainerIter;
/** An interator in an XLineLookup
*/
typedef XLineLookup::iterator LookupIter;
+
+namespace Stats
+{
+ class Context;
+}
diff --git a/include/users.h b/include/users.h
index fa346a329..5e7df74ea 100644
--- a/include/users.h
+++ b/include/users.h
@@ -519,9 +519,109 @@ class CoreExport User : public Extensible
*/
void WriteNotice(const std::string& text) { this->WriteCommand("NOTICE", ":" + text); }
- void WriteNumeric(unsigned int numeric, const char* text, ...) CUSTOM_PRINTF(3, 4);
+ void WriteRemoteNumeric(const Numeric::Numeric& numeric);
- void WriteNumeric(unsigned int numeric, const std::string &text);
+ template <typename T1>
+ void WriteRemoteNumeric(unsigned int numeric, T1 p1)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(p1);
+ WriteRemoteNumeric(n);
+ }
+
+ template <typename T1, typename T2>
+ void WriteRemoteNumeric(unsigned int numeric, T1 p1, T2 p2)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(p1);
+ n.push(p2);
+ WriteRemoteNumeric(n);
+ }
+
+ template <typename T1, typename T2, typename T3>
+ void WriteRemoteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ WriteRemoteNumeric(n);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4>
+ void WriteRemoteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ n.push(p4);
+ WriteRemoteNumeric(n);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5>
+ void WriteRemoteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ n.push(p4);
+ n.push(p5);
+ WriteRemoteNumeric(n);
+ }
+
+ void WriteNumeric(const Numeric::Numeric& numeric);
+
+ template <typename T1>
+ void WriteNumeric(unsigned int numeric, T1 p1)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(p1);
+ WriteNumeric(n);
+ }
+
+ template <typename T1, typename T2>
+ void WriteNumeric(unsigned int numeric, T1 p1, T2 p2)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(p1);
+ n.push(p2);
+ WriteNumeric(n);
+ }
+
+ template <typename T1, typename T2, typename T3>
+ void WriteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ WriteNumeric(n);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4>
+ void WriteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ n.push(p4);
+ WriteNumeric(n);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5>
+ void WriteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)
+ {
+ Numeric::Numeric n(numeric);
+ n.push(p1);
+ n.push(p2);
+ n.push(p3);
+ n.push(p4);
+ n.push(p5);
+ WriteNumeric(n);
+ }
/** Write text to this user, appending CR/LF and prepending :nick!user\@host of the user provided in the first parameter.
* @param user The user to prepend the :nick!user\@host of
diff --git a/include/xline.h b/include/xline.h
index fe044d0f2..c2ede29df 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -520,8 +520,7 @@ class CoreExport XLineManager
* will be expired and removed before the list is displayed.
* @param type The type of stats to show
* @param numeric The numeric to give to each result line
- * @param user The username making the query
- * @param results The string_list to receive the results
+ * @param stats Stats context
*/
- void InvokeStats(const std::string &type, int numeric, User* user, string_list &results);
+ void InvokeStats(const std::string& type, unsigned int numeric, Stats::Context& stats);
};