diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/access.h | 2 | ||||
| -rw-r--r-- | include/anope.h | 17 | ||||
| -rw-r--r-- | include/channels.h | 19 | ||||
| -rw-r--r-- | include/hashcomp.h | 4 | ||||
| -rw-r--r-- | include/logger.h | 27 | ||||
| -rw-r--r-- | include/modes.h | 29 | ||||
| -rw-r--r-- | include/protocol.h | 2 | ||||
| -rw-r--r-- | include/servers.h | 8 | ||||
| -rw-r--r-- | include/users.h | 4 |
9 files changed, 70 insertions, 42 deletions
diff --git a/include/access.h b/include/access.h index ea2667774..f60625ad9 100644 --- a/include/access.h +++ b/include/access.h @@ -79,6 +79,8 @@ class CoreExport ChanAccess : public Serializable AccessProvider *provider; /* Channel this access entry is on */ Serialize::Reference<ChannelInfo> ci; + /* account this access entry is for, if any */ + Serialize::Reference<NickCore> nc; Anope::string mask; Anope::string creator; time_t last_seen; diff --git a/include/anope.h b/include/anope.h index 9bf0f982d..8e24d12da 100644 --- a/include/anope.h +++ b/include/anope.h @@ -255,7 +255,7 @@ namespace Anope { Anope::string new_string = *this; for (size_type i = 0; i < new_string.length(); ++i) - new_string[i] = std::tolower(new_string[i], Anope::casemap); + new_string[i] = Anope::tolower(new_string[i]); return new_string; } @@ -266,7 +266,7 @@ namespace Anope { Anope::string new_string = *this; for (size_type i = 0; i < new_string.length(); ++i) - new_string[i] = std::toupper(new_string[i], Anope::casemap); + new_string[i] = Anope::toupper(new_string[i]); return new_string; } @@ -547,15 +547,12 @@ class CoreExport sepstream /** 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; + /** Current string position + */ + size_t pos; public: /** Create a sepstream and fill it with the provided data */ @@ -570,7 +567,7 @@ class CoreExport sepstream /** Gets token number 'num' from the stream * @param token The token is placed here * @param num The token number to featch - * @return True if the token was able to be detched + * @return True if the token was able to be fetched */ bool GetToken(Anope::string &token, int num); @@ -588,7 +585,7 @@ class CoreExport sepstream /** Gets token number 'num' from the stream and all remaining tokens. * @param token The token is placed here * @param num The token number to featch - * @return True if the token was able to be detched + * @return True if the token was able to be fetched */ bool GetTokenRemainder(Anope::string &token, int num); diff --git a/include/channels.h b/include/channels.h index 18ef65a7c..118864c8a 100644 --- a/include/channels.h +++ b/include/channels.h @@ -54,7 +54,7 @@ class CoreExport Channel : public Base, public Extensible time_t creation_time; /* Users in the channel */ - typedef std::list<ChanUserContainer *> ChanUserList; + typedef std::map<User *, ChanUserContainer *> ChanUserList; ChanUserList users; /* Current topic of the channel */ @@ -75,12 +75,14 @@ class CoreExport Channel : public Base, public Extensible int16_t chanserv_modecount; /* Number of check_mode()'s this sec */ int16_t bouncy_modes; /* Did we fail to set modes here? */ + private: /** Constructor * @param name The channel name * @param ts The time the channel was created */ Channel(const Anope::string &nname, time_t ts = Anope::CurTime); + public: /** Destructor */ ~Channel(); @@ -113,14 +115,14 @@ class CoreExport Channel : public Base, public Extensible * @param u The user * @return A user container if found, else NULL */ - ChanUserContainer *FindUser(const User *u) const; + ChanUserContainer *FindUser(User *u) const; /** Check if a user has a status on a channel * @param u The user * @param cms The status mode, or NULL to represent no status * @return true or false */ - bool HasUserStatus(const User *u, ChannelModeStatus *cms) const; + bool HasUserStatus(User *u, ChannelModeStatus *cms); /** Check if a user has a status on a channel * Use the overloaded function for ChannelModeStatus* to check for no status @@ -128,7 +130,7 @@ class CoreExport Channel : public Base, public Extensible * @param name The mode name, eg CMODE_OP, CMODE_VOICE * @return true or false */ - bool HasUserStatus(const User *u, const Anope::string &name) const; + bool HasUserStatus(User *u, const Anope::string &name); /** See if a channel has a mode * @param name The mode name @@ -279,13 +281,20 @@ class CoreExport Channel : public Base, public Extensible * @param full Whether or not to match using the user's real host and IP * @return whether or not a ban was removed */ - bool Unban(const User *u, bool full = false); + bool Unban(User *u, bool full = false); /** Finds a channel * @param name The channel to find * @return The channel, if found */ static Channel* Find(const Anope::string &name); + + /** Finds or creates a channel + * @param name The channel name + * @param created Set to true if the channel was just created + * @param ts The time the channel was created + */ + static Channel *FindOrCreate(const Anope::string &name, bool &created, time_t ts = Anope::CurTime); }; #endif // CHANNELS_H diff --git a/include/hashcomp.h b/include/hashcomp.h index 9ebc7ae81..38c0e3833 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -28,6 +28,10 @@ namespace Anope /* Casemap in use by Anope. ci::string's comparation functions use this (and thus Anope::string) */ extern std::locale casemap; + extern void CaseMapRebuild(); + extern unsigned char tolower(unsigned char); + extern unsigned char toupper(unsigned char); + /* ASCII case insensitive ctype. */ template<typename char_type> class ascii_ctype : public std::ctype<char_type> diff --git a/include/logger.h b/include/logger.h index 5050c22ce..afa874ca3 100644 --- a/include/logger.h +++ b/include/logger.h @@ -45,7 +45,8 @@ struct LogFile std::ofstream stream; LogFile(const Anope::string &name); - Anope::string GetName() const; + ~LogFile(); + const Anope::string &GetName() const; }; /* Represents a single log message */ @@ -72,7 +73,6 @@ class CoreExport Log Module *m; LogType type; Anope::string category; - std::list<Anope::string> sources; std::stringstream buf; @@ -109,17 +109,18 @@ class CoreExport Log class CoreExport LogInfo { public: - std::list<Anope::string> targets; - std::map<Anope::string, LogFile *> logfiles; - std::list<Anope::string> sources; + std::vector<Anope::string> targets; + std::vector<LogFile *> logfiles; + int last_day; + std::vector<Anope::string> sources; int log_age; - std::list<Anope::string> admin; - std::list<Anope::string> override; - std::list<Anope::string> commands; - std::list<Anope::string> servers; - std::list<Anope::string> users; - std::list<Anope::string> channels; - std::list<Anope::string> normal; + std::vector<Anope::string> admin; + std::vector<Anope::string> override; + std::vector<Anope::string> commands; + std::vector<Anope::string> servers; + std::vector<Anope::string> users; + std::vector<Anope::string> channels; + std::vector<Anope::string> normal; bool raw_io; bool debug; @@ -127,7 +128,7 @@ class CoreExport LogInfo ~LogInfo(); - void AddType(std::list<Anope::string> &list, const Anope::string &type); + void OpenLogFiles(); bool HasType(LogType ltype, const Anope::string &type) const; diff --git a/include/modes.h b/include/modes.h index bb329b5b4..6a39393bb 100644 --- a/include/modes.h +++ b/include/modes.h @@ -134,7 +134,7 @@ class CoreExport ChannelModeList : public ChannelMode * @param e The entry to match against * @return true on match */ - virtual bool Matches(const User *u, const Entry *e) { return false; } + virtual bool Matches(User *u, const Entry *e) { return false; } /** Called when a mask is added to a channel * @param chan The channel @@ -181,7 +181,7 @@ class CoreExport ChannelModeStatus : public ChannelMode { public: /* The symbol, eg @ % + */ - char Symbol; + char symbol; /* The "level" of the mode, used to compare with other modes. * Used so we know op > halfop > voice etc. */ @@ -190,10 +190,10 @@ class CoreExport ChannelModeStatus : public ChannelMode /** constructor * @param name The mode name * @param mc The mode char - * @param mSymbol The symbol for the mode, eg @ % + * @param msymbol The symbol for the mode, eg @ % * @param mlevel A level for the mode, which is usually determined by the PREFIX capab */ - ChannelModeStatus(const Anope::string &name, char mc, char mSymbol, short mlevel = 0); + ChannelModeStatus(const Anope::string &name, char mc, char msymbol, short mlevel = 0); /** destructor */ @@ -203,9 +203,14 @@ class CoreExport ChannelModeStatus : public ChannelMode /* The status a user has on a channel (+v, +h, +o) etc */ class CoreExport ChannelStatus { + Anope::string modes; public: - std::set<Anope::string> modes; - Anope::string BuildCharPrefixList() const; + void AddMode(char c); + void DelMode(char c); + bool HasMode(char c) const; + bool Empty() const; + void Clear(); + const Anope::string &Modes() const; Anope::string BuildModePrefixList() const; }; @@ -292,11 +297,14 @@ class CoreExport ModeManager */ static std::list<Anope::string> BuildModeStrings(StackerInfo *info); - public: - /* List of all modes Anope knows about */ + /* Array of all modes Anope knows about. Modes are in this array at position + * modechar. Additionally, status modes are in this array (again) at statuschar. + */ static std::vector<ChannelMode *> ChannelModes; static std::vector<UserMode *> UserModes; + public: + /* Number of generic channel and user modes we are tracking */ static unsigned GenericChannelModes; static unsigned GenericUserModes; @@ -358,6 +366,9 @@ class CoreExport ModeManager */ static char GetStatusChar(char symbol); + static const std::vector<ChannelMode *> &GetChannelModes(); + static const std::vector<UserMode *> &GetUserModes(); + /** Add a mode to the stacker to be set on a channel * @param bi The client to set the modes from * @param c The channel @@ -419,7 +430,7 @@ class CoreExport Entry * @param full True to match against a users real host and IP * @return true on match */ - bool Matches(const User *u, bool full = false) const; + bool Matches(User *u, bool full = false) const; }; #endif // MODES_H diff --git a/include/protocol.h b/include/protocol.h index 8953d25e5..23bed3003 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -148,7 +148,7 @@ class CoreExport IRCDProto : public Service * be set on the user. This may include the modes in the join, but will usually place them on the mode * stacker to be set "soon". */ - virtual void SendJoin(const User *u, Channel *c, const ChannelStatus *status) = 0; + virtual void SendJoin(User *u, Channel *c, const ChannelStatus *status) = 0; virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...); /** Force joins a user that isn't ours to a channel. diff --git a/include/servers.h b/include/servers.h index d8b01626f..bf0acb523 100644 --- a/include/servers.h +++ b/include/servers.h @@ -33,6 +33,10 @@ namespace Servers */ extern CoreExport Server* GetUplink(); + /* Server maps by name and id */ + extern CoreExport Anope::map<Server *> ByName; + extern CoreExport Anope::map<Server *> ByID; + /* CAPAB/PROTOCTL given by the uplink */ extern CoreExport std::set<Anope::string> Capab; } @@ -169,10 +173,10 @@ class CoreExport Server : public Extensible /** Find a server * @param name The name or SID/numeric - * @param s The server list to search for this server on, defaults to our Uplink + * @param name_only set to true to only look up by name, not SID * @return The server */ - static Server *Find(const Anope::string &name, Server *s = NULL); + static Server *Find(const Anope::string &name, bool name_only = false); }; #endif // SERVERS_H diff --git a/include/users.h b/include/users.h index 4110ad211..5bcd61f95 100644 --- a/include/users.h +++ b/include/users.h @@ -79,7 +79,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe bool super_admin; /* Channels the user is in */ - typedef std::list<ChanUserContainer *> ChanUserList; + typedef std::map<Channel *, ChanUserContainer *> ChanUserList; ChanUserList chans; /* Last time this user sent a memo command used */ @@ -312,7 +312,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe * @param c The channel * @return The channel container, or NULL */ - ChanUserContainer *FindChannel(const Channel *c) const; + ChanUserContainer *FindChannel(Channel *c) const; /** Check if the user is protected from kicks and negative mode changes * @return true or false |
