diff options
author | Peter Powell <petpow@saberuk.com> | 2019-03-30 15:48:33 +0000 |
---|---|---|
committer | P. Powell <petpow@saberuk.com> | 2019-09-23 13:20:07 +0100 |
commit | e43bc49ba73840af183b70a1069c9b50ba72eb59 (patch) | |
tree | f07ce3349064eedaf45c9c259eeee8a908441452 /include/protocol.h | |
parent | d9de4ddd8295a4917b0b0b8260fc647b55ced683 (diff) |
Update the core message parser to allow parsing IRCv3 message tags.
Diffstat (limited to 'include/protocol.h')
-rw-r--r-- | include/protocol.h | 30 |
1 files changed, 29 insertions, 1 deletions
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<Anope::string> &); + virtual bool Parse(const Anope::string &, Anope::map<Anope::string> &, Anope::string &, Anope::string &, std::vector<Anope::string> &); 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<Anope::string> ¶ms) = 0; + virtual void Run(MessageSource &, const std::vector<Anope::string> ¶ms, const Anope::map<Anope::string> &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 \<middle> 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 \<trailing> 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 |