summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/account.h62
-rw-r--r--include/anope.h363
-rw-r--r--include/bots.h16
-rw-r--r--include/channels.h47
-rw-r--r--include/commands.h26
-rw-r--r--include/config.h296
-rw-r--r--include/extensible.h33
-rw-r--r--include/extern.h273
-rw-r--r--include/hashcomp.h121
-rw-r--r--include/mail.h20
-rw-r--r--include/modes.h68
-rw-r--r--include/modules.h126
-rw-r--r--include/operserv.h44
-rw-r--r--include/opertype.h18
-rw-r--r--include/regchannel.h46
-rw-r--r--include/servers.h30
-rw-r--r--include/services.h360
-rw-r--r--include/sockets.h34
-rw-r--r--include/users.h82
19 files changed, 1136 insertions, 929 deletions
diff --git a/include/account.h b/include/account.h
index 82ccb3871..11fcc6767 100644
--- a/include/account.h
+++ b/include/account.h
@@ -1,13 +1,15 @@
#ifndef ACCOUNT_H
#define ACCOUNT_H
+#include "anope.h"
+
class NickAlias;
class NickCore;
class NickRequest;
-typedef unordered_map_namespace::unordered_map<ci::string, NickAlias *, hash_compare_ci_string> nickalias_map;
-typedef unordered_map_namespace::unordered_map<ci::string, NickCore *, hash_compare_ci_string> nickcore_map;
-typedef unordered_map_namespace::unordered_map<ci::string, NickRequest *, hash_compare_ci_string> nickrequest_map;
+typedef unordered_map_namespace::unordered_map<Anope::string, NickAlias *, hash_compare_ci_string> nickalias_map;
+typedef unordered_map_namespace::unordered_map<Anope::string, NickCore *, hash_compare_ci_string> nickcore_map;
+typedef unordered_map_namespace::unordered_map<Anope::string, NickRequest *, hash_compare_ci_string> nickrequest_map;
extern CoreExport nickalias_map NickAliasList;
extern CoreExport nickcore_map NickCoreList;
@@ -86,14 +88,14 @@ enum NickCoreFlag
class CoreExport NickRequest : public Extensible
{
public:
- NickRequest(const std::string &nickname);
+ NickRequest(const Anope::string &nickname);
~NickRequest();
- char *nick;
- std::string passcode;
- std::string password;
- char *email;
+ Anope::string nick;
+ Anope::string passcode;
+ Anope::string password;
+ Anope::string email;
time_t requested;
time_t lastmail; /* Unsaved */
};
@@ -107,19 +109,19 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_EN
* @param nickname The nick
* @param nickcore The nickcofe for this nick
*/
- NickAlias(const std::string &nickname, NickCore *nickcore);
+ NickAlias(const Anope::string &nickname, NickCore *nickcore);
/** Default destructor
*/
~NickAlias();
- char *nick; /* Nickname */
- char *last_quit; /* Last quit message */
- char *last_realname; /* Last realname */
- char *last_usermask; /* Last usermask */
- time_t time_registered; /* When the nick was registered */
- time_t last_seen; /* When it was seen online for the last time */
- NickCore *nc; /* I'm an alias of this */
+ Anope::string nick; /* Nickname */
+ Anope::string last_quit; /* Last quit message */
+ Anope::string last_realname; /* Last realname */
+ Anope::string last_usermask; /* Last usermask */
+ time_t time_registered; /* When the nick was registered */
+ time_t last_seen; /* When it was seen online for the last time */
+ NickCore *nc; /* I'm an alias of this */
HostInfo hostinfo;
/** Release a nick
@@ -138,10 +140,10 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_EN
class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END>
{
public:
- /** Default constructor
+ /** Default constructor
* @param display The display nick
*/
- NickCore(const std::string &nickdisplay);
+ NickCore(const Anope::string &nickdisplay);
/** Default destructor
*/
@@ -149,12 +151,12 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
std::list<User *> Users;
- char *display; /* How the nick is displayed */
- std::string pass; /* Password of the nicks */
- char *email; /* E-mail associated to the nick */
- char *greet; /* Greet associated to the nick */
- uint16 language; /* Language selected by nickname owner (LANG_*) */
- std::vector<std::string> access; /* Access list, vector of strings */
+ Anope::string display; /* How the nick is displayed */
+ Anope::string pass; /* Password of the nicks */
+ Anope::string email; /* E-mail associated to the nick */
+ Anope::string greet; /* Greet associated to the nick */
+ uint16 language; /* Language selected by nickname owner (LANG_*) */
+ std::vector<Anope::string> access; /* Access list, vector of strings */
MemoInfo memos;
uint16 channelcount; /* Number of channels currently registered */
@@ -168,7 +170,7 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
* @param cmdstr The string to check, e.g. botserv/set/private.
* @return True if this opertype may run the specified command, false otherwise.
*/
- virtual bool HasCommand(const ci::string &cmdstr) const;
+ virtual bool HasCommand(const Anope::string &cmdstr) const;
/** Checks whether this account is a services oper or not.
* @return True if this account is a services oper, false otherwise.
@@ -179,7 +181,7 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
* @param privstr The priv to check for, e.g. users/auspex.
* @return True if this opertype has the specified priv, false otherwise.
*/
- virtual bool HasPriv(const ci::string &privstr) const;
+ virtual bool HasPriv(const Anope::string &privstr) const;
/** Add an entry to the nick's access list
*
@@ -187,7 +189,7 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
*
* Adds a new entry into the access list.
*/
- void AddAccess(const std::string &entry);
+ void AddAccess(const Anope::string &entry);
/** Get an entry from the nick's access list by index
*
@@ -196,7 +198,7 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
*
* Retrieves an entry from the access list corresponding to the given index.
*/
- std::string GetAccess(unsigned entry);
+ Anope::string GetAccess(unsigned entry);
/** Find an entry in the nick's access list
*
@@ -205,7 +207,7 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
*
* Search for an entry within the access list.
*/
- bool FindAccess(const std::string &entry);
+ bool FindAccess(const Anope::string &entry);
/** Erase an entry from the nick's access list
*
@@ -213,7 +215,7 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
*
* Removes the specified access list entry from the access list.
*/
- void EraseAccess(const std::string &entry);
+ void EraseAccess(const Anope::string &entry);
/** Clears the entire nick's access list
*
diff --git a/include/anope.h b/include/anope.h
new file mode 100644
index 000000000..e73f04157
--- /dev/null
+++ b/include/anope.h
@@ -0,0 +1,363 @@
+/*
+ * (C) 2003-2010 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for furhter details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
+#ifndef ANOPE_H
+#define ANOPE_H
+
+#include <string>
+#include <vector>
+#include "hashcomp.h"
+
+struct Message;
+
+namespace Anope
+{
+ /**
+ * A wrapper string class around all the other string classes, this class will
+ * allow us to only require one type of string everywhere that can be converted
+ * at any time to a specific type of string.
+ */
+ class string
+ {
+ private:
+ /**
+ * The actual string is stored in an std::string as it can be converted to
+ * ci::string, irc::string, or a C-style string at any time.
+ */
+ std::string _string;
+ public:
+ /**
+ * Extras.
+ */
+ typedef std::string::iterator iterator;
+ typedef std::string::const_iterator const_iterator;
+ typedef std::string::reverse_iterator reverse_iterator;
+ typedef std::string::const_reverse_iterator const_reverse_iterator;
+ typedef std::string::size_type size_type;
+ static const size_type npos = static_cast<size_type>(-1);
+
+ /**
+ * Constructors that can take in any type of string.
+ */
+ string() : _string("") { }
+ string(char chr) : _string() { _string = chr; }
+ string(size_type n, char chr) : _string(n, chr) { }
+ string(const char *_str) : _string(_str) { }
+ string(const std::string &_str) : _string(_str) { }
+ string(const ci::string &_str) : _string(_str.c_str()) { }
+ string(const irc::string &_str) : _string(_str.c_str()) { }
+ string(const string &_str, size_type pos = 0, size_type n = npos) : _string(_str._string, pos, n) { }
+ template <class InputIterator> string(InputIterator first, InputIterator last) : _string(first, last) { }
+
+ /**
+ * Assignment operators, so any type of string can be assigned to this class.
+ */
+ inline string &operator=(char chr) { this->_string = chr; return *this; }
+ inline string &operator=(const char *_str) { this->_string = _str; return *this; }
+ inline string &operator=(const std::string &_str) { this->_string = _str; return *this; }
+ inline string &operator=(const ci::string &_str) { this->_string = _str.c_str(); return *this; }
+ inline string &operator=(const irc::string &_str) { this->_string = _str.c_str(); return *this; }
+ inline string &operator=(const string &_str) { if (this != &_str) this->_string = _str._string; return *this; }
+
+ /**
+ * Equality operators, to compare to any type of string.
+ */
+ inline bool operator==(const char *_str) const { return this->_string == _str; }
+ inline bool operator==(const std::string &_str) const { return this->_string == _str; }
+ inline bool operator==(const ci::string &_str) const { return ci::string(this->_string.c_str()) == _str; }
+ inline bool operator==(const irc::string &_str) const { return irc::string(this->_string.c_str()) == _str; }
+ inline bool operator==(const string &_str) const { return this->_string == _str._string; }
+
+ inline bool equals_cs(const char *_str) const { return this->_string == _str; }
+ inline bool equals_cs(const std::string &_str) const { return this->_string == _str; }
+ inline bool equals_cs(const ci::string &_str) const { return this->_string == _str.c_str(); }
+ inline bool equals_cs(const irc::string &_str) const { return this->_string == _str.c_str(); }
+ inline bool equals_cs(const string &_str) const { return this->_string == _str._string; }
+
+ inline bool equals_ci(const char *_str) const { return ci::string(this->_string.c_str()) == _str; }
+ inline bool equals_ci(const std::string &_str) const { return ci::string(this->_string.c_str()) == _str.c_str(); }
+ inline bool equals_ci(const ci::string &_str) const { return _str == this->_string.c_str(); }
+ inline bool equals_ci(const irc::string &_str) const { return ci::string(this->_string.c_str()) == _str.c_str(); }
+ inline bool equals_ci(const string &_str) const { return ci::string(this->_string.c_str()) == _str._string.c_str(); }
+
+ inline bool equals_irc(const char *_str) const { return irc::string(this->_string.c_str()) == _str; }
+ inline bool equals_irc(const std::string &_str) const { return irc::string(this->_string.c_str()) == _str.c_str(); }
+ inline bool equals_irc(const ci::string &_str) const { return irc::string(this->_string.c_str()) == _str.c_str(); }
+ inline bool equals_irc(const irc::string &_str) const { return _str == this->_string.c_str(); }
+ inline bool equals_irc(const string &_str) const { return irc::string(this->_string.c_str()) == _str._string.c_str(); }
+
+ /**
+ * Inequality operators, exact opposites of the above.
+ */
+ inline bool operator!=(const char *_str) const { return !operator==(_str); }
+ inline bool operator!=(const std::string &_str) const { return !operator==(_str); }
+ inline bool operator!=(const ci::string &_str) const { return !operator==(_str); }
+ inline bool operator!=(const irc::string &_str) const { return !operator==(_str); }
+ inline bool operator!=(const string &_str) const { return !operator==(_str); }
+
+ /**
+ * Compound addition operators, overloaded to do concatenation.
+ */
+ inline string &operator+=(char chr) { this->_string += chr; return *this; }
+ inline string &operator+=(const char *_str) { this->_string += _str; return *this; }
+ inline string &operator+=(const std::string &_str) { this->_string += _str; return *this; }
+ inline string &operator+=(const ci::string &_str) { this->_string += _str.c_str(); return *this; }
+ inline string &operator+=(const irc::string &_str) { this->_string += _str.c_str(); return *this; }
+ inline string &operator+=(const string &_str) { if (this != &_str) this->_string += _str._string; return *this; }
+
+ /**
+ * Addition operators, overloaded to do concatenation.
+ */
+ inline const string operator+(char chr) const { return string(*this) += chr; }
+ inline const string operator+(const char *_str) const { return string(*this) += _str; }
+ inline const string operator+(const std::string &_str) const { return string(*this) += _str; }
+ inline const string operator+(const ci::string &_str) const { return string(*this) += _str; }
+ inline const string operator+(const irc::string &_str) const { return string(*this) += _str; }
+ inline const string operator+(const string &_str) const { return string(*this) += _str; }
+
+ friend const string operator+(char chr, const string &str);
+ friend const string operator+(const char *_str, const string &str);
+ friend const string operator+(const std::string &_str, const string &str);
+ friend const string operator+(const ci::string &_str, const string &str);
+ friend const string operator+(const irc::string &_str, const string &str);
+
+ /**
+ * Less-than operator.
+ */
+ inline bool operator<(const string &_str) const { return this->_string < _str._string; }
+
+ /**
+ * The following functions return the various types of strings.
+ */
+ inline const char *c_str() const { return this->_string.c_str(); }
+ inline std::string &str() { return this->_string; }
+ inline const std::string &str() const { return this->_string; }
+ inline ci::string ci_str() const { return ci::string(this->_string.c_str()); }
+ inline irc::string irc_str() const { return irc::string(this->_string.c_str()); }
+
+ /**
+ * Returns if the string is empty or not.
+ */
+ inline bool empty() const { return this->_string.empty(); }
+
+ /**
+ * Returns the string's length.
+ */
+ inline size_type length() const { return this->_string.length(); }
+
+ /**
+ * Erases characters from the string.
+ */
+ inline iterator erase(const iterator &i) { return this->_string.erase(i); }
+ inline iterator erase(const iterator &first, const iterator &last) { return this->_string.erase(first, last); }
+ inline void erase(size_type pos = 0, size_type n = std::string::npos) { this->_string.erase(pos, n); }
+
+ /**
+ * Clears the string.
+ */
+ inline void clear() { this->_string.clear(); }
+
+ /**
+ * Find substrings of the string.
+ */
+ inline size_type find(const string &_str, size_type pos = 0) const { return this->_string.find(_str._string, pos); }
+ inline size_type find(char chr, size_type pos = 0) const { return this->_string.find(chr, pos); }
+ inline size_type find_ci(const string &_str, size_type pos = 0) const { return ci::string(this->_string.c_str()).find(ci::string(_str._string.c_str()), pos); }
+ inline size_type find_ci(char chr, size_type pos = 0) const { return ci::string(this->_string.c_str()).find(chr, pos); }
+
+ inline size_type rfind(const string &_str, size_type pos = npos) const { return this->_string.rfind(_str._string, pos); }
+ inline size_type rfind(char chr, size_type pos = npos) const { return this->_string.rfind(chr, pos); }
+ inline size_type rfind_ci(const string &_str, size_type pos = npos) const { return ci::string(this->_string.c_str()).rfind(ci::string(_str._string.c_str()), pos); }
+ inline size_type rfind_ci(char chr, size_type pos = npos) const { return ci::string(this->_string.c_str()).rfind(chr, pos); }
+
+ inline size_type find_first_of(const string &_str, size_type pos = 0) const { return this->_string.find_first_of(_str._string, pos); }
+ inline size_type find_first_of_ci(const string &_str, size_type pos = 0) const { return ci::string(this->_string.c_str()).find_first_of(ci::string(_str._string.c_str()), pos); }
+
+ inline size_type find_first_not_of(const string &_str, size_type pos = 0) const { return this->_string.find_first_not_of(_str._string, pos); }
+ inline size_type find_first_not_of_ci(const string &_str, size_type pos = 0) const { return ci::string(this->_string.c_str()).find_first_not_of(ci::string(_str._string.c_str()), pos); }
+
+ inline size_type find_last_of(const string &_str, size_type pos = npos) const { return this->_string.find_last_of(_str._string, pos); }
+ inline size_type find_last_of_ci(const string &_str, size_type pos = npos) const { return ci::string(this->_string.c_str()).find_last_of(ci::string(_str._string.c_str()), pos); }
+
+ inline size_type find_last_not_of(const string &_str, size_type pos = npos) const { return this->_string.find_last_not_of(_str._string, pos); }
+ inline size_type find_last_not_of_ci(const string &_str, size_type pos = npos) const { return ci::string(this->_string.c_str()).find_last_not_of(ci::string(_str._string.c_str()), pos); }
+
+ /**
+ * Determine if string consists of only numbers.
+ */
+ inline bool is_number_only() const { return this->find_first_not_of("0123456789.-") == npos; }
+
+ /**
+ * Replace parts of the string.
+ */
+ inline string replace(size_type pos, size_type n, const string &_str) { return string(this->_string.replace(pos, n, _str._string)); }
+ inline string replace(size_type pos, size_type n, const string &_str, size_type pos1, size_type n1) { return string(this->_string.replace(pos, n, _str._string, pos1, n1)); }
+ inline string replace(size_type pos, size_type n, size_type n1, char chr) { return string(this->_string.replace(pos, n, n1, chr)); }
+ inline string replace(iterator first, iterator last, const string &_str) { return string(this->_string.replace(first, last, _str._string)); }
+ inline string replace(iterator first, iterator last, size_type n, char chr) { return string(this->_string.replace(first, last, n, chr)); }
+ template <class InputIterator> inline string replace(iterator first, iterator last, InputIterator f, InputIterator l) { return string(this->_string.replace(first, last, f, l)); }
+ inline string replace_all_cs(const string &_orig, const string &_repl)
+ {
+ Anope::string new_string = *this;
+ size_type pos = new_string.find(_orig), orig_length = _orig.length();
+ while (pos != npos)
+ {
+ new_string.replace(pos, pos + orig_length, _repl);
+ pos = new_string.find(_orig, pos + orig_length);
+ }
+ return new_string;
+ }
+ inline string replace_all_ci(const string &_orig, const string &_repl)
+ {
+ Anope::string new_string = *this;
+ size_type pos = new_string.find_ci(_orig), orig_length = _orig.length();
+ while (pos != npos)
+ {
+ new_string.replace(pos, pos + orig_length, _repl);
+ pos = new_string.find_ci(_orig, pos + orig_length);
+ }
+ return new_string;
+ }
+
+ /**
+ * Get a substring of the string.
+ */
+ inline string substr(size_type pos = 0, size_type n = npos) const { return string(this->_string.substr(pos, n)); }
+
+ /**
+ * Iterators to the string.
+ */
+ inline iterator begin() { return this->_string.begin(); }
+ inline const_iterator begin() const { return this->_string.begin(); }
+ inline iterator end() { return this->_string.end(); }
+ inline const_iterator end() const { return this->_string.end(); }
+ inline reverse_iterator rbegin() { return this->_string.rbegin(); }
+ inline const_reverse_iterator rbegin() const { return this->_string.rbegin(); }
+ inline reverse_iterator rend() { return this->_string.rend(); }
+ inline const_reverse_iterator rend() const { return this->_string.rend(); }
+
+ /**
+ * Subscript operator, to access individual characters of the string.
+ */
+ inline char &operator[](size_type n) { return this->_string[n]; }
+ inline const char &operator[](size_type n) const { return this->_string[n]; }
+
+ /**
+ * Stream insertion operator, must be friend because they cannot be inside the class.
+ */
+ friend std::ostream &operator<<(std::ostream &os, const string &_str);
+ };
+
+ inline std::ostream &operator<<(std::ostream &os, const string &_str) { return os << _str._string; }
+
+ inline const string operator+(char chr, const string &str) { string tmp(chr); tmp += str; return tmp; }
+ inline const string operator+(const char *_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
+ inline const string operator+(const std::string &_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
+ inline const string operator+(const ci::string &_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
+ inline const string operator+(const irc::string &_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
+
+ static const char *const compiled = __TIME__ " " __DATE__;
+
+ extern string Version();
+
+ extern string Build();
+
+ /** Check whether two strings match.
+ * @param str The string to check against the pattern (e.g. foobar)
+ * @param mask The pattern to check (e.g. foo*bar)
+ * @param case_sensitive Whether or not the match is case sensitive, default false.
+ */
+ extern bool Match(const Anope::string &str, const Anope::string &mask, bool case_sensitive = false);
+
+ /** Add a message to Anope
+ * @param name The message name as sent by the IRCd
+ * @param func A callback function that will be called when this message is received
+ * @return The new message object
+ */
+ extern Message *AddMessage(const string &name, int (*func)(const string &source, int ac, const char **av));
+
+ /** Deletes a message from Anope
+ * XXX Im not sure what will happen if this function is called indirectly from message function pointed to by this message.. must check
+ * @param m The message
+ * @return true if the message was found and deleted, else false
+ */
+ extern bool DelMessage(Message *m);
+
+ /** Returns a list of pointers to message handlers
+ * @param The message name as sent by the IRCd
+ * @return a vector with pointers to the messagehandlers (you can bind more than one handler to a message)
+ */
+ extern std::vector<Message *> FindMessage(const string &name);
+}
+
+/** sepstream allows for splitting token seperated lists.
+ * Each successive call to sepstream::GetToken() returns
+ * the next token, until none remain, at which point the method returns
+ * an empty string.
+ */
+class CoreExport sepstream
+{
+ private:
+ /** Original string.
+ */
+ Anope::string tokens;
+ /** Last position of a seperator token
+ */
+ Anope::string::iterator last_starting_position;
+ /** Current string position
+ */
+ Anope::string::iterator n;
+ /** Seperator value
+ */
+ char sep;
+ public:
+ /** Create a sepstream and fill it with the provided data
+ */
+ sepstream(const Anope::string &source, char seperator);
+ virtual ~sepstream() { }
+
+ /** Fetch the next token from the stream
+ * @param token The next token from the stream is placed here
+ * @return True if tokens still remain, false if there are none left
+ */
+ virtual bool GetToken(Anope::string &token);
+
+ /** Fetch the entire remaining stream, without tokenizing
+ * @return The remaining part of the stream
+ */
+ virtual const Anope::string GetRemaining();
+
+ /** Returns true if the end of the stream has been reached
+ * @return True if the end of the stream has been reached, otherwise false
+ */
+ virtual bool StreamEnd();
+};
+
+/** A derived form of sepstream, which seperates on commas
+ */
+class commasepstream : public sepstream
+{
+ public:
+ /** Initialize with comma seperator
+ */
+ commasepstream(const Anope::string &source) : sepstream(source, ',') { }
+};
+
+/** A derived form of sepstream, which seperates on spaces
+ */
+class spacesepstream : public sepstream
+{
+ public:
+ /** Initialize with space seperator
+ */
+ spacesepstream(const Anope::string &source) : sepstream(source, ' ') { }
+};
+
+#endif // ANOPE_H
diff --git a/include/bots.h b/include/bots.h
index cd95467b5..3d35f569e 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -12,8 +12,8 @@
class BotInfo;
-typedef unordered_map_namespace::unordered_map<ci::string, BotInfo *, hash_compare_ci_string> botinfo_map;
-typedef unordered_map_namespace::unordered_map<std::string, BotInfo *, hash_compare_std_string> botinfo_uid_map;
+typedef unordered_map_namespace::unordered_map<Anope::string, BotInfo *, hash_compare_ci_string> botinfo_map;
+typedef unordered_map_namespace::unordered_map<Anope::string, BotInfo *, hash_compare_std_string> botinfo_uid_map;
extern CoreExport botinfo_map BotListByNick;
extern CoreExport botinfo_uid_map BotListByUID;
@@ -32,8 +32,8 @@ enum BotFlag
class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>
{
public:
- time_t created; /* Birth date ;) */
- time_t lastmsg; /* Last time we said something */
+ time_t created; /* Birth date ;) */
+ time_t lastmsg; /* Last time we said something */
CommandMap Commands; /* Commands on this bot */
/** Create a new bot.
@@ -42,7 +42,7 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>
* @param host The hostname to give the bot.
* @param real The realname to give the bot.
*/
- BotInfo(const std::string &nick, const std::string &user = "", const std::string &host = "", const std::string &real = "");
+ BotInfo(const Anope::string &nick, const Anope::string &user = "", const Anope::string &host = "", const Anope::string &real = "");
/** Destroy a bot, clearing up appropriately.
*/
@@ -51,7 +51,7 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>
/** Change the nickname for the bot.
* @param newnick The nick to change to
*/
- void SetNewNick(const std::string &newnick);
+ void SetNewNick(const Anope::string &newnick);
/** Rejoins all channels that this bot is assigned to.
* Used on /kill, rename, etc.
@@ -71,8 +71,8 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>
void UnAssign(User *u, ChannelInfo *ci);
void Join(Channel *c);
- void Join(const std::string &chname);
- void Part(Channel *c, const std::string &reason = "");
+ void Join(const Anope::string &chname);
+ void Part(Channel *c, const Anope::string &reason = "");
};
#endif // BOTS_H
diff --git a/include/channels.h b/include/channels.h
index 7cdc32de3..8bf98e4b9 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -9,20 +9,25 @@
#ifndef CHANNELS_H
#define CHANNELS_H
-typedef unordered_map_namespace::unordered_map<ci::string, Channel *, hash_compare_ci_string> channel_map;
+typedef unordered_map_namespace::unordered_map<Anope::string, Channel *, hash_compare_ci_string> channel_map;
extern CoreExport channel_map ChannelList;
struct UserData
{
UserData()
{
- lastline = NULL;
+ Clear();
+ }
+
+ virtual ~UserData() { }
+
+ void Clear()
+ {
last_use = last_start = time(NULL);
lines = times = 0;
+ lastline.clear();
}
- virtual ~UserData() { delete [] lastline; }
-
/* Data validity */
time_t last_use;
@@ -31,7 +36,7 @@ struct UserData
time_t last_start;
/* for repeat kicker */
- char *lastline;
+ Anope::string lastline;
int16 times;
};
@@ -60,7 +65,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
private:
/** A map of channel modes with their parameters set on this channel
*/
- std::map<ChannelModeName, std::string> Params;
+ std::map<ChannelModeName, Anope::string> Params;
/* Modes set on the channel */
Flags<ChannelModeName, CMODE_END> modes;
@@ -70,17 +75,17 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
* @param name The channel name
* @param ts The time the channel was created
*/
- Channel(const std::string &name, time_t ts = time(NULL));
+ Channel(const Anope::string &name, time_t ts = time(NULL));
/** Default destructor
*/
~Channel();
- std::string name; /* Channel name */
+ Anope::string name; /* Channel name */
ChannelInfo *ci; /* Corresponding ChannelInfo */
time_t creation_time; /* When channel was created */
- char *topic;
- std::string topic_setter;
+ Anope::string topic;
+ Anope::string topic_setter;
time_t topic_time; /* When topic was set */
EList *bans;
@@ -137,7 +142,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
/** See if the channel has any modes at all
* @return true or false
*/
- inline const bool HasModes() const { return modes.FlagCount(); }
+ inline bool HasModes() const { return modes.FlagCount(); }
/** See if a channel has a mode
* @param Name The mode name
@@ -150,14 +155,14 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
* @param param The param
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
*/
- void SetModeInternal(ChannelMode *cm, const std::string &param = "", bool EnforceMLock = true);
+ void SetModeInternal(ChannelMode *cm, const Anope::string &param = "", bool EnforceMLock = true);
/** Remove a mode internally on a channel, this is not sent out to the IRCd
* @param cm The mode
* @param param The param
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
*/
- void RemoveModeInternal(ChannelMode *cm, const std::string &param = "", bool EnforceMLock = true);
+ void RemoveModeInternal(ChannelMode *cm, const Anope::string &param = "", bool EnforceMLock = true);
/** Set a mode on a channel
* @param bi The client setting the modes
@@ -165,7 +170,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
* @param param Optional param arg for the mode
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
*/
- void SetMode(BotInfo *bi, ChannelMode *cm, const std::string &param = "", bool EnforceMLock = true);
+ void SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param = "", bool EnforceMLock = true);
/**
* Set a mode on a channel
@@ -174,7 +179,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
* @param param Optional param arg for the mode
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
*/
- void SetMode(BotInfo *bi, ChannelModeName Name, const std::string &param = "", bool EnforceMLock = true);
+ void SetMode(BotInfo *bi, ChannelModeName Name, const Anope::string &param = "", bool EnforceMLock = true);
/**
* Set a mode on a channel
@@ -183,7 +188,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
* @param param Optional param arg for the mode
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
*/
- void SetMode(BotInfo *bi, char Mode, const std::string &param = "", bool EnforceMLock = true);
+ void SetMode(BotInfo *bi, char Mode, const Anope::string &param = "", bool EnforceMLock = true);
/** Remove a mode from a channel
* @param bi The client setting the modes
@@ -191,7 +196,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
* @param param Optional param arg for the mode
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
*/
- void RemoveMode(BotInfo *bi, ChannelMode *cm, const std::string &param = "", bool EnforceMLock = true);
+ void RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param = "", bool EnforceMLock = true);
/**
* Remove a mode from a channel
@@ -200,7 +205,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
* @param param Optional param arg for the mode
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
*/
- void RemoveMode(BotInfo *bi, ChannelModeName Name, const std::string &param = "", bool EnforceMLock = true);
+ void RemoveMode(BotInfo *bi, ChannelModeName Name, const Anope::string &param = "", bool EnforceMLock = true);
/**
* Remove a mode from a channel
* @param bi The client setting the modes
@@ -208,7 +213,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
* @param param Optional param arg for the mode
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
*/
- void RemoveMode(BotInfo *bi, char Mode, const std::string &param = "", bool EnforceMLock = true);
+ void RemoveMode(BotInfo *bi, char Mode, const Anope::string &param = "", bool EnforceMLock = true);
/** Clear all the modes from the channel
* @param bi The client unsetting the modes
@@ -235,7 +240,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
* @param Target a string to put the param into
* @return true on success
*/
- const bool GetParam(ChannelModeName Name, std::string &Target);
+ const bool GetParam(ChannelModeName Name, Anope::string &Target);
/** Check if a mode is set and has a param
* @param Name The mode
@@ -253,7 +258,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E
* @param nick The nick being kicked
* @param reason The reason for the kick
*/
- void KickInternal(const std::string &source, const std::string &nick, const std::string &reason);
+ void KickInternal(const Anope::string &source, const Anope::string &nick, const Anope::string &reason);
/** Kick a user from the channel
* @param bi The sender, can be NULL for the service bot for this channel
diff --git a/include/commands.h b/include/commands.h
index cfe2eddab..71fee7e42 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -18,7 +18,7 @@ class Module;
class BotInfo;
class Command;
-typedef std::map<ci::string, Command *> CommandMap;
+typedef std::map<Anope::string, Command *, hash_compare_ci_string> CommandMap;
/** The return value from commands.
*/
@@ -28,10 +28,10 @@ enum CommandReturn
MOD_STOP
};
-extern CoreExport Command *FindCommand(BotInfo *bi, const ci::string &cmd);
-extern CoreExport void mod_help_cmd(BotInfo *bi, User *u, const ci::string &cmd);
-extern CoreExport void mod_run_cmd(BotInfo *bi, User *u, const std::string &message);
-extern CoreExport void mod_run_cmd(BotInfo *bi, User *u, Command *c, const ci::string &command, const ci::string &message);
+extern CoreExport Command *FindCommand(BotInfo *bi, const Anope::string &cmd);
+extern CoreExport void mod_help_cmd(BotInfo *bi, User *u, const Anope::string &cmd);
+extern CoreExport void m