summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-12-06 21:02:48 -0500
committerAdam <Adam@anope.org>2016-12-06 21:02:48 -0500
commit87ec095a89bbc73a4dd16858bea499f466066212 (patch)
tree776129c883242ae6b6c27884b128a336b801999b /include
parent1ff4719ea70cfead41bd91d7b78cfdcb5b84b8cc (diff)
Remove many more old C style format strings in the protocol functions
Diffstat (limited to 'include')
-rw-r--r--include/anope.h7
-rw-r--r--include/module.h1
-rw-r--r--include/modules/protocol/charybdis.h2
-rw-r--r--include/modules/protocol/hybrid.h4
-rw-r--r--include/modules/protocol/plexus.h2
-rw-r--r--include/modules/protocol/ratbox.h2
-rw-r--r--include/modules/protocol/rfc1459.h6
-rw-r--r--include/modules/protocol/unreal.h2
-rw-r--r--include/numeric.h42
-rw-r--r--include/protocol.h211
-rw-r--r--include/uplink.h2
-rw-r--r--include/version.cpp20
12 files changed, 207 insertions, 94 deletions
diff --git a/include/anope.h b/include/anope.h
index 19d9f9501..02a8c3fef 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -147,6 +147,8 @@ namespace Anope
*/
inline void push_back(char c) { return this->_string.push_back(c); }
+ inline string& insert(const_iterator p, char c) { this->_string.insert(p, c); return *this; }
+
inline string& append(const string &s) { this->_string.append(s.str()); return *this; }
inline string& append(const char *s, size_t n) { this->_string.append(s, n); return *this; }
@@ -353,7 +355,7 @@ namespace Anope
template<typename T> using locale_hash_map = std::unordered_map<string, T, hash_locale, compare_locale>;
#ifndef REPRODUCIBLE_BUILD
- static const char *const compiled = __TIME__ " " __DATE__;
+ static const char *const COMPILED = __DATE__ " " __TIME__;
#endif
/** The time Anope started.
@@ -406,7 +408,8 @@ namespace Anope
*/
extern CoreExport string Version();
extern CoreExport string VersionShort();
- extern CoreExport string VersionBuildString();
+ extern CoreExport string VersionBuildTime();
+ extern CoreExport string VersionFlags();
extern CoreExport int VersionMajor();
extern CoreExport int VersionMinor();
extern CoreExport int VersionPatch();
diff --git a/include/module.h b/include/module.h
index 6371eb336..58b012fce 100644
--- a/include/module.h
+++ b/include/module.h
@@ -34,6 +34,7 @@
#include "mail.h"
#include "modes.h"
#include "modules.h"
+#include "numeric.h"
#include "opertype.h"
#include "protocol.h"
#include "serialize.h"
diff --git a/include/modules/protocol/charybdis.h b/include/modules/protocol/charybdis.h
index 4d525c49d..d65e094a0 100644
--- a/include/modules/protocol/charybdis.h
+++ b/include/modules/protocol/charybdis.h
@@ -43,7 +43,7 @@ class EUID : public IRCDMessage
class ServerMessage : public IRCDMessage
{
public:
- ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { }
// SERVER dev.anope.de 1 :charybdis test server
void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
diff --git a/include/modules/protocol/hybrid.h b/include/modules/protocol/hybrid.h
index 9c1444f4d..943480f54 100644
--- a/include/modules/protocol/hybrid.h
+++ b/include/modules/protocol/hybrid.h
@@ -67,7 +67,7 @@ class Pong : public IRCDMessage
class ServerMessage : public IRCDMessage
{
public:
- ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { }
void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
@@ -75,7 +75,7 @@ class ServerMessage : public IRCDMessage
class SID : public IRCDMessage
{
public:
- SID(Module *creator) : IRCDMessage(creator, "SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ SID(Module *creator) : IRCDMessage(creator, "SID", 4) { }
void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
diff --git a/include/modules/protocol/plexus.h b/include/modules/protocol/plexus.h
index b87f3e6c7..0c5d8d8c0 100644
--- a/include/modules/protocol/plexus.h
+++ b/include/modules/protocol/plexus.h
@@ -33,7 +33,7 @@ class Encap : public IRCDMessage
class ServerMessage : public IRCDMessage
{
public:
- ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { }
void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
diff --git a/include/modules/protocol/ratbox.h b/include/modules/protocol/ratbox.h
index 32710fbea..2ad4a5529 100644
--- a/include/modules/protocol/ratbox.h
+++ b/include/modules/protocol/ratbox.h
@@ -44,7 +44,7 @@ class Join : public rfc1459::Join
class ServerMessage : public IRCDMessage
{
public:
- ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { }
void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
diff --git a/include/modules/protocol/rfc1459.h b/include/modules/protocol/rfc1459.h
index 635e151c8..4ef8f0313 100644
--- a/include/modules/protocol/rfc1459.h
+++ b/include/modules/protocol/rfc1459.h
@@ -164,7 +164,7 @@ class Stats : public IRCDMessage
class Time : public IRCDMessage
{
public:
- Time(Module *creator, const Anope::string &mname = "TIME") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+ Time(Module *creator, const Anope::string &mname = "TIME") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); }
void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
@@ -180,7 +180,7 @@ class Topic : public IRCDMessage
class Version : public IRCDMessage
{
public:
- Version(Module *creator, const Anope::string &mname = "VERSION") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+ Version(Module *creator, const Anope::string &mname = "VERSION") : IRCDMessage(creator, mname, 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); }
void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
@@ -188,7 +188,7 @@ class Version : public IRCDMessage
class Whois : public IRCDMessage
{
public:
- Whois(Module *creator, const Anope::string &mname = "WHOIS") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
+ Whois(Module *creator, const Anope::string &mname = "WHOIS") : IRCDMessage(creator, mname, 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); }
void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
diff --git a/include/modules/protocol/unreal.h b/include/modules/protocol/unreal.h
index 305d52bd0..88ed05997 100644
--- a/include/modules/protocol/unreal.h
+++ b/include/modules/protocol/unreal.h
@@ -139,7 +139,7 @@ struct SetName : IRCDMessage
class ServerMessage : public IRCDMessage
{
public:
- ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
+ ServerMessage(Module *creator) : IRCDMessage(creator, "SERVER", 3) { }
void Run(MessageSource &source, const std::vector<Anope::string> &params) override;
};
diff --git a/include/numeric.h b/include/numeric.h
new file mode 100644
index 000000000..57de4433f
--- /dev/null
+++ b/include/numeric.h
@@ -0,0 +1,42 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2016 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope 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 see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+enum
+{
+ RPL_STATSLINKINFO = 211,
+ RPL_ENDOFSTATS = 219,
+ RPL_STATSUPTIME = 242,
+ RPL_STATSOLINE = 243,
+ RPL_STATSCONN = 250,
+ RPL_WHOISREGNICK = 307,
+ RPL_WHOISUSER = 311,
+ RPL_WHOISSERVER = 312,
+ RPL_WHOISIDLE = 317,
+ RPL_ENDOFWHOIS = 318,
+ RPL_VERSION = 351,
+ RPL_MOTD = 372,
+ RPL_MOTDSTART = 375,
+ RPL_ENDOFMOTD = 376,
+ RPL_YOUREOPER = 381,
+ RPL_TIME = 391,
+ ERR_NOSUCHNICK = 401,
+ ERR_NOMOTD = 422
+};
diff --git a/include/protocol.h b/include/protocol.h
index 7475fed21..50d16d7b3 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -22,6 +22,8 @@
#include "services.h"
#include "anope.h"
#include "service.h"
+#include "servers.h"
+#include "users.h"
class IRCMessage;
@@ -30,57 +32,62 @@ class CoreExport IRCDProto : public Service
{
Anope::string proto_name;
- protected:
- IRCDProto(Module *creator, const Anope::string &proto_name);
- public:
+public:
static constexpr const char *NAME = "ircdproto";
-
- virtual ~IRCDProto();
-
- virtual void SendSVSKillInternal(const MessageSource &, User *, const Anope::string &);
- virtual void SendModeInternal(const MessageSource &, const Channel *, const Anope::string &);
- virtual void SendModeInternal(const MessageSource &, User *, const Anope::string &);
- virtual void SendKickInternal(const MessageSource &, const Channel *, User *, const Anope::string &);
- virtual void SendNoticeInternal(const MessageSource &, const Anope::string &dest, const Anope::string &msg);
- virtual void SendPrivmsgInternal(const MessageSource &, const Anope::string &dest, const Anope::string &buf);
- virtual void SendQuitInternal(User *, const Anope::string &buf);
- virtual void SendPartInternal(User *, const Channel *chan, const Anope::string &buf);
- virtual void SendGlobopsInternal(const MessageSource &, const Anope::string &buf);
- virtual void SendCTCPInternal(const MessageSource &, const Anope::string &dest, const Anope::string &buf);
- virtual void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf);
-
- const Anope::string &GetProtocolName();
- virtual void Parse(const Anope::string &, Anope::string &, Anope::string &, std::vector<Anope::string> &);
- virtual Anope::string Format(IRCMessage &);
/* Modes used by default by our clients */
- Anope::string DefaultPseudoclientModes;
+ Anope::string DefaultPseudoclientModes = "+io";
/* Can we force change a users's nick? */
- bool CanSVSNick;
+ bool CanSVSNick = false;
/* Can we force join or part users? */
- bool CanSVSJoin;
+ bool CanSVSJoin = false;
/* Can we set vhosts/vidents on users? */
- bool CanSetVHost, CanSetVIdent;
+ bool CanSetVHost = false, CanSetVIdent = false;
/* Can we ban specific gecos from being used? */
- bool CanSNLine;
+ bool CanSNLine = false;
/* Can we ban specific nicknames from being used? */
- bool CanSQLine;
+ bool CanSQLine = false;
/* Can we ban sepcific channel names from being used? */
- bool CanSQLineChannel;
+ bool CanSQLineChannel = false;
/* Can we ban by IP? */
- bool CanSZLine;
+ bool CanSZLine = false;
/* Can we place temporary holds on specific nicknames? */
- bool CanSVSHold;
+ bool CanSVSHold = false;
/* See ns_cert */
- bool CanCertFP;
+ bool CanCertFP = false;
/* Whether this IRCd requires unique IDs for each user or server. See TS6/P10. */
- bool RequiresID;
+ bool RequiresID = false;
/* If this IRCd has unique ids, whether the IDs and nicknames are ambiguous */
- bool AmbiguousID;
+ bool AmbiguousID = false;
/* The maximum number of modes we are allowed to set with one MODE command */
- unsigned MaxModes;
+ unsigned int MaxModes = 3;
/* The maximum number of bytes a line may have */
- unsigned MaxLine;
+ unsigned int MaxLine = 512;
+
+ IRCDProto(Module *creator, const Anope::string &proto_name);
+ virtual ~IRCDProto();
+
+ const Anope::string &GetProtocolName() const;
+
+ virtual void Parse(const Anope::string &, Anope::string &, Anope::string &, std::vector<Anope::string> &);
+ virtual Anope::string Format(IRCMessage &);
+
+ /** Kills a user
+ * @param source Who is doing the kill
+ * @param user The target to be killed
+ * @param reason Kill reason
+ */
+ virtual void SendSVSKill(const MessageSource &source, User *user, const Anope::string &reason);
+ virtual void SendMode(const MessageSource &, Channel *, const Anope::string &);
+ virtual void SendMode(const MessageSource &, User *, const Anope::string &);
+ virtual void SendKick(const MessageSource &, Channel *, User *, const Anope::string &);
+ virtual void SendNotice(const MessageSource &, const Anope::string &dest, const Anope::string &msg);
+ virtual void SendPrivmsg(const MessageSource &, const Anope::string &dest, const Anope::string &msg);
+ virtual void SendQuit(User *, const Anope::string &reason);
+ virtual void SendPart(User *, Channel *chan, const Anope::string &reason);
+ virtual void SendGlobops(const MessageSource &, const Anope::string &buf);
+ virtual void SendCTCPReply(const MessageSource &, const Anope::string &dest, const Anope::string &buf);
+ virtual void SendNumeric(int numeric, User *dest, IRCMessage &);
/* Retrieves the next free UID or SID */
virtual Anope::string UID_Retrieve();
@@ -91,7 +98,7 @@ class CoreExport IRCDProto : public Service
* @param s The server
* @param mode Whether to turn NOOP on or off
*/
- virtual void SendSVSNOOP(const Server *s, bool mode) { }
+ virtual void SendSVSNOOP(Server *s, bool mode) { }
/** Sets the topic on a channel
* @param bi The bot to set the topic from
@@ -130,32 +137,18 @@ class CoreExport IRCDProto : public Service
virtual void SendKill(const MessageSource &source, const Anope::string &target, const Anope::string &reason);
- /** Kills a user
- * @param source Who is doing the kill
- * @param user The user to be killed
- * @param fmt Kill reason
- */
- virtual void SendSVSKill(const MessageSource &source, User *user, const char *fmt, ...);
-
- virtual void SendMode(const MessageSource &source, const Channel *dest, const char *fmt, ...);
- virtual void SendMode(const MessageSource &source, User *u, const char *fmt, ...);
-
/** Introduces a client to the rest of the network
* @param u The client to introduce
*/
virtual void SendClientIntroduction(User *u) anope_abstract;
- virtual void SendKick(const MessageSource &source, const Channel *chan, User *user, const char *fmt, ...);
- virtual void SendNotice(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
- virtual void SendPrivmsg(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
- virtual void SendAction(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
- virtual void SendCTCP(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
+ virtual void SendAction(const MessageSource &source, const Anope::string &dest, const Anope::string &message);
+
+ virtual void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) anope_abstract;
+ virtual void SendGlobalPrivmsg(ServiceBot *bi, Server *desc, const Anope::string &msg) anope_abstract;
- virtual void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) anope_abstract;
- virtual void SendGlobalPrivmsg(ServiceBot *bi, const Server *desc, const Anope::string &msg) anope_abstract;
- virtual void SendQuit(User *u, const char *fmt, ...);
virtual void SendPing(const Anope::string &servname, const Anope::string &who);
/**
@@ -174,7 +167,6 @@ class CoreExport IRCDProto : public Service
* stacker to be set "soon".
*/
virtual void SendJoin(User *u, Channel *c, const ChannelStatus *status) anope_abstract;
- virtual void SendPart(User *u, const Channel *chan, const char *fmt, ...);
/** Force joins a user that isn't ours to a channel.
* @param bi The source of the message
@@ -192,8 +184,8 @@ class CoreExport IRCDProto : public Service
*/
virtual void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param) { }
- virtual void SendInvite(const MessageSource &source, const Channel *c, User *u);
- virtual void SendGlobops(const MessageSource &source, const char *fmt, ...);
+ virtual void SendInvite(const MessageSource &source, Channel *c, User *u);
+
/** Sends a nick change of one of our clients.
*/
@@ -221,10 +213,9 @@ class CoreExport IRCDProto : public Service
/** Introduces a server to the uplink
*/
- virtual void SendServer(const Server *) anope_abstract;
+ virtual void SendServer(Server *) anope_abstract;
virtual void SendSquit(Server *, const Anope::string &message);
- virtual void SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...);
virtual void SendLogin(User *u, NickServ::Nick *na) anope_abstract;
virtual void SendLogout(User *u) anope_abstract;
@@ -252,16 +243,74 @@ class CoreExport IRCDProto : public Service
/** Retrieve the maximum number of list modes settable on this channel
* Defaults to Config->ListSize
*/
- virtual unsigned GetMaxListFor(Channel *c);
+ virtual unsigned int GetMaxListFor(Channel *c);
virtual Anope::string NormalizeMask(const Anope::string &mask);
+
+ /* Templated functions which overload the normal functions to provide format strings */
+ template<typename... Args> void SendSVSKill(const MessageSource &source, User *user, const Anope::string &reason, Args&&... args)
+ {
+ SendSVSKill(source, user, Anope::Format(reason, std::forward<Args>(args)...));
+ }
+
+ template<typename... Args> void SendMode(const MessageSource &source, Channel *chan, const Anope::string &modes, Args&&... args)
+ {
+ SendMode(source, chan, Anope::Format(modes, std::forward<Args>(args)...));
+ }
+
+ template<typename... Args> void SendMode(const MessageSource &source, User *u, const Anope::string &modes, Args&&... args)
+ {
+ SendMode(source, u, Anope::Format(modes, std::forward<Args>(args)...));
+ }
+
+ template<typename... Args> void SendKick(const MessageSource &source, const Channel *chan, User *user, const Anope::string &reason, Args&&... args)
+ {
+ SendKick(source, chan, user, Anope::Format(reason, std::forward<Args>(args)...));
+ }
+
+ template<typename... Args> void SendNotice(const MessageSource &source, const Anope::string &dest, const Anope::string &message, Args&&... args)
+ {
+ SendNotice(source, dest, Anope::Format(message, std::forward<Args>(args)...));
+ }
+
+ template<typename... Args> void SendPrivmsg(const MessageSource &source, const Anope::string &dest, const Anope::string &message, Args&&... args)
+ {
+ SendPrivmsg(source, dest, Anope::Format(message, std::forward<Args>(args)...));
+ }
+
+ template<typename... Args> void SendAction(const MessageSource &source, const Anope::string &dest, const Anope::string &message, Args&&... args)
+ {
+ SendAction(source, dest, Anope::Format(message, std::forward<Args>(args)...));
+ }
+
+ template<typename... Args> void SendCTCPReply(const MessageSource &source, const Anope::string &dest, const Anope::string &message, Args&&... args)
+ {
+ SendCTCPReply(source, dest, Anope::Format(message, std::forward<Args>(args)...));
+ }
+
+ template<typename... Args> void SendGlobops(const MessageSource &source, const Anope::string &msg, Args&&... args)
+ {
+ SendGlobops(source, Anope::Format(msg, std::forward<Args>(args)...));
+ }
+
+ template<typename... Args> void SendNumeric(int numeric, User *dest, Args&&... args);
+
+ template<typename... Args> void SendQuit(User *u, const Anope::string &reason, Args&&... args)
+ {
+ SendQuit(u, Anope::Format(reason, std::forward<Args>(args)...));
+ }
+
+ template<typename... Args> void SendPart(User *u, Channel *chan, const Anope::string &reason, Args&&... args)
+ {
+ SendPart(u, chan, Anope::Format(reason, std::forward<Args>(args)...));
+ }
};
class CoreExport MessageSource
{
Anope::string source;
- User *u;
- Server *s;
+ User *u = nullptr;
+ Server *s = nullptr;
public:
MessageSource(const Anope::string &);
@@ -289,9 +338,9 @@ class CoreExport IRCDMessage : public Service
std::set<IRCDMessageFlag> flags;
public:
static constexpr const char *NAME = "IRCDMessage";
-
- IRCDMessage(Module *owner, const Anope::string &n, unsigned p = 0);
- unsigned GetParamCount() const;
+
+ IRCDMessage(Module *owner, const Anope::string &n, unsigned int p = 0);
+ unsigned int GetParamCount() const;
virtual void Run(MessageSource &, const std::vector<Anope::string> &params) anope_abstract;
void SetFlag(IRCDMessageFlag f) { flags.insert(f); }
@@ -305,9 +354,7 @@ class IRCMessage
MessageSource source;
Anope::string command;
std::vector<Anope::string> parameters;
-
- void Push() { }
-
+
public:
template<typename... Args>
IRCMessage(const MessageSource &_source, const Anope::string &_command, Args&&... args)
@@ -315,10 +362,10 @@ class IRCMessage
, command(_command)
{
parameters.reserve(sizeof...(args));
-
+
Push(std::forward<Args>(args)...);
}
-
+
template<typename T, typename... Args>
void Push(const T& t, Args&&... args)
{
@@ -326,7 +373,9 @@ class IRCMessage
Push(std::forward<Args>(args)...);
}
-
+
+ void Push() { }
+
void TokenizeAndPush(const Anope::string &buf, char sepToken = ' ')
{
sepstream sep(buf, sepToken);
@@ -334,7 +383,7 @@ class IRCMessage
while (sep.GetToken(token))
Push(token);
}
-
+
const MessageSource &GetSource() const
{
return source;
@@ -344,14 +393,28 @@ class IRCMessage
{
this->source = _source;
}
-
+
const Anope::string &GetCommand() const
{
return command;
}
-
+
const std::vector<Anope::string> &GetParameters() const
{
return parameters;
}
};
+
+template<typename... Args>
+void IRCDProto::SendNumeric(int numeric, User *dest, Args&&... args)
+{
+ Anope::string numstr = stringify(numeric);
+ if (numeric < 10)
+ numstr.insert(numstr.begin(), '0');
+ if (numeric < 100)
+ numstr.insert(numstr.begin(), '0');
+
+ IRCMessage message(Me, numstr, dest->nick);
+ message.Push(std::forward<Args>(args)...);
+ SendNumeric(numeric, dest, message);
+}
diff --git a/include/uplink.h b/include/uplink.h
index 0075b5d44..c999f4de1 100644
--- a/include/uplink.h
+++ b/include/uplink.h
@@ -37,7 +37,7 @@ namespace Uplink
template<typename... Args>
void Send(const Anope::string &command, Args&&... args)
{
- IRCMessage message(MessageSource(""), command, std::forward<Args>(args)...);
+ IRCMessage message(Me, command, std::forward<Args>(args)...);
SendMessage(message);
}
}
diff --git a/include/version.cpp b/include/version.cpp
index 7dc0b3402..b2340153b 100644
--- a/include/version.cpp
+++ b/include/version.cpp
@@ -85,26 +85,31 @@ static bool write_build_h(const std::string &buildh, const std::string &git_vers
{
std::fstream fd(buildh.c_str(), std::ios::in);
- std::string build = "#define BUILD 1";
+ std::string existing_version;
if (fd.is_open())
{
for (std::string filebuf; getline(fd, filebuf);)
{
- if (!filebuf.find("#define BUILD"))
+ if (!filebuf.find("#define VERSION_GIT"))
{
- size_t tab = filebuf.find(' ');
+ std::size_t q = filebuf.find('"');
+ if (q == std::string::npos)
+ break;
- int ibuild = atoi(filebuf.substr(tab + 1).c_str()) + 1;
+ std::size_t q2 = filebuf.find('"', q + 1);
+ if (q2 == std::string::npos)
+ break;
- std::stringstream ss;
- ss << "#define BUILD " << ibuild;
- build = ss.str();
+ existing_version = filebuf.substr(q + 1, q2 - q - 1);
}
}
fd.close();
}
+ if (existing_version == git_version)
+ return true;
+
fd.clear();
fd.open(buildh.c_str(), std::ios::out);
if (!fd.is_open())
@@ -114,7 +119,6 @@ static bool write_build_h(const std::string &buildh, const std::string &git_vers
}
fd << "/* This file is automatically generated by version.cpp - do not edit it! */" << std::endl;
- fd << build << std::endl;
if (!git_version.empty())
fd << "#define VERSION_GIT \"" << git_version << "\"" << std::endl;
fd.close();