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 /src | |
parent | 6e6b6b46aabfb3e558f66bd0fdc528e93505cf76 (diff) |
Trying to make things a little more const-safe, a work in progress but this is a bit better.
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 14 | ||||
-rw-r--r-- | src/config.cpp | 10 | ||||
-rw-r--r-- | src/configreader.cpp | 2 | ||||
-rw-r--r-- | src/modes.cpp | 10 | ||||
-rw-r--r-- | src/module.cpp | 8 | ||||
-rw-r--r-- | src/modulemanager.cpp | 4 | ||||
-rw-r--r-- | src/modules.cpp | 4 | ||||
-rw-r--r-- | src/operserv.cpp | 8 | ||||
-rw-r--r-- | src/protocol.cpp | 4 | ||||
-rw-r--r-- | src/regchannel.cpp | 18 | ||||
-rw-r--r-- | src/send.cpp | 2 | ||||
-rw-r--r-- | src/servers.cpp | 4 | ||||
-rw-r--r-- | src/sessions.cpp | 2 | ||||
-rw-r--r-- | src/sockets.cpp | 6 | ||||
-rw-r--r-- | src/timers.cpp | 8 | ||||
-rw-r--r-- | src/users.cpp | 21 |
16 files changed, 64 insertions, 61 deletions
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; |