From e43bc49ba73840af183b70a1069c9b50ba72eb59 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sat, 30 Mar 2019 15:48:33 +0000 Subject: Update the core message parser to allow parsing IRCv3 message tags. --- include/protocol.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/protocol.h b/include/protocol.h index 1e3653c85..1f3b8c026 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -39,7 +39,7 @@ class CoreExport IRCDProto : public Service 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 &); + virtual bool Parse(const Anope::string &, Anope::map &, Anope::string &, Anope::string &, std::vector &); virtual Anope::string Format(const Anope::string &source, const Anope::string &message); /* Modes used by default by our clients */ @@ -278,11 +278,39 @@ class CoreExport IRCDMessage : public Service IRCDMessage(Module *owner, const Anope::string &n, unsigned p = 0); unsigned GetParamCount() const; virtual void Run(MessageSource &, const std::vector ¶ms) = 0; + virtual void Run(MessageSource &, const std::vector ¶ms, const Anope::map &tags); void SetFlag(IRCDMessageFlag f) { flags.insert(f); } bool HasFlag(IRCDMessageFlag f) const { return flags.count(f); } }; +/** MessageTokenizer allows tokens in the IRC wire format to be read from a string */ +class CoreExport MessageTokenizer +{ +private: + /** The message we are parsing tokens from. */ + Anope::string message; + + /** The current position within the message. */ + Anope::string::size_type position; + + public: + /** Create a tokenstream and fill it with the provided data. */ + MessageTokenizer(const Anope::string &msg); + + /** Retrieve the next \ token in the message. + * @param token The next token available, or an empty string if none remain. + * @return True if a token was retrieved; otherwise, false. + */ + bool GetMiddle(Anope::string &token); + + /** Retrieve the next \ token in the message. + * @param token The next token available, or an empty string if none remain. + * @return True if a token was retrieved; otherwise, false. + */ + bool GetTrailing(Anope::string &token); +}; + extern CoreExport IRCDProto *IRCD; #endif // PROTOCOL_H -- cgit