diff options
author | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-07-26 23:32:03 -0400 |
---|---|---|
committer | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-07-26 23:32:03 -0400 |
commit | 57bb7593059242652c57aae4391b45416dc7fa70 (patch) | |
tree | 80b1b21308a0ce7e55bc5b8e278ed6cc95c07e8c | |
parent | 6e6b6b46aabfb3e558f66bd0fdc528e93505cf76 (diff) |
Trying to make things a little more const-safe, a work in progress but this is a bit better.
34 files changed, 143 insertions, 141 deletions
diff --git a/include/channels.h b/include/channels.h index 8bf98e4b9..f2785ff01 100644 --- a/include/channels.h +++ b/include/channels.h @@ -129,7 +129,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E * @param cms The status mode, or NULL to represent no status * @return true or false */ - bool HasUserStatus(User *u, ChannelModeStatus *cms); + bool HasUserStatus(User *u, ChannelModeStatus *cms) const; /** Check if a user has a status on a channel * Use the overloaded function for ChannelModeStatus* to check for no status @@ -137,7 +137,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E * @param Name The Mode name, eg CMODE_OP, CMODE_VOICE * @return true or false */ - bool HasUserStatus(User *u, ChannelModeName Name); + bool HasUserStatus(User *u, ChannelModeName Name) const; /** See if the channel has any modes at all * @return true or false @@ -148,7 +148,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags, CMODE_E * @param Name The mode name * @return true or false */ - bool HasMode(ChannelModeName Name); + bool HasMode(ChannelModeName Name) const; /** Set a mode internally on a channel, this is not sent out to the IRCd * @param cm The mode @@ -240,12 +240,13 @@ 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, Anope::string &Target); + bool GetParam(ChannelModeName Name, Anope::string &Target) const; /** Check if a mode is set and has a param * @param Name The mode */ - const bool HasParam(ChannelModeName Name); + bool HasParam(ChannelModeName Name) const; + /** Set a string of modes on the channel * @param bi The client setting the modes * @param EnforceMLock Should mlock be enforced on this mode change diff --git a/include/config.h b/include/config.h index ef7445041..54e3d095f 100644 --- a/include/config.h +++ b/include/config.h @@ -86,7 +86,7 @@ class ValueItem /** Change value to an int */ void Set(int); /** Get value as an int */ - int GetInteger(); + int GetInteger() const; /** Get value as a string */ const char *GetString() const; /** Get value as an std::string */ @@ -96,7 +96,7 @@ class ValueItem /** Get value as a ci::string */ inline const Anope::string &GetValue() const { return v; } /** Get value as a bool */ - bool GetBool(); + bool GetBool() const; }; /** The base class of the container 'ValueContainer' @@ -458,9 +458,9 @@ class ServerConfig /** Returns the numbers of vars inside the index'th 'tag in the config file */ int ConfVarEnum(ConfigDataHash &, const Anope::string &, int); - void ValidateHostname(const Anope::string &, const Anope::string &, const Anope::string &); - void ValidateIP(const Anope::string &p, const Anope::string &, const Anope::string &, bool); - void ValidateNoSpaces(const Anope::string &, const Anope::string &, const Anope::string &); + void ValidateHostname(const Anope::string &, const Anope::string &, const Anope::string &) const; + void ValidateIP(const Anope::string &p, const Anope::string &, const Anope::string &, bool) const; + void ValidateNoSpaces(const Anope::string &, const Anope::string &, const Anope::string &) const; /** Below here is a list of variables which contain the config files values */ @@ -965,7 +965,7 @@ class CoreExport ConfigReader * used with the index value of ConfigReader::ReadValue to loop through all copies of a * multiple instance tag. */ - int Enumerate(const Anope::string &); + int Enumerate(const Anope::string &) const; /** Returns true if a config file is valid. * This method is partially implemented and will only return false if the config * file does not exist or could not be opened. diff --git a/include/extern.h b/include/extern.h index e323102a2..f36be8640 100644 --- a/include/extern.h +++ b/include/extern.h @@ -341,7 +341,7 @@ E void process(const Anope::string &buf); E void send_cmd(const Anope::string &source, const char *fmt, ...) FORMAT(printf, 2, 3); -E void notice_server(const Anope::string &source, Server * s, const char *fmt, ...) FORMAT(printf, 3, 4); +E void notice_server(const Anope::string &source, const Server *s, const char *fmt, ...) FORMAT(printf, 3, 4); E void notice_lang(const Anope::string &source, User *dest, int message, ...); // MARK_DEPRECATED; E void notice_help(const Anope::string &source, User *dest, int message, ...); // MARK_DEPRECATED; diff --git a/include/modes.h b/include/modes.h index ce5372117..7a4ff7f70 100644 --- a/include/modes.h +++ b/include/modes.h @@ -133,7 +133,7 @@ class CoreExport UserModeParam : public UserMode * @param value The param * @return true or false */ - virtual bool IsValid(const Anope::string &value) { return true; } + virtual bool IsValid(const Anope::string &value) const { return true; } }; /** This class is a channel mode, all channel modes use this/inherit from this @@ -159,7 +159,7 @@ class CoreExport ChannelMode : public Mode * NOTE: User CAN be NULL, this is for checking if it can be locked with defcon * @param u The user, or NULL */ - virtual bool CanSet(User *u) { return true; } + virtual bool CanSet(User *u) const { return true; } }; @@ -183,7 +183,7 @@ class CoreExport ChannelModeList : public ChannelMode * @param mask The mask * @return true for yes, false for no */ - virtual bool IsValid(const Anope::string &mask) { return true; } + virtual bool IsValid(const Anope::string &mask) const { return true; } /** Add the mask to the channel, this should be overridden * @param chan The channel @@ -223,7 +223,7 @@ class CoreExport ChannelModeParam : public ChannelMode * @param value The param * @return true for yes, false for no */ - virtual bool IsValid(const Anope::string &value) { return true; } + virtual bool IsValid(const Anope::string &value) const { return true; } }; /** This is a mode that is a channel status, eg +v/h/o/a/q. @@ -291,7 +291,7 @@ class CoreExport ChannelModeKey : public ChannelModeParam public: ChannelModeKey(char modeChar) : ChannelModeParam(CMODE_KEY, "CMODE_KEY", modeChar) { } - bool IsValid(const Anope::string &value); + bool IsValid(const Anope::string &value) const; }; /** Channel mode +f (flood) @@ -301,7 +301,7 @@ class ChannelModeFlood : public ChannelModeParam public: ChannelModeFlood(char modeChar, bool minusNoArg = false) : ChannelModeParam(CMODE_FLOOD, "CMODE_FLOOD", modeChar, minusNoArg) { } - bool IsValid(const Anope::string &value); + bool IsValid(const Anope::string &value) const; }; /** This class is used for channel mode +A (Admin only) @@ -313,7 +313,7 @@ class CoreExport ChannelModeAdmin : public ChannelMode ChannelModeAdmin(char modeChar) : ChannelMode(CMODE_ADMINONLY, "CMODE_ADMINONLY", modeChar) { } /* Opers only */ - bool CanSet(User *u); + bool CanSet(User *u) const; }; /** This class is used for channel mode +O (Opers only) @@ -325,7 +325,7 @@ class CoreExport ChannelModeOper : public ChannelMode ChannelModeOper(char modeChar) : ChannelMode(CMODE_OPERONLY, "CMODE_OPERONLY", modeChar) { } /* Opers only */ - bool CanSet(User *u); + bool CanSet(User *u) const; }; /** This class is used for channel mode +r (registered channel) @@ -337,7 +337,7 @@ class CoreExport ChannelModeRegistered : public ChannelMode ChannelModeRegistered(char modeChar) : ChannelMode(CMODE_REGISTERED, "CMODE_REGISTERED", modeChar) { } /* No one mlocks +r */ - bool CanSet(User *u); + bool CanSet(User *u) const; }; enum StackerType diff --git a/include/modules.h b/include/modules.h index 643edf88c..f4b1ad60b 100644 --- a/include/modules.h +++ b/include/modules.h @@ -27,7 +27,6 @@ # define dlsym(file, symbol) (HMODULE)GetProcAddress(file, symbol) # define dlclose(file) FreeLibrary(file) ? 0 : 1 # define ano_modclearerr() SetLastError(0) -# define MODULE_EXT ".so" #else typedef void * ano_module_t; @@ -37,7 +36,6 @@ * to be cleared, POSIX-wise. -GD */ # define ano_modclearerr() dlerror() -# define MODULE_EXT ".so" #endif /** Possible return types from events. @@ -131,7 +129,6 @@ struct Message; extern CoreExport Module *FindModule(const Anope::string &name); int protocol_module_init(); -extern CoreExport Message *createMessage(const char *name, int (*func)(const char *source, int ac, const char **av)); extern CoreExport bool moduleMinVersion(int major, int minor, int patch, int build); enum ModuleReturn @@ -188,17 +185,17 @@ class Version /** Get the major version of Anope this was built against * @return The major version */ - const unsigned GetMajor(); + unsigned GetMajor() const; /** Get the minor version of Anope this was built against * @return The minor version */ - const unsigned GetMinor(); + unsigned GetMinor() const; /** Get the build version this was built against * @return The build version */ - const unsigned GetBuild(); + unsigned GetBuild() const; }; /* Forward declaration of CallBack class for the Module class */ @@ -275,7 +272,7 @@ class CoreExport Module /** Retrieves whether or not a given module is permanent. * @return true if the module is permanent, false else. */ - bool GetPermanent(); + bool GetPermanent() const; /** Set the modules version info. * @param version the version of the module @@ -291,7 +288,7 @@ class CoreExport Module * compiled against * @return The version */ - Version GetVersion(); + Version GetVersion() const; /** * Allow a module to add a set of language strings to anope @@ -322,7 +319,7 @@ class CoreExport Module * @param number The message number * @param ... The argument list **/ - void NoticeLang(const Anope::string &source, User *u, int number, ...); + void NoticeLang(const Anope::string &source, const User *u, int number, ...) const; /** * Add a module provided command to the given service. diff --git a/include/operserv.h b/include/operserv.h index b5025b007..e3c25b0f6 100644 --- a/include/operserv.h +++ b/include/operserv.h @@ -34,7 +34,7 @@ extern CoreExport void operserv(User *u, const Anope::string &message); extern CoreExport void os_init(); extern CoreExport void oper_global(const Anope::string &nick, const char *fmt, ...); -extern CoreExport void server_global(Server *s, const Anope::string &message); +extern CoreExport void server_global(const Server *s, const Anope::string &message); enum XLineType { @@ -101,7 +101,7 @@ class CoreExport XLineManager /** Get the number of XLines in this XLineManager * @return The number of XLines */ - const size_t GetCount() const; + size_t GetCount() const; /** Get the XLine vector * @return The vector @@ -123,7 +123,7 @@ class CoreExport XLineManager * @param index The index * @return The XLine, or NULL if the index is out of bounds */ - XLine *GetEntry(unsigned index) const; + XLine *GetEntry(unsigned index); /** Clear the XLine vector */ @@ -159,7 +159,7 @@ class CoreExport XLineManager * @param mask The mask * @return The XLine the user matches, or NULL */ - XLine *HasEntry(const Anope::string &mask) const; + XLine *HasEntry(const Anope::string &mask); /** Check a user against all of the xlines in this XLineManager * @param u The user diff --git a/include/regchannel.h b/include/regchannel.h index 00a99e96d..68eb08aa1 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -148,7 +148,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, /** Get the size of the accss vector for this channel * @return The access vector size */ - const unsigned GetAccessCount() const; + unsigned GetAccessCount() const; /** Erase an entry from the channel access list * @@ -191,7 +191,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, /** Get the size of the akick vector for this channel * @return The akick vector size */ - const unsigned GetAkickCount() const; + unsigned GetAkickCount() const; /** Erase an entry from the channel akick list * @param index The index of the akick @@ -218,7 +218,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, /** Get how many badwords are on this channel * @return The number of badwords in the vector */ - const unsigned GetBadWordCount() const; + unsigned GetBadWordCount() const; /** Remove a badword * @param index The index of the badword @@ -239,7 +239,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, * @param status True to check mlock on, false for mlock off * @return true on success, false on fail */ - const bool HasMLock(ChannelModeName Name, bool status); + bool HasMLock(ChannelModeName Name, bool status) const; /** Set a mlock * @param Name The mode @@ -263,19 +263,19 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, * @param status true for mlock on, false for mlock off * @return The number of mlocked modes */ - const size_t GetMLockCount(bool status) const; + size_t GetMLockCount(bool status) const; /** Get a param from the channel * @param Name The mode * @param Target a string to put the param into * @return true on success */ - const bool GetParam(ChannelModeName Name, Anope::string &Target); + bool GetParam(ChannelModeName Name, Anope::string &Target) const; /** Check if a mode is set and has a param * @param Name The mode */ - const bool HasParam(ChannelModeName Name); + bool HasParam(ChannelModeName Name) const; /** Clear all the params from the channel */ diff --git a/include/servers.h b/include/servers.h index 5c7d114f8..09de78547 100644 --- a/include/servers.h +++ b/include/servers.h @@ -120,7 +120,7 @@ class CoreExport Server : public Flags<ServerFlag> /** Get the number of hops this server is from services * @return Number of hops */ - unsigned int GetHops() const; + unsigned GetHops() const; /** Set the server description * @param desc The new description @@ -145,7 +145,7 @@ class CoreExport Server : public Flags<ServerFlag> /** Get the uplink server for this server, if this is our uplink will be Me * @return The servers uplink */ - Server *GetUplink() const; + Server *GetUplink(); /** Adds a link to this server * @param s The linking server diff --git a/include/services.h b/include/services.h index a23f78bff..16f365a09 100644 --- a/include/services.h +++ b/include/services.h @@ -940,8 +940,8 @@ class CoreExport IRCDProto virtual void SendNotice(BotInfo *bi, const Anope::string &dest, const char *fmt, ...); virtual void SendAction(BotInfo *bi, const Anope::string &dest, const char *fmt, ...); virtual void SendPrivmsg(BotInfo *bi, const Anope::string &dest, const char *fmt, ...); - virtual void SendGlobalNotice(BotInfo *bi, Server *dest, const Anope::string &msg); - virtual void SendGlobalPrivmsg(BotInfo *bi, Server *desc, const Anope::string &msg); + virtual void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg); + virtual void SendGlobalPrivmsg(BotInfo *bi, const Server *desc, const Anope::string &msg); /** XXX: This is a hack for NickServ enforcers. It is deprecated. * If I catch any developer using this in new code, I will RIP YOUR BALLS OFF. diff --git a/include/sockets.h b/include/sockets.h index c1d102edc..78ed5f4af 100644 --- a/include/sockets.h +++ b/include/sockets.h @@ -1,4 +1,4 @@ -/* +/* * * (C) 2003-2010 Anope Team * Contact us at team@anope.org @@ -55,13 +55,13 @@ class CoreExport Socket : public Flags<SocketFlag, 1> * @param sz How much to read * @return Number of bytes recieved */ - virtual const int RecvInternal(char *buf, size_t sz) const; + virtual int RecvInternal(char *buf, size_t sz) const; /** Really write something to the socket * @param buf What to write * @return Number of bytes written */ - virtual const int SendInternal(const Anope::string &buf) const; + virtual int SendInternal(const Anope::string &buf) const; protected: /* Socket FD */ @@ -86,7 +86,7 @@ class CoreExport Socket : public Flags<SocketFlag, 1> * @param nIPv6 true if using ipv6 */ Socket(int nsock, bool nIPv6); - + /** Default destructor */ virtual ~Socket(); @@ -161,22 +161,22 @@ class CoreExport ClientSocket : public Socket public: - /** Constructor - * @param nTargetHost The target host to connect to - * @param nPort The target port to connect to - * @param nBindHost The host to bind to for connecting - * @param nIPv6 true to use IPv6 - */ - ClientSocket(const Anope::string &nTargetHost, int nPort, const Anope::string &nBindHost, bool nIPv6); + /** Constructor + * @param nTargetHost The target host to connect to + * @param nPort The target port to connect to + * @param nBindHost The host to bind to for connecting + * @param nIPv6 true to use IPv6 + */ + ClientSocket(const Anope::string &nTargetHost, int nPort, const Anope::string &nBindHost, bool nIPv6); - /** Default destructor - */ - virtual ~ClientSocket(); + /** Default destructor + */ + virtual ~ClientSocket(); /** Called with a line recieved from the socket - * @param buf The line - * @return true to continue reading, false to drop the socket - */ + * @param buf The line + * @return true to continue reading, false to drop the socket + */ virtual bool Read(const Anope::string &buf); }; @@ -217,8 +217,8 @@ class CoreExport ListenSocket : public Socket /** Get the port this socket is bound to * @return The port - */ - const int GetPort() const; + */ + int GetPort() const; }; #endif // SOCKET_H diff --git a/include/timers.h b/include/timers.h index 9573ee524..79443d753 100644 --- a/include/timers.h +++ b/include/timers.h @@ -56,22 +56,22 @@ class CoreExport Timer : public Extensible /** Retrieve the triggering time * @return The trigger time */ - const time_t GetTimer(); + time_t GetTimer() const; /** Returns true if the timer is set to repeat * @return Returns true if the timer is set to repeat */ - const bool GetRepeat(); + bool GetRepeat() const; /** Returns the interval between ticks * @return The interval */ - const long GetSecs(); + long GetSecs() const; /** Returns the time this timer was created * @return The time this timer was created */ - const time_t GetSetTime(); + time_t GetSetTime() const; /** Called when the timer ticks * This should be overridden with something useful diff --git a/include/users.h b/include/users.h index 6db093c32..c80daa193 100644 --- a/include/users.h +++ b/include/users.h @@ -92,7 +92,7 @@ class CoreExport User : public Extensible /** Get the displayed vhost of a user record. * @return The displayed vhost of the user, where ircd-supported, or the user's real host. */ - const Anope::string GetDisplayedHost() const; + const Anope::string &GetDisplayedHost() const; /** Update the cloaked host of a user * @param host The cloaked host @@ -134,7 +134,7 @@ class CoreExport User : public Extensible /** Get the full mask ( nick!ident@realhost ) of a user */ - const Anope::string GetMask(); + Anope::string GetMask() const; /** Updates the realname of the user record. */ @@ -146,8 +146,8 @@ class CoreExport User : public Extensible * @param fmt Format of the Message * @param ... any number of parameters */ - virtual void SendMessage(const Anope::string &source, const char *fmt, ...); - virtual void SendMessage(const Anope::string &source, const Anope::string &msg); + virtual void SendMessage(const Anope::string &source, const char *fmt, ...) const; + virtual void SendMessage(const Anope::string &source, const Anope::string &msg) const; /** Collide a nick * See the comment in users.cpp @@ -179,6 +179,7 @@ class CoreExport User : public Extensible * @reurn The account or NULL */ virtual NickCore *Account(); + virtual const NickCore *Account() const; /** Check if the user is identified for their nick * @param CheckNick True to check if the user is identified to the nickname they are on too @@ -264,7 +265,7 @@ class CoreExport User : public Extensible * @param c The channel * @return The channel container, or NULL */ - ChannelContainer *FindChannel(Channel *c); + ChannelContainer *FindChannel(const Channel *c); /** Check if the user is protected from kicks and negative mode changes * @return true or false diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp index 386dd0d5f..ea1c3e4fb 100644 --- a/modules/extra/m_ssl.cpp +++ b/modules/extra/m_ssl.cpp @@ -19,12 +19,12 @@ class SSLSocket : public ClientSocket private: SSL *sslsock; - const int RecvInternal(char *buf, size_t sz) const + int RecvInternal(char *buf, size_t sz) const { return SSL_read(sslsock, buf, sz); } - const int SendInternal(const Anope::string &buf) const + int SendInternal(const Anope::string &buf) const { return SSL_write(sslsock, buf.c_str(), buf.length()); } diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 1f8b70ef7..d80fb953b 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -709,7 +709,7 @@ int anope_event_burst(const Anope::string &source, int ac, const char **av) return MOD_CONT; } -bool ChannelModeFlood::IsValid(const Anope::string &value) +bool ChannelModeFlood::IsValid(const Anope::string &value) const { Anope::string rest; if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty()) diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp index 9e21516e6..c58c011c9 100644 --- a/modules/protocol/inspircd11.cpp +++ b/modules/protocol/inspircd11.cpp @@ -1081,7 +1081,7 @@ void moduleAddIRCDMsgs() Anope::AddMessage("IDLE", anope_event_idle); } -bool ChannelModeFlood::IsValid(const Anope::string &value) +bool ChannelModeFlood::IsValid(const Anope::string &value) const { Anope::string rest; if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty()) diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 416a91c96..4c1a5407e 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -1280,7 +1280,7 @@ void moduleAddIRCDMsgs() Anope::AddMessage("METADATA", anope_event_metadata); } -bool ChannelModeFlood::IsValid(const Anope::string &value) +bool ChannelModeFlood::IsValid(const Anope::string &value) const { Anope::string rest; if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty()) diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 8c3f14e67..5097f24b8 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -1251,7 +1251,7 @@ void moduleAddIRCDMsgs() Anope::AddMessage("METADATA", anope_event_metadata); } -bool ChannelModeFlood::IsValid(const Anope::string &value) +bool ChannelModeFlood::IsValid(const Anope::string &value) const { //char *dp, *end; Anope::string rest; diff --git a/modules/protocol/unreal32.cpp b/modules/protocol/unreal32.cpp index f94e5bcbe..a8aee3790 100644 --- a/modules/protocol/unreal32.cpp +++ b/modules/protocol/unreal32.cpp @@ -1215,7 +1215,7 @@ void moduleAddIRCDMsgs() } /* Borrowed part of this check from UnrealIRCd */ -bool ChannelModeFlood::IsValid(const Anope::string &value) +bool ChannelModeFlood::IsValid(const Anope::string &value) const { if (value.empty()) return false; diff --git a/src/channels.cpp b/src/channels.cpp index 862dfe152..9654b295b 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -206,7 +206,7 @@ UserContainer *Channel::FindUser(User *u) * @param cms The status mode, or NULL to represent no status * @return true or false */ -bool Channel::HasUserStatus(User *u, ChannelModeStatus *cms) +bool Channel::HasUserStatus(User *u, ChannelModeStatus *cms) const { if (!u || (cms && cms->Type != MODE_STATUS)) throw CoreException("Channel::HasUserStatus got bad mode"); @@ -230,7 +230,7 @@ bool Channel::HasUserStatus(User *u, ChannelModeStatus *cms) * @param Name The Mode name, eg CMODE_OP, CMODE_VOICE * @return true or false */ -bool Channel::HasUserStatus(User *u, ChannelModeName Name) +bool Channel::HasUserStatus(User *u, ChannelModeName Name) const { return HasUserStatus(u, dynamic_cast<ChannelModeStatus *>(ModeManager::FindChannelModeByName(Name))); } @@ -240,7 +240,7 @@ bool Channel::HasUserStatus(User *u, ChannelModeName Name) * @param Name The mode name * @return true or false */ -bool Channel::HasMode(ChannelModeName Name) +bool Channel::HasMode(ChannelModeName Name) const { return modes.HasFlag(Name); } @@ -612,9 +612,9 @@ void Channel::RemoveMode(BotInfo *bi, char Mode, const Anope::string ¶m, boo * @param Target a string to put the param into * @return true on success */ -const bool Channel::GetParam(ChannelModeName Name, Anope::string &Target) +bool Channel::GetParam(ChannelModeName Name, Anope::string &Target) const { - std::map<ChannelModeName, Anope::string>::iterator it = Params.find(Name); + std::map<ChannelModeName, Anope::string>::const_iterator it = Params.find(Name); Target.clear(); @@ -630,9 +630,9 @@ const bool Channel::GetParam(ChannelModeName Name, Anope::string &Target) /** Check if a mode is set and has a param * @param Name The mode */ -const bool Channel::HasParam(ChannelModeName Name) +bool Channel::HasParam(ChannelModeName Name) const { - std::map<ChannelModeName, Anope::string>::iterator it = Params.find(Name); + std::map<ChannelModeName, Anope::string>::const_iterator it = Params.find(Name); if (it != Params.end()) return true; diff --git a/src/config.cpp b/src/config.cpp index c9dcf426a..7dbce6a61 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -65,7 +65,7 @@ bool NoValidation(ServerConfig *, const Anope::string &, const Anope::string &, return true; } -void ServerConfig::ValidateNoSpaces(const Anope::string &p, const Anope::string &tag, const Anope::string &val) +void ServerConfig::ValidateNoSpaces(const Anope::string &p, const Anope::string &tag, const Anope::string &val) const { for (Anope::string::const_iterator ptr = p.begin(), end = p.end(); ptr != end; ++ptr) if (*ptr == ' ') @@ -76,7 +76,7 @@ void ServerConfig::ValidateNoSpaces(const Anope::string &p, const Anope::string * even in strerror(errno). They just return 'yes' or 'no' to an address without such detail as to whats WRONG with the address. * Because ircd users arent as technical as they used to be (;)) we are going to give more of a useful error message. */ -void ServerConfig::ValidateIP(const Anope::string &p, const Anope::string &tag, const Anope::string &val, bool wild) +void ServerConfig::ValidateIP(const Anope::string &p, const Anope::string &tag, const Anope::string &val, bool wild) const { int num_dots = 0, num_seps = 0; bool not_numbers = false, not_hex = false; @@ -128,7 +128,7 @@ void ServerConfig::ValidateIP(const Anope::string &p, const Anope::string &tag, } } -void ServerConfig::ValidateHostname(const Anope::string &p, const Anope::string &tag, const Anope::string &val) +void ServerConfig::ValidateHostname(const Anope::string &p, const Anope::string &tag, const Anope::string &val) const { if (p.equals_ci("localhost")) return; @@ -1454,7 +1454,7 @@ void ValueItem::Set(int value) v = n.str(); } -int ValueItem::GetInteger() +int ValueItem::GetInteger() const { if (v.empty() || !v.is_number_only()) return 0; @@ -1466,7 +1466,7 @@ const char *ValueItem::GetString() const return v.c_str(); } -bool ValueItem::GetBool() +bool ValueItem::GetBool() const { return GetInteger() || v == "yes" || v == "true"; } diff --git a/src/configreader.cpp b/src/configreader.cpp index 9e17b34be..6ba9453f7 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -92,7 +92,7 @@ void ConfigReader::DumpErrors(bool bail) Config.ReportConfigError(this->errorlog->str(), bail); } -int ConfigReader::Enumerate(const Anope::string &tag) +int ConfigReader::Enumerate(const Anope::string &tag) const { return Config.ConfValueEnum(*this->data, tag); } diff --git a/src/modes.cpp b/src/modes.cpp index 3642b977e..af4c2f879 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -201,7 +201,7 @@ ChannelModeStatus::~ChannelModeStatus() * @param value The key * @return true or false */ -bool ChannelModeKey::IsValid(const Anope::string &value) +bool ChannelModeKey::IsValid(const Anope::string &value) const { if (!value.empty() && value.find(':') != Anope::string::npos && value.find(',') != Anope::string::npos) return true; @@ -213,7 +213,7 @@ bool ChannelModeKey::IsValid(const Anope::string &value) * @param u The user - can be NULL if defcon is checking * @return true or false */ -bool ChannelModeAdmin::CanSet(User *u) +bool ChannelModeAdmin::CanSet(User *u) const { if (u && is_oper(u)) return true; @@ -225,7 +225,7 @@ bool ChannelModeAdmin::CanSet(User *u) * @param u The user - can be NULL if defcon is checking * @return true or false */ -bool ChannelModeOper::CanSet(User *u) +bool ChannelModeOper::CanSet(User *u) const { if (u && is_oper(u)) return true; @@ -233,11 +233,11 @@ bool ChannelModeOper::CanSet(User *u) return false; } -/** Can the user set the registerd mode? +/** Can the user set the registered mode? * No. * @return false */ -bool ChannelModeRegistered::CanSet(User *u) +bool ChannelModeRegistered::CanSet(User *u) const { return false; } diff --git a/src/module.cpp b/src/module.cpp index 99233d7a3..d426eb2aa 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -130,7 +130,7 @@ void Module::SetPermanent(bool state) this->permanent = state; } -bool Module::GetPermanent() +bool Module::GetPermanent() const { return this->permanent; } @@ -153,17 +153,17 @@ Version::~Version() { } -const unsigned Version::GetMajor() +unsigned Version::GetMajor() const { return Major; } -const unsigned Version::GetMinor() +unsigned Version::GetMinor() const { return Minor; } -const unsigned Version::GetBuild() +unsigned Version::GetBuild() const { return Build; } diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index a8a290ed6..30424afef 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -35,7 +35,7 @@ static int moduleCopyFile(const Anope::string &name, Anope::string &output) #ifndef _WIN32 int srcfp; #endif - Anope::string input = services_dir + "/modules/" + name + MODULE_EXT; + Anope::string input = services_dir + "/modules/" + name + ".so"; if (!(source = fopen(input.c_str(), "rb"))) return MOD_ERR_NOEXIST; @@ -123,7 +123,7 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) Alog(LOG_DEBUG) << "trying to load [" << modname << "]"; /* Generate the filename for the temporary copy of the module */ - Anope::string pbuf = services_dir + "/modules/runtime/" + modname + MODULE_EXT + ".XXXXXX"; + Anope::string pbuf = services_dir + "/modules/runtime/" + modname + ".so.XXXXXX"; /* Don't skip return value checking! -GD */ if ((ret = moduleCopyFile(modname, pbuf)) != MOD_ERR_OK) diff --git a/src/modules.cpp b/src/modules.cpp index b6115137d..7f7af6150 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -254,7 +254,7 @@ bool moduleMinVersion(int major, int minor, int patch, int build) return ret; } -void Module::NoticeLang(const Anope::string &source, User *u, int number, ...) +void Module::NoticeLang(const Anope::string &source, const User *u, int number, ...) const { va_list va; char buffer[4096], outbuf[4096]; @@ -396,7 +396,7 @@ void ModuleRunTimeDirCleanUp() Alog(LOG_DEBUG) << "Module run time directory has been cleaned out"; } -Version Module::GetVersion() +Version Module::GetVersion() const { return Version(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD); } diff --git a/src/operserv.cpp b/src/operserv.cpp index e91ad113b..30aa52b63 100644 --- a/src/operserv.cpp +++ b/src/operserv.cpp @@ -122,7 +122,7 @@ void DelDefCon(int level, DefconLevel Level) DefCon[level][Level] = false; } -void server_global(Server *s, const Anope::string &message) +void server_global(const Server *s, const Anope::string &message) { /* Do not send the notice to ourselves our juped servers */ if (s != Me && !s->HasFlag(SERVER_JUPED)) @@ -269,7 +269,7 @@ std::pair<XLineManager *, XLine *> XLineManager::CheckAll(User *u) /** Get the number of XLines in this XLineManager * @return The number of XLines */ -const size_t XLineManager::GetCount() const +size_t XLineManager::GetCount() const { return XLines.size(); } @@ -313,7 +313,7 @@ bool XLineManager::DelXLine(XLine *x) * @param index The index * @return The XLine, or NULL if the index is out of bounds */ -XLine *XLineManager::GetEntry(unsigned index) const +XLine *XLineManager::GetEntry(unsigned index) { if (index >= XLines.size()) return NULL; @@ -405,7 +405,7 @@ std::pair<int, XLine *> XLineManager::CanAdd(const Anope::string &mask, time_t e * @param mask The mask * @return The XLine the user matches, or NULL */ -XLine *XLineManager::HasEntry(const Anope::string &mask) const +XLine *XLineManager::HasEntry(const Anope::string &mask) { for (unsigned i = 0, end = XLines.size(); i < end; ++i) { diff --git a/src/protocol.cpp b/src/protocol.cpp index 7bb21407b..f11c591b2 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -150,12 +150,12 @@ void IRCDProto::SendPrivmsg(BotInfo *bi, const Anope::string &dest, const char * SendPrivmsgInternal(bi, dest, buf); } -void IRCDProto::SendGlobalNotice(BotInfo *bi, Server *dest, const Anope::string &msg) +void IRCDProto::SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) { send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "NOTICE %s%s :%s", ircd->globaltldprefix, dest->GetName().c_str(), msg.c_str()); } -void IRCDProto::SendGlobalPrivmsg(BotInfo *bi, Server *dest, const Anope::string &msg) +void IRCDProto::SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) { send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "PRIVMSG %s%s :%s", ircd->globaltldprefix, dest->GetName().c_str(), msg.c_str()); } diff --git a/src/regchannel.cpp b/src/regchannel.cpp index d596b6bb6..019f173e5 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -162,7 +162,7 @@ ChanAccess *ChannelInfo::GetAccess(const NickCore *nc, int16 level) /** Get the size of the accss vector for this channel * @return The access vector size */ -const unsigned ChannelInfo::GetAccessCount() const +unsigned ChannelInfo::GetAccessCount() const { return access.empty() ? 0 : access.size(); } @@ -254,7 +254,7 @@ AutoKick *ChannelInfo::GetAkick(unsigned index) /** Get the size of the akick vector for this channel * @return The akick vector size */ -const unsigned ChannelInfo::GetAkickCount() const +unsigned ChannelInfo::GetAkickCount() const { return akick.empty() ? 0 : akick.size(); } @@ -312,7 +312,7 @@ BadWord *ChannelInfo::GetBadWord(unsigned index) /** Get how many badwords are on this channel * @return The number of badwords in the vector */ -const unsigned ChannelInfo::GetBadWordCount() const +unsigned ChannelInfo::GetBadWordCount() const { return badwords.empty() ? 0 : badwords.size(); } @@ -409,7 +409,7 @@ void ChannelInfo::LoadMLock() * @param status True to check mlock on, false for mlock off * @return true on success, false on fail */ -const bool ChannelInfo::HasMLock(ChannelModeName Name, bool status) +bool ChannelInfo::HasMLock(ChannelModeName Name, bool status) const { if (status) return mlock_on.HasFlag(Name); @@ -485,7 +485,7 @@ void ChannelInfo::ClearMLock() * @param status true for mlock on, false for mlock off * @return The number of mlocked modes */ -const size_t ChannelInfo::GetMLockCount(bool status) const +size_t ChannelInfo::GetMLockCount(bool status) const { if (status) return mlock_on.FlagCount(); @@ -498,9 +498,9 @@ const size_t ChannelInfo::GetMLockCount(bool status) const * @param Target a string to put the param into * @return true on success */ -const bool ChannelInfo::GetParam(ChannelModeName Name, Anope::string &Target) +bool ChannelInfo::GetParam(ChannelModeName Name, Anope::string &Target) const { - std::map<ChannelModeName, Anope::string>::iterator it = Params.find(Name); + std::map<ChannelModeName, Anope::string>::const_iterator it = Params.find(Name); Target.clear(); @@ -516,9 +516,9 @@ const bool ChannelInfo::GetParam(ChannelModeName Name, Anope::string &Target) /** Check if a mode is set and has a param * @param Name The mode */ -const bool ChannelInfo::HasParam(ChannelModeName Name) +bool ChannelInfo::HasParam(ChannelModeName Name) const { - std::map<ChannelModeName, Anope::string>::iterator it = Params.find(Name); + std::map<ChannelModeName, Anope::string>::const_iterator it = Params.find(Name); if (it != Params.end()) return true; diff --git a/src/send.cpp b/src/send.cpp index f04e937c2..7f724a1e2 100644 --- a/src/send.cpp +++ b/src/send.cpp @@ -63,7 +63,7 @@ void send_cmd(const Anope::string &source, const char *fmt, ...) * @param ... any number of parameters * @return void */ -void notice_server(const Anope::string &source, Server *s, const char *fmt, ...) +void notice_server(const Anope::string &source, const Server *s, const char *fmt, ...) { va_list args; char buf[BUFSIZE] = ""; diff --git a/src/servers.cpp b/src/servers.cpp index 251e594ea..d53f58f6e 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -143,7 +143,7 @@ const Anope::string &Server::GetName() const /** Get the number of hops this server is from services * @return Number of hops */ -unsigned int Server::GetHops() const +unsigned Server::GetHops() const { return Hops; } @@ -183,7 +183,7 @@ const std::list<Server*> *Server::GetLinks() const /** Get the uplink server for this server, if this is our uplink will be Me * @return The servers uplink */ -Server *Server::GetUplink() const +Server *Server::GetUplink() { return UplinkServer; } diff --git a/src/sessions.cpp b/src/sessions.cpp index 9a1bc7a76..31deb02c3 100644 --- a/src/sessions.cpp +++ b/src/sessions.cpp @@ -253,7 +253,7 @@ Exception *find_hostip_exception(const Anope::string &host, const Anope::string for (std::vector<Exception *>::const_iterator it = exceptions.begin(), it_end = exceptions.end(); it != it_end; ++it) { Exception *e = *it; - if (Anope::Match(host, e->mask) || (ircd->nickip && !hostip.empty() && Anope::Match(hostip, e->mask))) + if (Anope::Match(host, e->mask) || (!hostip.empty() && Anope::Match(hostip, e->mask))) return e; } diff --git a/src/sockets.cpp b/src/sockets.cpp index d72b2847d..345bb7032 100644 --- a/src/sockets.cpp +++ b/src/sockets.cpp @@ -43,7 +43,7 @@ Socket::~Socket() * @param sz How much to read * @return Number of bytes recieved */ -const int Socket::RecvInternal(char *buf, size_t sz) const +int Socket::RecvInternal(char *buf, size_t sz) const { return recv(GetSock(), buf, sz, 0); } @@ -52,7 +52,7 @@ const int Socket::RecvInternal(char *buf, size_t sz) const * @param buf What to write * @return Number of bytes written */ -const int Socket::SendInternal(const Anope::string &buf) const +int Socket::SendInternal(const Anope::string &buf) const { return send(GetSock(), buf.c_str(), buf.length(), 0); } @@ -437,7 +437,7 @@ const Anope::string &ListenSocket::GetBindIP() const /** Get the port this socket is bound to * @return The port */ -const int ListenSocket::GetPort() const +int ListenSocket::GetPort() const { return Port; } diff --git a/src/timers.cpp b/src/timers.cpp index df3f2d228..5e06d5bd3 100644 --- a/src/timers.cpp +++ b/src/timers.cpp @@ -45,7 +45,7 @@ void Timer::SetTimer(time_t t) /** Retrieve the triggering time * @return The trigger time */ -const time_t Timer::GetTimer() +time_t Timer::GetTimer() const { return trigger; } @@ -53,7 +53,7 @@ const time_t Timer::GetTimer() /** Returns true if the timer is set to repeat * @return Returns true if the timer is set to repeat */ -const bool Timer::GetRepeat() +bool Timer::GetRepeat() const { return repeat; } @@ -61,7 +61,7 @@ const bool Timer::GetRepeat() /** Returns the time this timer was created * @return The time this timer was created */ -const time_t Timer::GetSetTime() +time_t Timer::GetSetTime() const { return settime; } @@ -69,7 +69,7 @@ const time_t Timer::GetSetTime() /** Returns the interval between ticks * @return The interval */ -const long Timer::GetSecs() +long Timer::GetSecs() const { return secs; } diff --git a/src/users.cpp b/src/users.cpp index 6ccaf9bf0..b4d6ebfdf 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -96,7 +96,7 @@ void User::SetDisplayedHost(const Anope::string &shost) /** Get the displayed vhost of a user record. * @return The displayed vhost of the user, where ircd-supported, or the user's real host. */ -const Anope::string User::GetDisplayedHost() const +const Anope::string &User::GetDisplayedHost() const { if (ircd->vhost && !this->vhost.empty()) return this->vhost; @@ -167,11 +167,9 @@ const Anope::string &User::GetIdent() const return this->ident; } -const Anope::string User::GetMask() +Anope::string User::GetMask() const { - std::stringstream buf; - buf << this->nick << "!" << this->ident << "@" << this->host; - return buf.str(); + return this->nick + "!" + this->ident + "@" + this->host; } void User::SetRealname(const Anope::string &srealname) @@ -225,7 +223,7 @@ User::~User() Alog(LOG_DEBUG_2) << "User::~User() done"; } -void User::SendMessage(const Anope::string &source, const char *fmt, ...) +void User::SendMessage(const Anope::string &source, const char *fmt, ...) const { va_list args; char buf[BUFSIZE] = ""; @@ -241,7 +239,7 @@ void User::SendMessage(const Anope::string &source, const char *fmt, ...) } } -void User::SendMessage(const Anope::string &source, const Anope::string &msg) +void User::SendMessage(const Anope::string &source, const Anope::string &msg) const { /* Send privmsg instead of notice if: * - UsePrivmsg is enabled @@ -410,6 +408,11 @@ NickCore *User::Account() return nc; } +const NickCore *User::Account() const +{ + return nc; +} + /** Check if the user is identified for their nick * @param CheckNick True to check if the user is identified to the nickname they are on too * @return true or false @@ -625,9 +628,9 @@ void User::SetModes(BotInfo *bi, const char *umodes, ...) * @param c The channel * @return The channel container, or NULL */ -ChannelContainer *User::FindChannel(Channel *c) +ChannelContainer *User::FindChannel(const Channel *c) { - for (UChannelList::iterator it = this->chans.begin(), it_end = this->chans.end(); it != it_end; ++it) + for (UChannelList::const_iterator it = this->chans.begin(), it_end = this->chans.end(); it != it_end; ++it) if ((*it)->chan == c) return *it; return NULL; |