diff options
65 files changed, 464 insertions, 473 deletions
diff --git a/include/modules.h b/include/modules.h index 722bf4e3c..79c12a9cd 100644 --- a/include/modules.h +++ b/include/modules.h @@ -238,9 +238,9 @@ do { \ /** Is a module created user */ #define IS_MODULE_CREATED(x) (x->GetFd() == FD_MAGIC_NUMBER) /** Is an oper */ -#define IS_OPER(x) (*x->oper) +#define IS_OPER(x) (x->oper.empty()) /** Is away */ -#define IS_AWAY(x) (*x->awaymsg) +#define IS_AWAY(x) (x->awaymsg.empty()) /** Holds a module's Version information. * The four members (set by the constructor only) indicate details as to the version number diff --git a/include/u_listmode.h b/include/u_listmode.h index 19e9bf834..a7df014ed 100644 --- a/include/u_listmode.h +++ b/include/u_listmode.h @@ -153,15 +153,15 @@ class ListModeBase : public ModeHandler { for (modelist::reverse_iterator it = el->rbegin(); it != el->rend(); ++it) { - user->WriteNumeric(listnumeric, "%s %s %s %s %s", user->nick, channel->name, it->mask.c_str(), it->nick.c_str(), it->time.c_str()); + user->WriteNumeric(listnumeric, "%s %s %s %s %s", user->nick.c_str(), channel->name, it->mask.c_str(), it->nick.c_str(), it->time.c_str()); } } - user->WriteNumeric(endoflistnumeric, "%s %s :%s", user->nick, channel->name, endofliststring.c_str()); + user->WriteNumeric(endoflistnumeric, "%s %s :%s", user->nick.c_str(), channel->name, endofliststring.c_str()); } virtual void DisplayEmptyList(User* user, Channel* channel) { - user->WriteNumeric(endoflistnumeric, "%s %s :%s", user->nick, channel->name, endofliststring.c_str()); + user->WriteNumeric(endoflistnumeric, "%s %s :%s", user->nick.c_str(), channel->name, endofliststring.c_str()); } /** Remove all instances of the mode from a channel. @@ -323,7 +323,7 @@ class ListModeBase : public ModeHandler /* List is full, give subclass a chance to send a custom message */ if (!TellListTooLong(source, channel, parameter)) { - source->WriteNumeric(478, "%s %s %s :Channel ban/ignore list is full", source->nick, channel->name, parameter.c_str()); + source->WriteNumeric(478, "%s %s %s :Channel ban/ignore list is full", source->nick.c_str(), channel->name, parameter.c_str()); } parameter = ""; diff --git a/include/users.h b/include/users.h index 9a7b9a6e7..c07e157ab 100644 --- a/include/users.h +++ b/include/users.h @@ -437,19 +437,19 @@ class CoreExport User : public connection /** Cached nick!ident@host value using the real hostname */ - char* cached_fullhost; + std::string cached_fullhost; /** Cached nick!ident@ip value using the real IP address */ - char* cached_hostip; + std::string cached_hostip; /** Cached nick!ident@host value using the masked hostname */ - char* cached_makehost; + std::string cached_makehost; /** Cached nick!ident@realhost value using the real hostname */ - char* cached_fullrealhost; + std::string cached_fullrealhost; /** When we erase the user (in the destructor), * we call this method to subtract one from all @@ -512,27 +512,27 @@ class CoreExport User : public connection * An invalid nickname indicates an unregistered connection prior to the NICK command. * Use InspIRCd::IsNick() to validate nicknames. */ - char nick[NICKMAX]; - + std::string nick; + /** The user's unique identifier. * This is the unique identifier which the user has across the network. */ - char uuid[UUID_LENGTH]; - + std::string uuid; + /** The users ident reply. * Two characters are added to the user-defined limit to compensate for the tilde etc. */ - char ident[IDENTMAX+2]; - + std::string ident; + /** The host displayed to non-opers (used for cloaking etc). * This usually matches the value of User::host. */ - char dhost[65]; - + std::string dhost; + /** The users full name (GECOS). */ - char fullname[MAXGECOS+1]; - + std::string fullname; + /** The user's mode list. * This is NOT a null terminated string! In the 1.1 version of InspIRCd * this is an array of values in a similar way to channel modes. @@ -560,8 +560,8 @@ class CoreExport User : public connection /** The user's away message. * If this string is empty, the user is not marked as away. */ - char awaymsg[MAXAWAY+1]; - + std::string awaymsg; + /** Time the user last went away. * This is ONLY RELIABLE if user IS_AWAY()! */ @@ -578,8 +578,8 @@ class CoreExport User : public connection * we can say 'yay' or 'nay' to any commands they issue. * The value of this is the value of a valid 'type name=' tag. */ - char oper[NICKMAX]; - + std::string oper; + /** True when DNS lookups are completed. * The UserResolver classes res_forward and res_reverse will * set this value once they complete. @@ -590,8 +590,8 @@ class CoreExport User : public connection * This is stored even if the <connect> block doesnt need a password, so that * modules may check it. */ - char password[64]; - + std::string password; + /** User's receive queue. * Lines from the IRCd awaiting processing are stored here. * Upgraded april 2005, old system a bit hairy. @@ -698,7 +698,7 @@ class CoreExport User : public connection * on the server, in nick!ident&at;host form. * @return The full masked host of the user */ - virtual char* GetFullHost(); + virtual const std::string& GetFullHost(); /** Returns the full real host of the user * This member function returns the hostname of the user as seen by other users @@ -706,7 +706,7 @@ class CoreExport User : public connection * e.g. through a module, then this method will ignore it and return the true hostname. * @return The full real host of the user */ - virtual char* GetFullRealHost(); + virtual const std::string& GetFullRealHost(); /** This clears any cached results that are used for GetFullRealHost() etc. * The results of these calls are cached as generating them can be generally expensive. @@ -874,13 +874,13 @@ class CoreExport User : public connection * Takes a buffer to use and fills the given buffer with the hostmask in the format user@host * @return the usermask in the format user@host */ - char* MakeHost(); + const std::string& MakeHost(); /** Creates a usermask with real ip. * Takes a buffer to use and fills the given buffer with the ipmask in the format user@ip * @return the usermask in the format user@ip */ - char* MakeHostIP(); + const std::string& MakeHostIP(); /** Shuts down and closes the user's socket * This will not cause the user to be deleted. Use InspIRCd::QuitUser for this, @@ -1113,7 +1113,7 @@ class CoreExport User : public connection /** Get oper-specific quit message shown only to opers when the user quits. * (overrides any sent by QuitUser) */ - const char* GetOperQuit(); + const std::string& GetOperQuit(); /** Increases a user's command penalty by a set amount. */ diff --git a/src/channels.cpp b/src/channels.cpp index 4286abfef..84fa61b5a 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -232,7 +232,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (user->chans.size() >= user->GetMaxChans()) { - user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick, cn); + user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick.c_str(), cn); return NULL; } } @@ -242,7 +242,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (user->chans.size() >= Instance->Config->OperMaxChans) { - user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick, cn); + user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick.c_str(), cn); return NULL; } } @@ -250,7 +250,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (user->chans.size() >= Instance->Config->MaxChans) { - user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick, cn); + user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick.c_str(), cn); return NULL; } } @@ -268,7 +268,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool if (!IS_LOCAL(user)) { if (!TS) - Instance->Logs->Log("CHANNEL",DEBUG,"*** BUG *** Channel::JoinUser called for REMOTE user '%s' on channel '%s' but no TS given!", user->nick, cn); + Instance->Logs->Log("CHANNEL",DEBUG,"*** BUG *** Channel::JoinUser called for REMOTE user '%s' on channel '%s' but no TS given!", user->nick.c_str(), cn); } else { @@ -313,7 +313,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if ((!key) || strcmp(key,Ptr->key)) { - user->WriteNumeric(475, "%s %s :Cannot join channel (Incorrect channel key)",user->nick, Ptr->name); + user->WriteNumeric(475, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), Ptr->name); return NULL; } } @@ -326,7 +326,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (!user->IsInvited(Ptr->name)) { - user->WriteNumeric(473, "%s %s :Cannot join channel (Invite only)",user->nick, Ptr->name); + user->WriteNumeric(473, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), Ptr->name); return NULL; } } @@ -340,7 +340,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (Ptr->GetUserCounter() >= Ptr->limit) { - user->WriteNumeric(471, "%s %s :Cannot join channel (Channel is full)",user->nick, Ptr->name); + user->WriteNumeric(471, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), Ptr->name); return NULL; } } @@ -349,7 +349,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (Ptr->IsBanned(user)) { - user->WriteNumeric(474, "%s %s :Cannot join channel (You're banned)",user->nick, Ptr->name); + user->WriteNumeric(474, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name); return NULL; } } @@ -419,8 +419,8 @@ Channel* Channel::ForceChan(InspIRCd* Instance, Channel* Ptr, User* user, const { if (Ptr->topicset) { - user->WriteNumeric(332, "%s %s :%s", user->nick, Ptr->name, Ptr->topic); - user->WriteNumeric(333, "%s %s %s %lu", user->nick, Ptr->name, Ptr->setby, (unsigned long)Ptr->topicset); + user->WriteNumeric(332, "%s %s :%s", user->nick.c_str(), Ptr->name, Ptr->topic); + user->WriteNumeric(333, "%s %s %s %lu", user->nick.c_str(), Ptr->name, Ptr->setby, (unsigned long)Ptr->topicset); } Ptr->UserList(user); } @@ -438,7 +438,7 @@ bool Channel::IsBanned(User* user) return true; else if (MOD_RESULT == 0) { - snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString()); + snprintf(mask, MAXBUF, "%s!%s@%s", user->nick.c_str(), user->ident.c_str(), user->GetIPString()); for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++) { /* This allows CIDR ban matching @@ -460,7 +460,7 @@ bool Channel::IsExtBanned(User *user, char type) char mask[MAXBUF]; char *maskptr; - snprintf(mask, MAXBUF, "%s!%s@%s", user->nick, user->ident, user->GetIPString()); + snprintf(mask, MAXBUF, "%s!%s@%s", user->nick.c_str(), user->ident.c_str(), user->GetIPString()); for (BanList::iterator i = this->bans.begin(); i != this->bans.end(); i++) { @@ -555,7 +555,7 @@ long Channel::ServerKickUser(User* user, const char* reason, bool triggerevents, if (i != user->chans.end()) { if (!silent) - this->WriteChannelWithServ(servername, "KICK %s %s :%s", this->name, user->nick, reason); + this->WriteChannelWithServ(servername, "KICK %s %s :%s", this->name, user->nick.c_str(), reason); user->chans.erase(i); this->RemoveAllPrefixes(user); @@ -591,12 +591,12 @@ long Channel::KickUser(User *src, User *user, const char* reason) { if (!this->HasUser(user)) { - src->WriteNumeric(441, "%s %s %s :They are not on that channel",src->nick, user->nick, this->name); + src->WriteNumeric(441, "%s %s %s :They are not on that channel",src->nick.c_str(), user->nick.c_str(), this->name); return this->GetUserCounter(); } if ((ServerInstance->ULine(user->server)) && (!ServerInstance->ULine(src->server))) { - src->WriteNumeric(482, "%s %s :Only a u-line may kick a u-line from a channel.",src->nick, this->name); + src->WriteNumeric(482, "%s %s :Only a u-line may kick a u-line from a channel.",src->nick.c_str(), this->name); return this->GetUserCounter(); } int MOD_RESULT = 0; @@ -621,7 +621,7 @@ long Channel::KickUser(User *src, User *user, const char* reason) int us = this->GetStatus(user); if ((them < STATUS_HOP) || (them < us)) { - src->WriteNumeric(482, "%s %s :You must be a channel %soperator",src->nick, this->name, them == STATUS_HOP ? "" : "half-"); + src->WriteNumeric(482, "%s %s :You must be a channel %soperator",src->nick.c_str(), this->name, them == STATUS_HOP ? "" : "half-"); return this->GetUserCounter(); } } @@ -635,7 +635,7 @@ long Channel::KickUser(User *src, User *user, const char* reason) { /* zap it from the channel list of the user */ if (!silent) - this->WriteChannel(src, "KICK %s %s :%s", this->name, user->nick, reason); + this->WriteChannel(src, "KICK %s %s :%s", this->name, user->nick.c_str(), reason); user->chans.erase(i); this->RemoveAllPrefixes(user); @@ -685,7 +685,7 @@ void Channel::WriteChannel(User* user, const std::string &text) if (!user) return; - snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str()); + snprintf(tb,MAXBUF,":%s %s",user->GetFullHost().c_str(),text.c_str()); std::string out = tb; for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) @@ -762,7 +762,7 @@ void Channel::WriteAllExcept(User* user, bool serversource, char status, CUList CUList *ulist = this->GetUsers(); char tb[MAXBUF]; - snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str()); + snprintf(tb,MAXBUF,":%s %s",user->GetFullHost().c_str(),text.c_str()); std::string out = tb; for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) @@ -877,12 +877,12 @@ void Channel::UserList(User *user, CUList *ulist) { if ((this->IsModeSet('s')) && (!this->HasUser(user))) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, this->name); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), this->name); return; } } - dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick, this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name); + dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick.c_str(), this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name); int numusers = 0; char* ptr = list + dlen; @@ -929,7 +929,7 @@ void Channel::UserList(User *user, CUList *ulist) user->WriteServ(std::string(list)); /* reset our lengths */ - dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick, this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name); + dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick.c_str(), this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name); ptr = list + dlen; ptrlen = 0; @@ -950,7 +950,7 @@ void Channel::UserList(User *user, CUList *ulist) user->WriteNumeric(353,std::string(list)); } - user->WriteNumeric(366, "%s %s :End of /NAMES list.", user->nick, this->name); + user->WriteNumeric(366, "%s %s :End of /NAMES list.", user->nick.c_str(), this->name); } long Channel::GetMaxBans() diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 4c9701645..887ef0551 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -294,7 +294,7 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd) { if (user->registered == REG_ALL) { - user->WriteNumeric(421, "%s %s :Unknown command",user->nick,command.c_str()); + user->WriteNumeric(421, "%s %s :Unknown command",user->nick.c_str(),command.c_str()); } ServerInstance->stats->statsUnknown++; return true; @@ -318,28 +318,28 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd) { if (!user->IsModeSet(cm->second->flags_needed)) { - user->WriteNumeric(481, "%s :Permission Denied - You do not have the required operator privileges",user->nick); + user->WriteNumeric(481, "%s :Permission Denied - You do not have the required operator privileges",user->nick.c_str()); return do_more; } if (!user->HasPermission(command)) { - user->WriteNumeric(481, "%s :Permission Denied - Oper type %s does not have access to command %s",user->nick,user->oper,command.c_str()); + user->WriteNumeric(481, "%s :Permission Denied - Oper type %s does not have access to command %s",user->nick.c_str(),user->oper.c_str(),command.c_str()); return do_more; } } if ((user->registered == REG_ALL) && (!IS_OPER(user)) && (cm->second->IsDisabled())) { /* command is disabled! */ - user->WriteNumeric(421, "%s %s :This command has been disabled.",user->nick,command.c_str()); + user->WriteNumeric(421, "%s %s :This command has been disabled.",user->nick.c_str(),command.c_str()); ServerInstance->SNO->WriteToSnoMask('d', "%s denied for %s (%s@%s)", - command.c_str(), user->nick, user->ident, user->host); + command.c_str(), user->nick.c_str(), user->ident.c_str(), user->host); return do_more; } if (command_p.size() < cm->second->min_params) { - user->WriteNumeric(461, "%s %s :Not enough parameters.", user->nick, command.c_str()); + user->WriteNumeric(461, "%s %s :Not enough parameters.", user->nick.c_str(), command.c_str()); if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (cm->second->syntax.length())) - user->WriteNumeric(304, "%s :SYNTAX %s %s", user->nick, cm->second->command.c_str(), cm->second->syntax.c_str()); + user->WriteNumeric(304, "%s :SYNTAX %s %s", user->nick.c_str(), cm->second->command.c_str(), cm->second->syntax.c_str()); return do_more; } if ((user->registered != REG_ALL) && (!cm->second->WorksBeforeReg())) @@ -404,7 +404,7 @@ bool CommandParser::ProcessBuffer(std::string &buffer,User *user) if (buffer.length()) { - ServerInstance->Logs->Log("USERINPUT", DEBUG,"C[%d] I :%s %s",user->GetFd(), user->nick, buffer.c_str()); + ServerInstance->Logs->Log("USERINPUT", DEBUG,"C[%d] I :%s %s",user->GetFd(), user->nick.c_str(), buffer.c_str()); return this->ProcessCommand(user,buffer); } @@ -472,7 +472,7 @@ bool CommandParser::ReloadCommand(std::string cmd, User* user) if (err) { if (user) - user->WriteServ("NOTICE %s :*** Error loading 'cmd_%s.so': %s", user->nick, cmd.c_str(), err); + user->WriteServ("NOTICE %s :*** Error loading 'cmd_%s.so': %s", user->nick.c_str(), cmd.c_str(), err); return false; } @@ -487,16 +487,16 @@ CmdResult cmd_reload::Handle(const std::vector<std::string>& parameters, User *u if (parameters.size() < 1) return CMD_FAILURE; - user->WriteServ("NOTICE %s :*** Reloading command '%s'",user->nick, parameters[0].c_str()); + user->WriteServ("NOTICE %s :*** Reloading command '%s'",user->nick.c_str(), parameters[0].c_str()); if (ServerInstance->Parser->ReloadCommand(parameters[0], user)) { - user->WriteServ("NOTICE %s :*** Successfully reloaded command '%s'", user->nick, parameters[0].c_str()); - ServerInstance->SNO->WriteToSnoMask('A', "RELOAD: %s reloaded the '%s' command.", user->nick, parameters[0].c_str()); + user->WriteServ("NOTICE %s :*** Successfully reloaded command '%s'", user->nick.c_str(), parameters[0].c_str()); + ServerInstance->SNO->WriteToSnoMask('A', "RELOAD: %s reloaded the '%s' command.", user->nick.c_str(), parameters[0].c_str()); return CMD_SUCCESS; } else { - user->WriteServ("NOTICE %s :*** Could not reload command '%s' -- fix this problem, then /REHASH as soon as possible!", user->nick, parameters[0].c_str()); + user->WriteServ("NOTICE %s :*** Could not reload command '%s' -- fix this problem, then /REHASH as soon as possible!", user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } } @@ -560,7 +560,7 @@ void CommandParser::SetupCommandTable(User* user) { if (user) { - user->WriteServ("NOTICE %s :*** Failed to load core command %s: %s", user->nick, entry->d_name, err); + user->WriteServ("NOTICE %s :*** Failed to load core command %s: %s", user->nick.c_str(), entry->d_name, err); } else { diff --git a/src/commands.cpp b/src/commands.cpp index 53008eb54..382783c71 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -45,7 +45,7 @@ bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user) float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100; if (percent > (float)atof(itrigger)) { - SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a G/K/E line mask of %s, which covers %.2f%% of the network!",user->nick,mask.c_str(),percent); + SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a G/K/E line mask of %s, which covers %.2f%% of the network!",user->nick.c_str(),mask.c_str(),percent); return true; } return false; @@ -74,7 +74,7 @@ bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user) float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100; if (percent > (float)atof(itrigger)) { - SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick,ip.c_str(),percent); + SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick.c_str(),ip.c_str(),percent); return true; } return false; @@ -103,7 +103,7 @@ bool InspIRCd::NickMatchesEveryone(const std::string &nick, User* user) float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100; if (percent > (float)atof(itrigger)) { - SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick,nick.c_str(),percent); + SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick.c_str(),nick.c_str(),percent); return true; } return false; diff --git a/src/commands/cmd_admin.cpp b/src/commands/cmd_admin.cpp index 5e9b4b4c7..327b675ad 100644 --- a/src/commands/cmd_admin.cpp +++ b/src/commands/cmd_admin.cpp @@ -24,10 +24,10 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) */ CmdResult CommandAdmin::Handle (const std::vector<std::string>& parameters, User *user) { - user->WriteNumeric(256, "%s :Administrative info for %s",user->nick,ServerInstance->Config->ServerName); + user->WriteNumeric(256, "%s :Administrative info for %s",user->nick.c_str(),ServerInstance->Config->ServerName); if (*ServerInstance->Config->AdminName) - user->WriteNumeric(257, "%s :Name - %s",user->nick,ServerInstance->Config->AdminName); - user->WriteNumeric(258, "%s :Nickname - %s",user->nick,ServerInstance->Config->AdminNick); - user->WriteNumeric(259, "%s :E-Mail - %s",user->nick,ServerInstance->Config->AdminEmail); + user->WriteNumeric(257, "%s :Name - %s",user->nick.c_str(),ServerInstance->Config->AdminName); + user->WriteNumeric(258, "%s :Nickname - %s",user->nick.c_str(),ServerInstance->Config->AdminNick); + user->WriteNumeric(259, "%s :E-Mail - %s",user->nick.c_str(),ServerInstance->Config->AdminEmail); return CMD_SUCCESS; } diff --git a/src/commands/cmd_away.cpp b/src/commands/cmd_away.cpp index 7d2522304..7fac7ae6d 100644 --- a/src/commands/cmd_away.cpp +++ b/src/commands/cmd_away.cpp @@ -33,9 +33,9 @@ CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User return CMD_FAILURE; user->awaytime = ServerInstance->Time(); - strlcpy(user->awaymsg, parameters[0].c_str(), MAXAWAY); + user->awaymsg.assign(parameters[0], 0, MAXAWAY); - user->WriteNumeric(306, "%s :You have been marked as being away",user->nick); + user->WriteNumeric(306, "%s :You have been marked as being away",user->nick.c_str()); } else { @@ -44,8 +44,8 @@ CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User if (MOD_RESULT != 0 && !IS_LOCAL(user)) return CMD_FAILURE; - *user->awaymsg = 0; - user->WriteNumeric(305, "%s :You are no longer marked as being away",user->nick); + user->awaymsg.empty(); + user->WriteNumeric(305, "%s :You are no longer marked as being away",user->nick.c_str()); } return CMD_SUCCESS; diff --git a/src/commands/cmd_clearcache.cpp b/src/commands/cmd_clearcache.cpp index 5f1792928..aa0ef2c34 100644 --- a/src/commands/cmd_clearcache.cpp +++ b/src/commands/cmd_clearcache.cpp @@ -24,6 +24,6 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) CmdResult CommandClearcache::Handle (const std::vector<std::string>& parameters, User *user) { int n = ServerInstance->Res->ClearCache(); - user->WriteServ("NOTICE %s :*** Cleared DNS cache of %d items.", user->nick, n); + user->WriteServ("NOTICE %s :*** Cleared DNS cache of %d items.", user->nick.c_str(), n); return CMD_SUCCESS; } diff --git a/src/commands/cmd_commands.cpp b/src/commands/cmd_commands.cpp index eddcb6bd8..3f8542aa2 100644 --- a/src/commands/cmd_commands.cpp +++ b/src/commands/cmd_commands.cpp @@ -26,12 +26,12 @@ CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user) for (Commandable::iterator i = ServerInstance->Parser->cmdlist.begin(); i != ServerInstance->Parser->cmdlist.end(); i++) { user->WriteNumeric(702, "%s :%s %s %d %d", - user->nick, + user->nick.c_str(), i->second->command.c_str(), i->second->source.c_str(), i->second->min_params, i->second->Penalty); } - user->WriteNumeric(704, "%s :End of COMMANDS list",user->nick); + user->WriteNumeric(704, "%s :End of COMMANDS list",user->nick.c_str()); return CMD_SUCCESS; } diff --git a/src/commands/cmd_connect.cpp b/src/commands/cmd_connect.cpp index 81340c37a..0aed872e9 100644 --- a/src/commands/cmd_connect.cpp +++ b/src/commands/cmd_connect.cpp @@ -27,6 +27,6 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) */ CmdResult CommandConnect::Handle (const std::vector<std::string>&, User *user) { - user->WriteServ( "NOTICE %s :Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.", user->nick); + user->WriteServ( "NOTICE %s :Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.", user->nick.c_str()); return CMD_SUCCESS; } diff --git a/src/commands/cmd_die.cpp b/src/commands/cmd_die.cpp index 4278a3a90..342910094 100644 --- a/src/commands/cmd_die.cpp +++ b/src/commands/cmd_die.cpp @@ -39,8 +39,8 @@ CmdResult CommandDie::Handle (const std::vector<std::string>& parameters, User * } else { - ServerInstance->Logs->Log("COMMAND",SPARSE, "Failed /DIE command from %s!%s@%s", user->nick, user->ident, user->host); - ServerInstance->SNO->WriteToSnoMask('A', "Failed DIE Command from %s!%s@%s.",user->nick,user->ident,user->host); + ServerInstance->Logs->Log("COMMAND",SPARSE, "Failed /DIE command from %s!%s@%s", user->nick.c_str(), user->ident.c_str(), user->host); + ServerInstance->SNO->WriteToSnoMask('A', "Failed DIE Command from %s!%s@%s.",user->nick.c_str(),user->ident.c_str(),user->host); return CMD_FAILURE; } return CMD_SUCCESS; diff --git a/src/commands/cmd_eline.cpp b/src/commands/cmd_eline.cpp index 57f0e193c..4f26ace42 100644 --- a/src/commands/cmd_eline.cpp +++ b/src/commands/cmd_eline.cpp @@ -41,7 +41,7 @@ CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User if (ih.first.empty()) { - user->WriteServ("NOTICE %s :*** Target not found", user->nick); + user->WriteServ("NOTICE %s :*** Target not found", user->nick.c_str()); return CMD_FAILURE; } @@ -50,35 +50,35 @@ CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User long duration = ServerInstance->Duration(parameters[1].c_str()); - ELine* el = new ELine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2].c_str(), ih.first.c_str(), ih.second.c_str()); + ELine* el = new ELine(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ih.first.c_str(), ih.second.c_str()); if (ServerInstance->XLines->AddLine(el, user)) { if (!duration) { - ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent E-line for %s.",user->nick,target.c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent E-line for %s.",user->nick.c_str(),target.c_str()); } else { time_t c_requires_crap = duration + ServerInstance->Time(); - ServerInstance->SNO->WriteToSnoMask('x',"%s added timed E-line for %s, expires on %s",user->nick,target.c_str(), + ServerInstance->SNO->WriteToSnoMask('x',"%s added timed E-line for %s, expires on %s",user->nick.c_str(),target.c_str(), ServerInstance->TimeString(c_requires_crap).c_str()); } } else { delete el; - user->WriteServ("NOTICE %s :*** E-Line for %s already exists",user->nick,target.c_str()); + user->WriteServ("NOTICE %s :*** E-Line for %s already exists",user->nick.c_str(),target.c_str()); } } else { if (ServerInstance->XLines->DelLine(target.c_str(), "E", user)) { - ServerInstance->SNO->WriteToSnoMask('x',"%s Removed E-line on %s.",user->nick,target.c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s Removed E-line on %s.",user->nick.c_str(),target.c_str()); } else { - user->WriteServ("NOTICE %s :*** E-Line %s not found in list, try /stats e.",user->nick,target.c_str()); + user->WriteServ("NOTICE %s :*** E-Line %s not found in list, try /stats e.",user->nick.c_str(),target.c_str()); } } diff --git a/src/commands/cmd_gline.cpp b/src/commands/cmd_gline.cpp index d2a1f69d6..a10056410 100644 --- a/src/commands/cmd_gline.cpp +++ b/src/commands/cmd_gline.cpp @@ -41,7 +41,7 @@ CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User if (ih.first.empty()) { - user->WriteServ("NOTICE %s :*** Target not found", user->nick); + user->WriteServ("NOTICE %s :*** Target not found", user->nick.c_str()); return CMD_FAILURE; } @@ -50,22 +50,22 @@ CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User else if (target.find('!') != std::string::npos) { - user->WriteServ("NOTICE %s :*** G-Line cannot operate on nick!user@host masks",user->nick); + user->WriteServ("NOTICE %s :*** G-Line cannot operate on nick!user@host masks",user->nick.c_str()); return CMD_FAILURE; } long duration = ServerInstance->Duration(parameters[1].c_str()); - GLine* gl = new GLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2].c_str(), ih.first.c_str(), ih.second.c_str()); + GLine* gl = new GLine(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ih.first.c_str(), ih.second.c_str()); if (ServerInstance->XLines->AddLine(gl, user)) { if (!duration) { - ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent G-line for %s.",user->nick,target.c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent G-line for %s.",user->nick.c_str(),target.c_str()); } else { time_t c_requires_crap = duration + ServerInstance->Time(); - ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires on %s",user->nick,target.c_str(), + ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires on %s",user->nick.c_str(),target.c_str(), ServerInstance->TimeString(c_requires_crap).c_str()); } @@ -74,7 +74,7 @@ CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User else { delete gl; - user->WriteServ("NOTICE %s :*** G-Line for %s already exists",user->nick,target.c_str()); + user->WriteServ("NOTICE %s :*** G-Line for %s already exists",user->nick.c_str(),target.c_str()); } } @@ -82,11 +82,11 @@ CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User { if (ServerInstance->XLines->DelLine(target.c_str(),"G",user)) { - ServerInstance->SNO->WriteToSnoMask('x',"%s Removed G-line on %s.",user->nick,target.c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s Removed G-line on %s.",user->nick.c_str(),target.c_str()); } else { - user->WriteServ("NOTICE %s :*** G-line %s not found in list, try /stats g.",user->nick,target.c_str()); + user->WriteServ("NOTICE %s :*** G-line %s not found in list, try /stats g.",user->nick.c_str(),target.c_str()); } } diff --git a/src/commands/cmd_info.cpp b/src/commands/cmd_info.cpp index 346168960..517153948 100644 --- a/src/commands/cmd_info.cpp +++ b/src/commands/cmd_info.cpp @@ -23,38 +23,38 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) */ CmdResult CommandInfo::Handle (const std::vector<std::string>&, User *user) { - user->WriteServ( "371 %s : -/\\- \2InspIRCd\2 -\\/-", user->nick); - user->WriteServ( "371 %s : November 2002 - Present", user->nick); - user->WriteServ( "371 %s : ", user->nick); - user->WriteServ( "371 %s :\2Core Developers\2:", user->nick); - user->WriteServ( "371 %s : Craig Edwards, Brain, <brain@inspircd.org>", user->nick); - user->WriteServ( "371 %s : Craig McLure, Craig, <craig@inspircd.org>", user->nick); - user->WriteServ( "371 %s : Robin Burchell, w00t, <w00t@inspircd.org>", user->nick); - user->WriteServ( "371 %s : Oliver Lupton, Om, <om@inspircd.org>", user->nick); - user->WriteServ( "371 %s : John Brooks, Special, <special@inspircd.org>", user->nick); - user->WriteServ( "371 %s : Pippijn van Steenhoven, pippijn, <pippijn@one09.net>", user->nick); - user->WriteServ( "371 %s : Dennis Friis, peavey, <peavey@inspircd.org>", user->nick); - user->WriteServ( "371 %s : Thomas Stagner, aquanight, <aquanight@inspircd.org>", user->nick); - user->WriteServ( "371 %s : Eric Dietz, fez, <fez@inspircd.org>", user->nick); - user->WriteServ( "371 %s : ", user->nick); - user->WriteServ( "371 %s :\2Regular Contributors\2:", user->nick); - user->WriteServ( "371 %s : satmd nenolod John2 Skip", user->nick); - user->WriteServ( "371 %s : jilles Majic eggy Trystan", user->nick); - user->WriteServ( "371 %s : Quension danieldg praetorian", user->nick); - user->WriteServ( "371 %s : GreenReaper searchirc.com irc-junkie.org", user->nick); - user->WriteServ( "371 %s : ", user->nick); - user->WriteServ( "371 %s :\2Other Contributors\2:", user->nick); - user->WriteServ( "371 %s : dmb Zaba skenmy LeaChim", user->nick); - user->WriteServ( "371 %s : Thunderhacker Dan Jason owine", user->nick); - user->WriteServ( "371 %s : Adremelech dz BuildSmart HiroP", user->nick); - user->WriteServ( "371 %s : ThaPrince Bricker AnMaster djGrrr", user->nick); - user->WriteServ( "371 %s : ", user->nick); - user->WriteServ( "371 %s :\2Former Contributors\2:", user->nick); - user->WriteServ( "371 %s : CC jamie typobox43 Burlex (win32)", user->nick); - user->WriteServ( "371 %s : Stskeeps ", user->nick); - user->WriteServ( "371 %s : ", user->nick); - user->WriteServ( "371 %s : Best experienced with: \2An IRC client\2", user->nick); + user->WriteServ( "371 %s : -/\\- \2InspIRCd\2 -\\/-", user->nick.c_str()); + user->WriteServ( "371 %s : November 2002 - Present", user->nick.c_str()); + user->WriteServ( "371 %s : ", user->nick.c_str()); + user->WriteServ( "371 %s :\2Core Developers\2:", user->nick.c_str()); + user->WriteServ( "371 %s : Craig Edwards, Brain, <brain@inspircd.org>", user->nick.c_str()); + user->WriteServ( "371 %s : Craig McLure, Craig, <craig@inspircd.org>", user->nick.c_str()); + user->WriteServ( "371 %s : Robin Burchell, w00t, <w00t@inspircd.org>", user->nick.c_str()); + user->WriteServ( "371 %s : Oliver Lupton, Om, <om@inspircd.org>", user->nick.c_str()); + user->WriteServ( "371 %s : John Brooks, Special, <special@inspircd.org>", user->nick.c_str()); + user->WriteServ( "371 %s : Pippijn van Steenhoven, pippijn, <pippijn@one09.net>", user->nick.c_str()); + user->WriteServ( "371 %s : Dennis Friis, peavey, <peavey@inspircd.org>", user->nick.c_str()); + user->WriteServ( "371 %s : Thomas Stagner, aquanight, <aquanight@inspircd.org>", user->nick.c_str()); + user->WriteServ( "371 %s : Eric Dietz, fez, <fez@inspircd.org>", user->nick.c_str()); + user->WriteServ( "371 %s : ", user->nick.c_str()); + user->WriteServ( "371 %s :\2Regular Contributors\2:", user->nick.c_str()); + user->WriteServ( "371 %s : satmd nenolod John2 Skip", user->nick.c_str()); + user->WriteServ( "371 %s : jilles Majic eggy Trystan", user->nick.c_str()); + user->WriteServ( "371 %s : Quension danieldg praetorian", user->nick.c_str()); + user->WriteServ( "371 %s : GreenReaper searchirc.com irc-junkie.org", user->nick.c_str()); + user->WriteServ( "371 %s : ", user->nick.c_str()); + user->WriteServ( "371 %s :\2Other Contributors\2:", user->nick.c_str()); + user->WriteServ( "371 %s : dmb Zaba skenmy LeaChim", user->nick.c_str()); + user->WriteServ( "371 %s : Thunderhacker Dan Jason owine", user->nick.c_str()); + user->WriteServ( "371 %s : Adremelech dz BuildSmart HiroP", user->nick.c_str()); + user->WriteServ( "371 %s : ThaPrince Bricker AnMaster djGrrr", user->nick.c_str()); + user->WriteServ( "371 %s : ", user->nick.c_str()); + user->WriteServ( "371 %s :\2Former Contributors\2:", user->nick.c_str()); + user->WriteServ( "371 %s : CC jamie typobox43 Burlex (win32)", user->nick.c_str()); + user->WriteServ( "371 %s : Stskeeps ", user->nick.c_str()); + user->WriteServ( "371 %s : ", user->nick.c_str()); + user->WriteServ( "371 %s : Best experienced with: \2An IRC client\2", user->nick.c_str()); FOREACH_MOD(I_OnInfo,OnInfo(user)); - user->WriteServ( "374 %s :End of /INFO list", user->nick); + user->WriteServ( "374 %s :End of /INFO list", user->nick.c_str()); return CMD_SUCCESS; } diff --git a/src/commands/cmd_invite.cpp b/src/commands/cmd_invite.cpp index db1c64eac..1455e94e7 100644 --- a/src/commands/cmd_invite.cpp +++ b/src/commands/cmd_invite.cpp @@ -37,7 +37,7 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use if ((!c) || (!u)) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, c ? parameters[0].c_str() : parameters[1].c_str()); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c ? parameters[0].c_str() : parameters[1].c_str()); return CMD_FAILURE; } @@ -45,20 +45,20 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use { if (c->GetStatus(user) < STATUS_HOP) { - user->WriteNumeric(482, "%s %s :You must be a channel %soperator", user->nick, c->name, c->GetStatus(u) == STATUS_HOP ? "" : "half-"); + user->WriteNumeric(482, "%s %s :You must be a channel %soperator", user->nick.c_str(), c->name, c->GetStatus(u) == STATUS_HOP ? "" : "half-"); return CMD_FAILURE; } } if (c->HasUser(u)) { - user->WriteNumeric(443, "%s %s %s :is already on channel",user->nick,u->nick,c->name); + user->WriteNumeric(443, "%s %s %s :is already on channel",user->nick.c_str(),u->nick.c_str(),c->name); return CMD_FAILURE; } if ((IS_LOCAL(user)) && (!c->HasUser(user))) { - user->WriteNumeric(442, "%s %s :You're not on that channel!",user->nick, c->name); + user->WriteNumeric(442, "%s %s :You're not on that channel!",user->nick.c_str(), c->name); return CMD_FAILURE; } @@ -70,21 +70,21 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use } u->InviteTo(c->name, timeout); - u->WriteFrom(user,"INVITE %s :%s",u->nick,c->name); - user->WriteNumeric(341, "%s %s %s",user->nick,u->nick,c->name); + u->WriteFrom(user,"INVITE %s :%s",u->nick.c_str(),c->name); + user->WriteNumeric(341, "%s %s %s",user->nick.c_str(),u->nick.c_str(),c->name); switch (ServerInstance->Config->AnnounceInvites) { case ServerConfig::INVITE_ANNOUNCE_ALL: - c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick); + c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick.c_str(), u->nick.c_str()); break; case ServerConfig::INVITE_ANNOUNCE_OPS: - c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick); + c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick.c_str(), u->nick.c_str()); break; case ServerConfig::INVITE_ANNOUNCE_DYNAMIC: if (c->IsModeSet('i')) - c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick); + c->WriteAllExceptSender(user, true, '@', "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick.c_str(), u->nick.c_str()); else - c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick, u->nick); + c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :*** %s invited %s into the channel", c->name, user->nick.c_str(), u->nick.c_str()); break; default: /* Nobody */ @@ -99,9 +99,9 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use InvitedList* il = user->GetInviteList(); for (InvitedList::iterator i = il->begin(); i != il->end(); i++) { - user->WriteNumeric(346, "%s :%s",user->nick,i->first.c_str()); + user->WriteNumeric(346, "%s :%s",user->nick.c_str(),i->first.c_str()); } - user->WriteNumeric(347, "%s :End of INVITE list",user->nick); + user->WriteNumeric(347, "%s :End of INVITE list",user->nick.c_str()); } return CMD_SUCCESS; } diff --git a/src/commands/cmd_join.cpp b/src/commands/cmd_join.cpp index e7c841399..b27007507 100644 --- a/src/commands/cmd_join.cpp +++ b/src/commands/cmd_join.cpp @@ -46,6 +46,6 @@ CmdResult CommandJoin::Handle (const std::vector<std::string>& parameters, User } } - user->WriteNumeric(403, "%s %s :Invalid channel name",user->nick, parameters[0].c_str()); + user->WriteNumeric(403, "%s %s :Invalid channel name",user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_kick.cpp b/src/commands/cmd_kick.cpp index 99859b413..174800cf5 100644 --- a/src/commands/cmd_kick.cpp +++ b/src/commands/cmd_kick.cpp @@ -32,13 +32,13 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User if (!u || !c) { - user->WriteServ( "401 %s %s :No such nick/channel", user->nick, u ? parameters[0].c_str() : parameters[1].c_str()); + user->WriteServ( "401 %s %s :No such nick/channel", user->nick.c_str(), u ? parameters[0].c_str() : parameters[1].c_str()); return CMD_FAILURE; } if ((IS_LOCAL(user)) && (!c->HasUser(user)) && (!ServerInstance->ULine(user->server))) { - user->WriteServ( "442 %s %s :You're not on that channel!", user->nick, parameters[0].c_str()); + user->WriteServ( "442 %s %s :You're not on that channel!", user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } @@ -48,7 +48,7 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User } else { - strlcpy(reason, user->nick, MAXKICK - 1); + strlcpy(reason, user->nick.c_str(), MAXKICK - 1); } if (!c->KickUser(user, u, reason)) diff --git a/src/commands/cmd_kill.cpp b/src/commands/cmd_kill.cpp index 7e77aa5a1..48e1ac84e 100644 --- a/src/commands/cmd_kill.cpp +++ b/src/commands/cmd_kill.cpp @@ -59,7 +59,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User else { // hidekills is off, do nothing - snprintf(killreason, MAXQUIT, "Killed (%s (%s))", user->nick, parameters[1].c_str()); + snprintf(killreason, MAXQUIT, "Killed (%s (%s))", user->nick.c_str(), parameters[1].c_str()); } } else @@ -75,7 +75,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User if (!IS_LOCAL(u)) { // remote kill - ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1].c_str()); + ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s!%s@%s (%s)", user->nick.c_str(), u->nick.c_str(), u->ident.c_str(), u->host, parameters[1].c_str()); FOREACH_MOD(I_OnRemoteKill, OnRemoteKill(user, u, killreason, killreason)); } else @@ -85,18 +85,18 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User * XXX - this isn't entirely correct, servers A - B - C, oper on A, client on C. Oper kills client, A and B will get remote kill * snotices, C will get a local kill snotice. this isn't accurate, and needs fixing at some stage. -- w00t */ - ServerInstance->SNO->WriteToSnoMask('k',"Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1].c_str()); - ServerInstance->Logs->Log("KILL",DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1].c_str()); + ServerInstance->SNO->WriteToSnoMask('k',"Local Kill by %s: %s!%s@%s (%s)", user->nick.c_str(), u->nick.c_str(), u->ident.c_str(), u->host, parameters[1].c_str()); + ServerInstance->Logs->Log("KILL",DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick.c_str(), ServerInstance->Config->ServerName, user->dhost.c_str(), user->nick.c_str(), parameters[1].c_str()); /* Bug #419, make sure this message can only occur once even in the case of multiple KILL messages crossing the network, and change to show * hidekillsserver as source if possible */ if (!u->quitting) { - u->Write(":%s KILL %s :%s!%s!%s (%s)", *ServerInstance->Config->HideKillsServer ? ServerInstance->Config->HideKillsServer : user->GetFullHost(), - u->nick, + u->Write(":%s KILL %s :%s!%s!%s (%s)", *ServerInstance->Config->HideKillsServer ? ServerInstance->Config->HideKillsServer : user->GetFullHost().c_str(), + u->nick.c_str(), ServerInstance->Config->ServerName, - user->dhost, - *ServerInstance->Config->HideKillsServer ? ServerInstance->Config->HideKillsServer : user->nick, + user->dhost.c_str(), + *ServerInstance->Config->HideKillsServer ? ServerInstance->Config->HideKillsServer : user->nick.c_str(), parameters[1].c_str()); } } @@ -106,7 +106,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User } else { - user->WriteServ( "401 %s %s :No such nick/channel", user->nick, parameters[0].c_str()); + user->WriteServ( "401 %s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_kline.cpp b/src/commands/cmd_kline.cpp index ddf5d218b..95e24a7ea 100644 --- a/src/commands/cmd_kline.cpp +++ b/src/commands/cmd_kline.cpp @@ -41,7 +41,7 @@ CmdResult CommandKline::Handle (const std::vector<std::string>& parameters, User if (ih.first.empty()) { - user->WriteServ("NOTICE %s :*** Target not found", user->nick); + user->WriteServ("NOTICE %s :*** Target not found", user->nick.c_str()); return CMD_FAILURE; } @@ -50,22 +50,22 @@ CmdResult CommandKline::Handle (const std::vector<std::string>& parameters, User if (target.find('!') != std::string::npos) { - user->WriteServ("NOTICE %s :*** K-Line cannot operate on nick!user@host masks",user->nick); + user->WriteServ("NOTICE %s :*** K-Line cannot operate on nick!user@host masks",user->nick.c_str()); return CMD_FAILURE; } long duration = ServerInstance->Duration(parameters[1].c_str()); - KLine* kl = new KLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2].c_str(), ih.first.c_str(), ih.second.c_str()); + KLine* kl = new KLine(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ih.first.c_str(), ih.second.c_str()); if (ServerInstance->XLines->AddLine(kl,user)) { if (!duration) { - ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent K-line for %s.",user->nick,target.c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent K-line for %s.",user->nick.c_str(),target.c_str()); } else { time_t c_requires_crap = duration + ServerInstance->Time(); - ServerInstance->SNO->WriteToSnoMask('x',"%s added timed K-line for %s, expires on %s",user->nick,target.c_str(), + ServerInstance->SNO->WriteToSnoMask('x',"%s added timed K-line for %s, expires on %s",user->nick.c_str(),target.c_str(), ServerInstance->TimeString(c_requires_crap).c_str()); } @@ -74,18 +74,18 @@ CmdResult CommandKline::Handle (const std::vector<std::string>& parameters, User else { delete kl; - user->WriteServ("NOTICE %s :*** K-Line for %s already exists",user->nick,target.c_str()); + user->WriteServ("NOTICE %s :*** K-Line for %s already exists",user->nick.c_str(),target.c_str()); } } else { if (ServerInstance->XLines->DelLine(target.c_str(),"K",user)) { - ServerInstance->SNO->WriteToSnoMask('x',"%s Removed K-line on %s.",user->nick,target.c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s Removed K-line on %s.",user->nick.c_str(),target.c_str()); } else { - user->WriteServ("NOTICE %s :*** K-Line %s not found in list, try /stats k.",user->nick,target.c_str()); + user->WriteServ("NOTICE %s :*** K-Line %s not found in list, try /stats k.",user->nick.c_str(),target.c_str()); } } diff --git a/src/commands/cmd_links.cpp b/src/commands/cmd_links.cpp index 554e6d962..988e50be2 100644 --- a/src/commands/cmd_links.cpp +++ b/src/commands/cmd_links.cpp @@ -23,7 +23,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) */ CmdResult CommandLinks::Handle (const std::vector<std::string>&, User *user) { - user->WriteNumeric(364, "%s %s %s :0 %s",user->nick,ServerInstance->Config->ServerName,ServerInstance->Config->ServerName,ServerInstance->Config->ServerDesc); - user->WriteNumeric(365, "%s * :End of /LINKS list.",user->nick); + user->WriteNumeric(364, "%s %s %s :0 %s",user->nick.c_str(),ServerInstance->Config->ServerName,ServerInstance->Config->ServerName,ServerInstance->Config->ServerDesc); + user->WriteNumeric(365, "%s * :End of /LINKS list.",user->nick.c_str()); return CMD_SUCCESS; } diff --git a/src/commands/cmd_list.cpp b/src/commands/cmd_list.cpp index 164830a26..62bf8d628 100644 --- a/src/commands/cmd_list.cpp +++ b/src/commands/cmd_list.cpp @@ -26,7 +26,7 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User { int minusers = 0, maxusers = 0; - user->WriteNumeric(321, "%s Channel :Users Name",user->nick); + user->WriteNumeric(321, "%s Channel :Users Name",user->nick.c_str()); /* Work around mIRC suckyness. YOU SUCK, KHALED! */ if (parameters.size() == 1) @@ -62,17 +62,17 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User bool n = (i->second->HasUser(user) || IS_OPER(user)); if (!IS_OPER(user) && (i->second->IsModeSet('p')) && (!n)) { - user->WriteNumeric(322, "%s * %ld :",user->nick, users); + user->WriteNumeric(322, "%s * %ld :",user->nick.c_str(), users); } else { if (IS_OPER(user) || (((!(i->second->IsModeSet('p'))) && (!(i->second->IsModeSet('s')))) || (n))) { - user->WriteNumeric(322, "%s %s %ld :[+%s] %s",user->nick,i->second->name,users,i->second->ChanModes(n),i->second->topic); + user->WriteNumeric(322, "%s %s %ld :[+%s] %s",user->nick.c_str(),i->second->name,users,i->second->ChanModes(n),i->second->topic); } } } - user->WriteNumeric(323, "%s :End of channel list.",user->nick); + user->WriteNumeric(323, "%s :End of channel list.",user->nick.c_str()); return CMD_SUCCESS; } diff --git a/src/commands/cmd_loadmodule.cpp b/src/commands/cmd_loadmodule.cpp index 31bb02ca0..8060b47d5 100644 --- a/src/commands/cmd_loadmodule.cpp +++ b/src/commands/cmd_loadmodule.cpp @@ -25,13 +25,13 @@ CmdResult CommandLoadmodule::Handle (const std::vector<std::string>& parameters, { if (ServerInstance->Modules->Load(parameters[0].c_str())) { - ServerInstance->SNO->WriteToSnoMask('A', "NEW MODULE: %s loaded %s",user->nick, parameters[0].c_str()); - user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick, parameters[0].c_str()); + ServerInstance->SNO->WriteToSnoMask('A', "NEW MODULE: %s loaded %s",user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick.c_str(), parameters[0].c_str()); return CMD_SUCCESS; } else { - user->WriteNumeric(974, "%s %s :%s",user->nick, parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(974, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); return CMD_FAILURE; } } diff --git a/src/commands/cmd_lusers.cpp b/src/commands/cmd_lusers.cpp index 11f34d8d7..23e8b8234 100644 --- a/src/commands/cmd_lusers.cpp +++ b/src/commands/cmd_lusers.cpp @@ -25,15 +25,15 @@ CmdResult CommandLusers::Handle (const std::vector<std::string>&, User *user) { // this lusers command shows one server at all times because // a protocol module must override it to show those stats. - user->WriteNumeric(251, "%s :There are %d users and %d invisible on 1 server",user->nick,ServerInstance->Users->UserCount()-ServerInstance->Users->ModeCount('i'),ServerInstance->Users->ModeCount('i')); + user->WriteNumeric(251, "%s :There are %d users and %d invisible on 1 server",user->nick.c_str(),ServerInstance->Users->UserCount()-ServerInstance->Users->ModeCount('i'),ServerInstance->Users->ModeCount('i')); if (ServerInstance->Users->OperCount()) - user->WriteNumeric(252, "%s %d :operator(s) online",user->nick,ServerInstance->Users->OperCount()); + user->WriteNumeric(252, "%s %d :operator(s) online",user->nick.c_str(),ServerInstance->Users->OperCount()); if (ServerInstance->Users->UnregisteredUserCount()) - user->WriteNumeric(253, "%s %d :unknown connections",user->nick,ServerInstance->Users->UnregisteredUserCount()); + user->WriteNumeric(253, "%s %d :unknown connections",user->nick.c_str(),ServerInstance->Users->UnregisteredUserCount()); if (ServerInstance->ChannelCount()) - user->WriteNumeric(254, "%s %ld :channels formed",user->nick,ServerInstance->ChannelCount()); + user->WriteNumeric(254, "%s %ld :channels formed",user->nick.c_str(),ServerInstance->ChannelCount()); if (ServerInstance->Users->LocalUserCount()) - user->WriteNumeric(255, "%s :I have %d clients and 0 servers",user->nick,ServerInstance->Users->LocalUserCount()); + user->WriteNumeric(255, "%s :I have %d clients and 0 servers",user->nick.c_str(),ServerInstance->Users->LocalUserCount()); return CMD_SUCCESS; } diff --git a/src/commands/cmd_map.cpp b/src/commands/cmd_map.cpp index cea9f39cf..1ee1f0eb0 100644 --- a/src/commands/cmd_map.cpp +++ b/src/commands/cmd_map.cpp @@ -26,8 +26,8 @@ CmdResult CommandMap::Handle (const std::vector<std::string>&, User *user) // as with /LUSERS this does nothing without a linking // module to override its behaviour and display something // better. - user->WriteNumeric(006, "%s :%s",user->nick,ServerInstance->Config->ServerName); - user->WriteNumeric(007, "%s :End of /MAP",user->nick); + user->WriteNumeric(006, "%s :%s",user->nick.c_str(),ServerInstance->Config->ServerName); + user->WriteNumeric(007, "%s :End of /MAP",user->nick.c_str()); return CMD_SUCCESS; } diff --git a/src/commands/cmd_modules.cpp b/src/commands/cmd_modules.cpp index 0409e6341..9474dece4 100644 --- a/src/commands/cmd_modules.cpp +++ b/src/commands/cmd_modules.cpp @@ -62,14 +62,14 @@ CmdResult CommandModules::Handle (const std::vector<std::string>&, User *user) strlcpy(modulename,module_names[i].c_str(),256); if (IS_OPER(user)) { - user->WriteNumeric(702, "%s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,(unsigned long)m,V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2); + user->WriteNumeric(702, "%s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick.c_str(),(unsigned long)m,V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2); } else { - user->WriteNumeric(702, "%s :%s",user->nick,ServerConfig::CleanFilename(modulename)); + user->WriteNumeric(702, "%s :%s",user->nick.c_str(),ServerConfig::CleanFilename(modulename)); } } - user->WriteNumeric(703, "%s :End of MODULES list",user->nick); + user->WriteNumeric(703, "%s :End of MODULES list",user->nick.c_str()); return CMD_SUCCESS; } diff --git a/src/commands/cmd_names.cpp b/src/commands/cmd_names.cpp index 7e2b9cdee..acf516e86 100644 --- a/src/commands/cmd_names.cpp +++ b/src/commands/cmd_names.cpp @@ -27,7 +27,7 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User if (!parameters.size()) { - user->WriteNumeric(366, "%s * :End of /NAMES list.",user->nick); + user->WriteNumeric(366, "%s * :End of /NAMES list.",user->nick.c_str()); return CMD_SUCCESS; } @@ -39,14 +39,14 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User { if ((c->IsModeSet('s')) && (!c->HasUser(user))) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, c->name); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name); return CMD_FAILURE; } c->UserList(user); } else { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str()); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); } return CMD_SUCCESS; diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp index 0ae781cc0..8a8dbb6dd 100644 --- a/src/commands/cmd_nick.cpp +++ b/src/commands/cmd_nick.cpp @@ -32,7 +32,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User if (parameters[0].empty()) { /* We cant put blanks in the parameters, so for this (extremely rare) issue we just put '*' here. */ - user->WriteNumeric(432, "%s * :Erroneous Nickname", *user->nick ? user->nick : "*"); + user->WriteNumeric(432, "%s * :Erroneous Nickname", user->nick.empty() ? user->nick.c_str() : "*"); return CMD_FAILURE; } @@ -52,12 +52,12 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User return CMD_SUCCESS; } - user->WriteNumeric(432, "%s %s :Erroneous Nickname", user->nick,parameters[0].c_str()); + user->WriteNumeric(432, "%s %s :Erroneous Nickname", user->nick.c_str(),parameters[0].c_str()); return CMD_FAILURE; } } - if (irc::string(user->nick) == assign(parameters[0])) + if (irc::string(user->nick.c_str()) == assign(parameters[0])) { /* If its exactly the same, even case, dont do anything. */ if (parameters[0] == user->nick) @@ -67,14 +67,14 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User * able to do silly things like this even though the RFC says * the nick AAA is the same as the nick aaa. */ - strlcpy(oldnick, user->nick, NICKMAX - 1); + strlcpy(oldnick, user->nick.c_str(), NICKMAX - 1); int MOD_RESULT = 0; FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(user,parameters[0].c_str())); if (MOD_RESULT) return CMD_FAILURE; if (user->registered == REG_ALL) user->WriteCommon("NICK %s",parameters[0].c_str()); - strlcpy(user->nick, parameters[0].c_str(), NICKMAX - 1); + user->nick.assign(parameters[0], 0, NICKMAX - 1); user->InvalidateCache(); FOREACH_MOD(I_OnUserPostNick,OnUserPostNick(user,oldnick)); return CMD_SUCCESS; @@ -94,8 +94,8 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User XLine* mq = ServerInstance->XLines->MatchesLine("Q",parameters[0]); if (mq) { - ServerInstance->SNO->WriteToSnoMask('x', "Q-Lined nickname %s from %s!%s@%s: %s", parameters[0].c_str(), user->nick, user->ident, user->host, mq->reason); - user->WriteNumeric(432, "%s %s :Invalid nickname: %s",user->nick, parameters[0].c_str(), mq->reason); + ServerInstance->SNO->WriteToSnoMask('x', "Q-Lined nickname %s from %s!%s@%s: %s", parameters[0].c_str(), user->nick.c_str(), user->ident.c_str(), user->host, mq->reason); + user->WriteNumeric(432, "%s %s :Invalid nickname: %s",user->nick.c_str(), parameters[0].c_str(), mq->reason); return CMD_FAILURE; } } @@ -115,17 +115,17 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User if (InUse->registered != REG_ALL) { /* force the camper to their UUID, and ask them to re-send a NICK. */ - InUse->WriteTo(InUse, "NICK %s", InUse->uuid); - InUse->WriteNumeric(433, "%s %s :Nickname overruled.", InUse->nick, InUse->nick); - InUse->UpdateNickHash(InUse->uuid); - strlcpy(InUse->nick, InUse->uuid, NICKMAX - 1); + InUse->WriteTo(InUse, "NICK %s", InUse->uuid.c_str()); + InUse->WriteNumeric(433, "%s %s :Nickname overruled.", InUse->nick.c_str(), InUse->nick.c_str()); + InUse->UpdateNickHash(InUse->uuid.c_str()); + InUse->nick.assign(InUse->uuid, 0, NICKMAX - 1); InUse->InvalidateCache(); InUse->registered &= ~REG_NICK; } else { /* No camping, tell the incoming user to stop trying to change nick ;p */ - user->WriteNumeric(433, "%s %s :Nickname is already in use.", user->registered >= REG_NICK ? user->nick : "*", parameters[0].c_str()); + user->WriteNumeric(433, "%s %s :Nickname is already in use.", user->registered >= REG_NICK ? user->nick.c_str() : "*", parameters[0].c_str()); return CMD_FAILURE; } } @@ -141,7 +141,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User if (user->registered == REG_ALL) user->WriteCommon("NICK %s", parameters[0].c_str()); - strlcpy(oldnick, user->nick, NICKMAX - 1); + strlcpy(oldnick, user->nick.c_str(), NICKMAX - 1); /* change the nick of the user in the users_hash */ user = user->UpdateNickHash(parameters[0].c_str()); @@ -149,10 +149,10 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User /* actually change the nick within the record */ if (!user) return CMD_FAILURE; - if (!*user->nick) + if (!user->nick.empty()) return CMD_FAILURE; - strlcpy(user->nick, parameters[0].c_str(), NICKMAX - 1); + user->nick.assign(parameters[0], 0, NICKMAX - 1); user->InvalidateCache(); diff --git a/src/commands/cmd_notice.cpp b/src/commands/cmd_notice.cpp index 451b67074..6c8762a30 100644 --- a/src/commands/cmd_notice.cpp +++ b/src/commands/cmd_notice.cpp @@ -69,12 +69,12 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use { if ((chan->IsModeSet('n')) && (!chan->HasUser(user))) { - user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick, chan->name); + user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick.c_str(), chan->name); return CMD_FAILURE; } if ((chan->IsModeSet('m')) && (chan->GetStatus(user) < STATUS_VOICE)) { - user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick, chan->name); + user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick.c_str(), chan->name); return CMD_FAILURE; } } @@ -89,7 +89,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use if (temp.empty()) { - user->WriteNumeric(412, "%s :No text to send", user->nick); + user->WriteNumeric(412, "%s :No text to send", user->nick.c_str()); return CMD_FAILURE; } @@ -116,7 +116,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use else { /* no such nick/channel */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, target); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), target); return CMD_FAILURE; } return CMD_SUCCESS; @@ -136,7 +136,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use if (dest && strcasecmp(dest->server, targetserver + 1)) { /* Incorrect server for user */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str()); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } } @@ -150,7 +150,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use { if (parameters[1].empty()) { - user->WriteNumeric(412, "%s :No text to send", user->nick); + user->WriteNumeric(412, "%s :No text to send", user->nick.c_str()); return CMD_FAILURE; } @@ -167,7 +167,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use if (IS_LOCAL(dest)) { // direct write, same server - user->WriteTo(dest, "NOTICE %s :%s", dest->nick, text); + user->WriteTo(dest, "NOTICE %s :%s", dest->nick.c_str(), text); } FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,dest,TYPE_USER,text,0,exempt_list)); @@ -175,7 +175,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use else { /* no such nick/channel */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str()); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_oper.cpp b/src/commands/cmd_oper.cpp index 0e08c3357..8a3303093 100644 --- a/src/commands/cmd_oper.cpp +++ b/src/commands/cmd_oper.cpp @@ -54,8 +54,8 @@ CmdResult CommandOper::Handle (const std::vector<std::string>& parameters, User bool match_pass = false; bool match_hosts = false; - snprintf(TheHost,MAXBUF,"%s@%s",user->ident,user->host); - snprintf(TheIP, MAXBUF,"%s@%s",user->ident,user->GetIPString()); + snprintf(TheHost,MAXBUF,"%s@%s",user->ident.c_str(),user->host); + snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(),user->GetIPString()); for (int i = 0; i < ServerInstance->Config->ConfValueEnum(ServerInstance->Config->config_data, "oper"); i++) { @@ -82,9 +82,9 @@ CmdResult CommandOper::Handle (const std::vector<std::string>& parameters, User /* found this oper's opertype */ if (!ServerInstance->IsNick(TypeName)) { - user->WriteNumeric(491, "%s :Invalid oper type (oper types must follow the same syntax as nicknames)",user->nick); + user->WriteNumeric(491, "%s :Invalid oper type (oper types must follow the same syntax as nicknames)",user->nick.c_str()); ServerInstance->SNO->WriteToSnoMask('o',"CONFIGURATION ERROR! Oper type '%s' contains invalid characters",OperType); - ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: credentials valid, but oper type erroneous.",user->nick,user->ident,user->host); + ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: credentials valid, but oper type erroneous.",user->nick.c_str(),user->ident.c_str(),user->host); return CMD_FAILURE; } ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "type","host", j, HostName, MAXBUF); @@ -107,8 +107,8 @@ CmdResult CommandOper::Handle (const std::vector<std::string>& parameters, User if (found) { /* correct oper credentials */ - ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')",user->nick,user->ident,user->host,irc::Spacify(OperType),parameters[0].c_str()); - user->WriteNumeric(381, "%s :You are now %s %s",user->nick, strchr("aeiouAEIOU", *OperType) ? "an" : "a", irc::Spacify(OperType)); + ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')",user->nick.c_str(),user->ident.c_str(),user->host,irc::Spacify(OperType),parameters[0].c_str()); + user->WriteNumeric(381, "%s :You are now %s %s",user->nick.c_str(), strchr("aeiouAEIOU", *OperType) ? "an" : "a", irc::Spacify(OperType)); if (!user->IsModeSet('o')) user->Oper(OperType, LoginName); } @@ -130,25 +130,25 @@ CmdResult CommandOper::Handle (const std::vector<std::string>& parameters, User } // tell them they suck, and lag them up to help prevent brute-force attacks - user->WriteNumeric(491, "%s :Invalid oper credentials",user->nick); + user->WriteNumeric(491, "%s :Invalid oper credentials",user->nick.c_str()); user->IncreasePenalty(10); - snprintf(broadcast, MAXBUF, "WARNING! Failed oper attempt by %s!%s@%s using login '%s': The following fields do not match: %s",user->nick,user->ident,user->host, parameters[0].c_str(), fields.c_str()); + snprintf(broadcast, MAXBUF, "WARNING! Failed oper attempt by %s!%s@%s using login '%s': The following fields do not match: %s",user->nick.c_str(),user->ident.c_str(),user->host, parameters[0].c_str(), fields.c_str()); ServerInstance->SNO->WriteToSnoMask('o',std::string(broadcast)); ServerInstance->PI->SendSNONotice("o", std::string("OPER: ") + broadcast); - ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s!%s@%s using login '%s': The following fields did not match: %s",user->nick,user->ident,user->host,parameters[0].c_str(),fields.c_str()); + ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s!%s@%s using login '%s': The following fields did not match: %s",user->nick.c_str(),user->ident.c_str(),user->host,parameters[0].c_str(),fields.c_str()); return CMD_FAILURE; } else { - user->WriteNumeric(491, "%s :Your oper block does not have a valid opertype associated with it",user->nick); + user->WriteNumeric(491, "%s :Your oper block does not have a valid opertype associated with it",user->nick.c_str()); snprintf(broadcast, MAXBUF, "CONFIGURATION ERROR! Oper block '%s': missing OperType %s",parameters[0].c_str(),OperType); ServerInstance->SNO->WriteToSnoMask('o', std::string(broadcast)); - ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s!%s@%s using login '%s': credentials valid, but oper type nonexistent.",user->nick,user->ident,user->host,parameters[0].c_str()); + ServerInstance->Logs->Log("OPER",DEFAULT,"OPER: Failed oper attempt by %s!%s@%s using login '%s': credentials valid, but oper type nonexistent.",user->nick.c_str(),user->ident.c_str(),user->host,parameters[0].c_str()); return CMD_FAILURE; } } diff --git a/src/commands/cmd_part.cpp b/src/commands/cmd_part.cpp index 07b45367f..352b967b5 100644 --- a/src/commands/cmd_part.cpp +++ b/src/commands/cmd_part.cpp @@ -54,7 +54,7 @@ CmdResult CommandPart::Handle (const std::vector<std::string>& parameters, User } else { - user->WriteServ( "401 %s %s :No such channel", user->nick, parameters[0].c_str()); + user->WriteServ( "401 %s %s :No such channel", user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_pass.cpp b/src/commands/cmd_pass.cpp index 2e1a702a2..b9b55d007 100644 --- a/src/commands/cmd_pass.cpp +++ b/src/commands/cmd_pass.cpp @@ -24,14 +24,14 @@ CmdResult CommandPass::Handle (const std::vector<std::string>& parameters, User // Check to make sure they havnt registered -- Fix by FCS if (user->registered == REG_ALL) { - user->WriteNumeric(462, "%s :You may not reregister",user->nick); + user->WriteNumeric(462, "%s :You may not reregister",user->nick.c_str()); return CMD_FAILURE; } ConnectClass* a = user->GetClass(); if (!a) return CMD_FAILURE; - strlcpy(user->password, parameters[0].c_str(), 63); + user->password.assign(parameters[0], 0, 63); if (!ServerInstance->PassCompare(user, a->GetPass().c_str(), parameters[0].c_str(), a->GetHash().c_str())) user->haspassed = true; diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp index 1c4ba277e..c4d604959 100644 --- a/src/commands/cmd_privmsg.cpp +++ b/src/commands/cmd_privmsg.cpp @@ -70,12 +70,12 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us { if ((chan->IsModeSet('n')) && (!chan->HasUser(user))) { - user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick, chan->name); + user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick.c_str(), chan->name); return CMD_FAILURE; } if ((chan->IsModeSet('m')) && (chan->GetStatus(user) < STATUS_VOICE)) { - user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick, chan->name); + user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick.c_str(), chan->name); return CMD_FAILURE; } } @@ -91,7 +91,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us /* Check again, a module may have zapped the input string */ if (temp.empty()) { - user->WriteNumeric(412, "%s :No text to send", user->nick); + user->WriteNumeric(412, "%s :No text to send", user->nick.c_str()); return CMD_FAILURE; } @@ -118,7 +118,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us else { /* no such nick/channel */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, target); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), target); return CMD_FAILURE; } return CMD_SUCCESS; @@ -138,7 +138,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us if (dest && strcasecmp(dest->server, targetserver + 1)) { /* Incorrect server for user */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str()); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } } @@ -152,14 +152,14 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us { if (parameters[1].empty()) { - user->WriteNumeric(412, "%s :No text to send", user->nick); + user->WriteNumeric(412, "%s :No text to send", user->nick.c_str()); return CMD_FAILURE; } if (IS_AWAY(dest)) { /* auto respond with aweh msg */ - user->WriteNumeric(301, "%s %s :%s",user->nick,dest->nick,dest->awaymsg); + user->WriteNumeric(301, "%s %s :%s",user->nick.c_str(),dest->nick.c_str(),dest->awaymsg.c_str()); } int MOD_RESULT = 0; @@ -176,7 +176,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us if (IS_LOCAL(dest)) { // direct write, same server - user->WriteTo(dest, "PRIVMSG %s :%s", dest->nick, text); + user->WriteTo(dest, "PRIVMSG %s :%s", dest->nick.c_str(), text); } FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, dest, TYPE_USER, text, 0, except_list)); @@ -184,7 +184,7 @@ CmdResult CommandPrivmsg::Handle (const std::vector<std::string>& parameters, Us else { /* no such nick/channel */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str()); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } return CMD_SUCCESS; diff --git a/src/commands/cmd_qline.cpp b/src/commands/cmd_qline.cpp index f3471a6b3..ea7498736 100644 --- a/src/commands/cmd_qline.cpp +++ b/src/commands/cmd_qline.cpp @@ -31,22 +31,22 @@ CmdResult CommandQline::Handle (const std::vector<std::string>& parameters, User if (parameters[0].find('@') != std::string::npos || parameters[0].find('!') != std::string::npos || parameters[0].find('.') != std::string::npos) { - user->WriteServ("NOTICE %s :*** A Q-Line only bans a nick pattern, not a nick!user@host pattern.",user->nick); + user->WriteServ("NOTICE %s :*** A Q-Line only bans a nick pattern, not a nick!user@host pattern.",user->nick.c_str()); return CMD_FAILURE; } long duration = ServerInstance->Duration(parameters[1].c_str()); - QLine* ql = new QLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2].c_str(), parameters[0].c_str()); + QLine* ql = new QLine(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str()); if (ServerInstance->XLines->AddLine(ql,user)) { if (!duration) { - ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Q-line for %s.",user->nick,parameters[0].c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Q-line for %s.",user->nick.c_str(),parameters[0].c_str()); } else { time_t c_requires_crap = duration + ServerInstance->Time(); - ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s",user->nick,parameters[0].c_str(), + ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s",user->nick.c_str(),parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str()); } ServerInstance->XLines->ApplyLines(); @@ -54,18 +54,18 @@ CmdResult CommandQline::Handle (const std::vector<std::string>& parameters, User else { delete ql; - user->WriteServ("NOTICE %s :*** Q-Line for %s already exists",user->nick,parameters[0].c_str()); + user->WriteServ("NOTICE %s :*** Q-Line for %s already exists",user->nick.c_str(),parameters[0].c_str()); } } else { if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "Q", user)) { - ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Q-line on %s.",user->nick,parameters[0].c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Q-line on %s.",user->nick.c_str(),parameters[0].c_str()); } else { - user->WriteServ("NOTICE %s :*** Q-Line %s not found in list, try /stats q.",user->nick,parameters[0].c_str()); + user->WriteServ("NOTICE %s :*** Q-Line %s not found in list, try /stats q.",user->nick.c_str(),parameters[0].c_str()); return CMD_FAILURE; } } diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp index ce34239a5..6a7ed124b 100644 --- a/src/commands/cmd_rehash.cpp +++ b/src/commands/cmd_rehash.cpp @@ -44,9 +44,9 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use FOREACH_MOD(I_OnRehash,OnRehash(user, "")); // XXX write this to a remote user correctly - user->WriteNumeric(382, "%s %s :Rehashing",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName)); + user->WriteNumeric(382, "%s %s :Rehashing",user->nick.c_str(),ServerConfig::CleanFilename(ServerInstance->ConfigFileName)); - std::string m = std::string(user->nick) + " is rehashing config file " + ServerConfig::CleanFilename(ServerInstance->ConfigFileName) + " on " + ServerInstance->Config->ServerName; + std::string m = user->nick + " is rehashing config file " + ServerConfig::CleanFilename(ServerInstance->ConfigFileName) + " on " + ServerInstance->Config->ServerName; ServerInstance->SNO->WriteToSnoMask('A', m); ServerInstance->Logs->CloseLogs(); @@ -71,7 +71,7 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use { /* A rehash is already in progress! ahh shit. */ if (IS_LOCAL(user)) - user->WriteServ("NOTICE %s :*** Could not rehash: A rehash is already in progress.", user->nick); + user->WriteServ("NOTICE %s :*** Could not rehash: A rehash is already in progress.", user->nick.c_str()); else ServerInstance->PI->SendUserNotice(user, "*** Could not rehash: A rehash is already in progress."); diff --git a/src/commands/cmd_reloadmodule.cpp b/src/commands/cmd_reloadmodule.cpp index 05162e631..f968a49ad 100644 --- a/src/commands/cmd_reloadmodule.cpp +++ b/src/commands/cmd_reloadmodule.cpp @@ -23,16 +23,16 @@ CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameter { if (ServerInstance->Modules->Unload(parameters[0].c_str())) { - ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s unloaded %s",user->nick, parameters[0].c_str()); + ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s unloaded %s",user->nick.c_str(), parameters[0].c_str()); if (ServerInstance->Modules->Load(parameters[0].c_str())) { - ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s reloaded %s",user->nick, parameters[0].c_str()); - user->WriteNumeric(975, "%s %s :Module successfully reloaded.",user->nick, parameters[0].c_str()); + ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s reloaded %s",user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(975, "%s %s :Module successfully reloaded.",user->nick.c_str(), parameters[0].c_str()); return CMD_SUCCESS; } } - ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s unsuccessfully reloaded %s",user->nick, parameters[0].c_str()); - user->WriteNumeric(975, "%s %s :%s",user->nick, parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); + ServerInstance->SNO->WriteToSnoMask('A', "RELOAD MODULE: %s unsuccessfully reloaded %s",user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(975, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_restart.cpp b/src/commands/cmd_restart.cpp index 334fb621f..7251b1fa6 100644 --- a/src/commands/cmd_restart.cpp +++ b/src/commands/cmd_restart.cpp @@ -21,10 +21,10 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, User *user) { - ServerInstance->Logs->Log("COMMAND",DEFAULT,"Restart: %s",user->nick); + ServerInstance->Logs->Log("COMMAND",DEFAULT,"Restart: %s",user->nick.c_str()); if (!ServerInstance->PassCompare(user, ServerInstance->Config->restartpass, parameters[0].c_str(), ServerInstance->Config->powerhash)) { - ServerInstance->SNO->WriteToSnoMask('A', "RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host); + ServerInstance->SNO->WriteToSnoMask('A', "RESTART command from %s!%s@%s, restarting server.",user->nick.c_str(),user->ident.c_str(),user->host); try { @@ -38,7 +38,7 @@ CmdResult CommandRestart::Handle (const std::vector<std::string>& parameters, Us } else { - ServerInstance->SNO->WriteToSnoMask('A', "Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host); + ServerInstance->SNO->WriteToSnoMask('A', "Failed RESTART Command from %s!%s@%s.",user->nick.c_str(),user->ident.c_str(),user->host); return CMD_FAILURE; } diff --git a/src/commands/cmd_server.cpp b/src/commands/cmd_server.cpp index 5385428b8..c7b413406 100644 --- a/src/commands/cmd_server.cpp +++ b/src/commands/cmd_server.cpp @@ -23,7 +23,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) CmdResult CommandServer::Handle (const std::vector<std::string>&, User *user) { - user->WriteNumeric(666, "%s :You cannot identify as a server, you are a USER. IRC Operators informed.",user->nick); - ServerInstance->SNO->WriteToSnoMask('A', "WARNING: %s attempted to issue a SERVER command and is registered as a user!", user->nick); + user->WriteNumeric(666, "%s :You cannot identify as a server, you are a USER. IRC Operators informed.",user->nick.c_str()); + ServerInstance->SNO->WriteToSnoMask('A', "WARNING: %s attempted to issue a SERVER command and is registered as a user!", user->nick.c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_squit.cpp b/src/commands/cmd_squit.cpp index 61d0a601d..2fd5c701c 100644 --- a/src/commands/cmd_squit.cpp +++ b/src/commands/cmd_squit.cpp @@ -26,6 +26,6 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) CmdResult CommandSquit::Handle (const std::vector<std::string>&, User *user) { - user->WriteServ( "NOTICE %s :Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.", user->nick); + user->WriteServ( "NOTICE %s :Look into loading a linking module (like m_spanningtree) if you want this to do anything useful.", user->nick.c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index 174094afa..093d46c6c 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -53,7 +53,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str ServerInstance->SNO->WriteToSnoMask('t', "%s '%c' denied for %s (%s@%s)", (IS_LOCAL(user) ? "Stats" : "Remote stats"), - statschar, user->nick, user->ident, user->host); + statschar, user->nick.c_str(), user->ident.c_str(), user->host); results.push_back(sn + " 481 " + user->nick + " :Permission denied - STATS " + statschar + " is oper-only"); return; } @@ -239,7 +239,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str results.push_back(sn+" 249 "+user->nick+" :nick collisions "+ConvToStr(ServerInstance->stats->statsCollisions)); results.push_back(sn+" 249 "+user->nick+" :dns requests "+ConvToStr(ServerInstance->stats->statsDnsGood+ServerInstance->stats->statsDnsBad)+" succeeded "+ConvToStr(ServerInstance->stats->statsDnsGood)+" failed "+ConvToStr(ServerInstance->stats->statsDnsBad)); results.push_back(sn+" 249 "+user->nick+" :connection count "+ConvToStr(ServerInstance->stats->statsConnects)); - snprintf(buffer,MAXBUF," 249 %s :bytes sent %5.2fK recv %5.2fK",user->nick,ServerInstance->stats->statsSent / 1024,ServerInstance->stats->statsRecv / 1024); + snprintf(buffer,MAXBUF," 249 %s :bytes sent %5.2fK recv %5.2fK",user->nick.c_str(),ServerInstance->stats->statsSent / 1024,ServerInstance->stats->statsRecv / 1024); results.push_back(sn+buffer); } break; @@ -264,7 +264,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++) { User* i = *n; - if (ServerInstance->IsNick(i->nick)) + if (ServerInstance->IsNick(i->nick.c_str())) { results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age)); } @@ -277,7 +277,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++) { User* i = *n; - if (ServerInstance->IsNick(i->nick)) + if (ServerInstance->IsNick(i->nick.c_str())) { results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(ServerInstance->Time() - i->age)); } @@ -297,13 +297,13 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str if (stime->tm_year > 70) { char buffer[MAXBUF]; - snprintf(buffer,MAXBUF," 242 %s :Server up %d years, %d days, %.2d:%.2d:%.2d",user->nick,(stime->tm_year-70),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec); + snprintf(buffer,MAXBUF," 242 %s :Server up %d years, %d days, %.2d:%.2d:%.2d",user->nick.c_str(),(stime->tm_year-70),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec); results.push_back(sn+buffer); } else { char buffer[MAXBUF]; - snprintf(buffer,MAXBUF," 242 %s :Server up %d days, %.2d:%.2d:%.2d",user->nick,stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec); + snprintf(buffer,MAXBUF," 242 %s :Server up %d days, %.2d:%.2d:%.2d",user->nick.c_str(),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec); results.push_back(sn+buffer); } } @@ -315,6 +315,6 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report"); ServerInstance->SNO->WriteToSnoMask('t',"%s '%c' requested by %s (%s@%s)", - (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick, user->ident, user->host); + (IS_LOCAL(user) ? "Stats" : "Remote stats"), statschar, user->nick.c_str(), user->ident.c_str(), user->host); return; } diff --git a/src/commands/cmd_time.cpp b/src/commands/cmd_time.cpp index d8c3561b0..79b8e823d 100644 --- a/src/commands/cmd_time.cpp +++ b/src/commands/cmd_time.cpp @@ -32,7 +32,7 @@ CmdResult CommandTime::Handle (const std::vector<std::string>&, User *user) snprintf(tms,26,"%s",asctime(timeinfo)); tms[24] = 0; - user->WriteNumeric(391, "%s %s :%s",user->nick,ServerInstance->Config->ServerName,tms); + user->WriteNumeric(391, "%s %s :%s",user->nick.c_str(),ServerInstance->Config->ServerName,tms); return CMD_SUCCESS; } diff --git a/src/commands/cmd_topic.cpp b/src/commands/cmd_topic.cpp index 9f9d56b14..f228243bd 100644 --- a/src/commands/cmd_topic.cpp +++ b/src/commands/cmd_topic.cpp @@ -31,22 +31,22 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User { if ((Ptr->IsModeSet('s')) && (!Ptr->HasUser(user))) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, Ptr->name); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), Ptr->name); return CMD_FAILURE; } if (Ptr->topicset) { - user->WriteNumeric(332, "%s %s :%s", user->nick, Ptr->name, Ptr->topic); - user->WriteNumeric(333, "%s %s %s %lu", user->nick, Ptr->name, Ptr->setby, (unsigned long)Ptr->topicset); + user->WriteNumeric(332, "%s %s :%s", user->nick.c_str(), Ptr->name, Ptr->topic); + user->WriteNumeric(333, "%s %s %s %lu", user->nick.c_str(), Ptr->name, Ptr->setby, (unsigned long)Ptr->topicset); } else { - user->WriteNumeric(331, "%s %s :No topic is set.", user->nick, Ptr->name); + user->WriteNumeric(331, "%s %s :No topic is set.", user->nick.c_str(), Ptr->name); } } else { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str()); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } return CMD_SUCCESS; @@ -60,12 +60,12 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User { if (!Ptr->HasUser(user)) { - user->WriteNumeric(442, "%s %s :You're not on that channel!",user->nick, Ptr->name); + user->WriteNumeric(442, "%s %s :You're not on that channel!",user->nick.c_str(), Ptr->name); return CMD_FAILURE; } if ((Ptr->IsModeSet('t')) && (Ptr->GetStatus(user) < STATUS_HOP)) { - user->WriteNumeric(482, "%s %s :You must be at least a half-operator to change the topic on this channel", user->nick, Ptr->name); + user->WriteNumeric(482, "%s %s :You must be at least a half-operator to change the topic on this channel", user->nick.c_str(), Ptr->name); return CMD_FAILURE; } } @@ -93,9 +93,9 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User } if (ServerInstance->Config->FullHostInTopic) - strlcpy(Ptr->setby,user->GetFullHost(),127); + strlcpy(Ptr->setby,user->GetFullHost().c_str(),127); else - strlcpy(Ptr->setby,user->nick,127); + strlcpy(Ptr->setby,user->nick.c_str(),127); Ptr->topicset = ServerInstance->Time(); Ptr->WriteChannel(user, "TOPIC %s :%s", Ptr->name, Ptr->topic); @@ -106,7 +106,7 @@ CmdResult CommandTopic::Handle (const std::vector<std::string>& parameters, User } else { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str()); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } } diff --git a/src/commands/cmd_unloadmodule.cpp b/src/commands/cmd_unloadmodule.cpp index 68ad591ce..4c1e685fb 100644 --- a/src/commands/cmd_unloadmodule.cpp +++ b/src/commands/cmd_unloadmodule.cpp @@ -25,12 +25,12 @@ CmdResult CommandUnloadmodule::Handle (const std::vector<std::string>& parameter { if (ServerInstance->Modules->Unload(parameters[0].c_str())) { - ServerInstance->SNO->WriteToSnoMask('A', "MODULE UNLOADED: %s unloaded %s", user->nick, parameters[0].c_str()); - user->WriteNumeric(973, "%s %s :Module successfully unloaded.",user->nick, parameters[0].c_str()); + ServerInstance->SNO->WriteToSnoMask('A', "MODULE UNLOADED: %s unloaded %s", user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(973, "%s %s :Module successfully unloaded.",user->nick.c_str(), parameters[0].c_str()); } else { - user->WriteNumeric(972, "%s %s :%s",user->nick, parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(972, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_user.cpp b/src/commands/cmd_user.cpp index 46d42771b..1acd901f9 100644 --- a/src/commands/cmd_user.cpp +++ b/src/commands/cmd_user.cpp @@ -30,7 +30,7 @@ CmdResult CommandUser::Handle (const std::vector<std::string>& parameters, User * RFC says we must use this numeric, so we do. Let's make it a little more nub friendly though. :) * -- Craig, and then w00t. */ - user->WriteNumeric(461, "%s USER :Your username is not valid",user->nick); + user->WriteNumeric(461, "%s USER :Your username is not valid",user->nick.c_str()); return CMD_FAILURE; } else @@ -40,14 +40,14 @@ CmdResult CommandUser::Handle (const std::vector<std::string>& parameters, User * ~ character, and +1 for null termination, therefore we can safely use up to * IDENTMAX here. */ - strlcpy(user->ident, parameters[0].c_str(), IDENTMAX); - strlcpy(user->fullname, !parameters[3].empty() ? parameters[3].c_str() : "No info", MAXGECOS); + user->ident.assign(parameters[0], 0, IDENTMAX); + user->fullname.assign(parameters[3].empty() ? std::string("No info") : parameters[3], 0, MAXGECOS); user->registered = (user->registered | REG_USER); } } else { - user->WriteNumeric(462, "%s :You may not reregister",user->nick); + user->WriteNumeric(462, "%s :You may not reregister",user->nick.c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_version.cpp b/src/commands/cmd_version.cpp index 1951417d7..091577aba 100644 --- a/src/commands/cmd_version.cpp +++ b/src/commands/cmd_version.cpp @@ -23,7 +23,7 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user) { - user->WriteNumeric(351, "%s :%s",user->nick,ServerInstance->GetVersionString().c_str()); + user->WriteNumeric(351, "%s :%s",user->nick.c_str(),ServerInstance->GetVersionString().c_str()); ServerInstance->Config->Send005(user); return CMD_SUCCESS; } diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index 2c91cb6e7..7f4365204 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -335,13 +335,13 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User * { for (std::vector<std::string>::const_iterator n = whoresults.begin(); n != whoresults.end(); n++) user->WriteServ(*n); - user->WriteNumeric(315, "%s %s :End of /WHO list.",user->nick, *parameters[0].c_str() ? parameters[0].c_str() : "*"); + user->WriteNumeric(315, "%s %s :End of /WHO list.",user->nick.c_str(), *parameters[0].c_str() ? parameters[0].c_str() : "*"); return CMD_SUCCESS; } else { /* BZZT! Too many results. */ - user->WriteNumeric(315, "%s %s :Too many results",user->nick, parameters[0].c_str()); + user->WriteNumeric(315, "%s %s :Too many results",user->nick.c_str(), parameters[0].c_str()); return CMD_FAILURE; } } diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp index d78144348..9858ff93a 100644 --- a/src/commands/cmd_whois.cpp +++ b/src/commands/cmd_whois.cpp @@ -19,17 +19,17 @@ void do_whois(InspIRCd* ServerInstance, User* user, User* dest,unsigned long sig { if (dest->Visibility && !dest->Visibility->VisibleTo(user)) { - ServerInstance->SendWhoisLine(user, dest, 401, "%s %s :No such nick/channel",user->nick, *nick ? nick : "*"); - ServerInstance->SendWhoisLine(user, dest, 318, "%s %s :End of /WHOIS list.",user->nick, *nick ? nick : "*"); + ServerInstance->SendWhoisLine(user, dest, 401, "%s %s :No such nick/channel",user->nick.c_str(), *nick ? nick : "*"); + ServerInstance->SendWhoisLine(user, dest, 318, "%s %s :End of /WHOIS list.",user->nick.c_str(), *nick ? nick : "*"); return; } if (dest->registered == REG_ALL) { - ServerInstance->SendWhoisLine(user, dest, 311, "%s %s %s %s * :%s",user->nick, dest->nick, dest->ident, dest->dhost, dest->fullname); + ServerInstance->SendWhoisLine(user, dest, 311, "%s %s %s %s * :%s",user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->dhost.c_str(), dest->fullname.c_str()); if (user == dest || IS_OPER(user)) { - ServerInstance->SendWhoisLine(user, dest, 378, "%s %s :is connecting from %s@%s %s", user->nick, dest->nick, dest->ident, dest->host, dest->GetIPString()); + ServerInstance->SendWhoisLine(user, dest, 378, "%s %s :is connecting from %s@%s %s", user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->host, dest->GetIPString()); } std::string cl = dest->ChannelList(user); @@ -42,37 +42,37 @@ void do_whois(InspIRCd* ServerInstance, User* user, User* dest,unsigned long sig } else { - ServerInstance->SendWhoisLine(user, dest, 319, "%s %s :%s",user->nick, dest->nick, cl.c_str()); + ServerInstance->SendWhoisLine(user, dest, 319, "%s %s :%s",user->nick.c_str(), dest->nick.c_str(), cl.c_str()); } } if (*ServerInstance->Config->HideWhoisServer && !IS_OPER(user)) { - ServerInstance->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick, dest->nick, ServerInstance->Config->HideWhoisServer, ServerInstance->Config->Network); + ServerInstance->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick.c_str(), dest->nick.c_str(), ServerInstance->Config->HideWhoisServer, ServerInstance->Config->Network); } else { - ServerInstance->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick, dest->nick, dest->server, ServerInstance->GetServerDescription(dest->server).c_str()); + ServerInstance->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick.c_str(), dest->nick.c_str(), dest->server, ServerInstance->GetServerDescription(dest->server).c_str()); } if (IS_AWAY(dest)) { - ServerInstance->SendWhoisLine(user, dest, 301, "%s %s :%s",user->nick, dest->nick, dest->awaymsg); + ServerInstance->SendWhoisLine(user, dest, 301, "%s %s :%s",user->nick.c_str(), dest->nick.c_str(), dest->awaymsg.c_str()); } if (IS_OPER(dest)) { - ServerInstance->SendWhoisLine(user, dest, 313, "%s %s :is %s %s on %s",user->nick, dest->nick, (strchr("AEIOUaeiou",*dest->oper) ? "an" : "a"),irc::Spacify(dest->oper), ServerInstance->Config->Network); + ServerInstance->SendWhoisLine(user, dest, 313, "%s %s :is %s %s on %s",user->nick.c_str(), dest->nick.c_str(), (strchr("AEIOUaeiou",dest->oper[0]) ? "an" : "a"),irc::Spacify(dest->oper.c_str()), ServerInstance->Config->Network); } if (user == dest || IS_OPER(user)) { if (dest->modes[UM_SNOMASK] != 0) { - ServerInstance->SendWhoisLine(user, dest, 379, "%s %s :is using modes +%s +%s", user->nick, dest->nick, dest->FormatModes(), dest->FormatNoticeMasks()); + ServerInstance->SendWhoisLine(user, dest, 379, "%s %s :is using modes +%s +%s", user->nick.c_str(), dest->nick.c_str(), dest->FormatModes(), dest->FormatNoticeMasks()); } else { - ServerInstance->SendWhoisLine(user, dest, 379, "%s %s :is using modes +%s", user->nick, dest->nick, dest->FormatModes()); + ServerInstance->SendWhoisLine(user, dest, 379, "%s %s :is using modes +%s", user->nick.c_str(), dest->nick.c_str(), dest->FormatModes()); } } @@ -84,15 +84,15 @@ void do_whois(InspIRCd* ServerInstance, User* user, User* dest,unsigned long sig */ if ((idle) || (signon)) { - ServerInstance->SendWhoisLine(user, dest, 317, "%s %s %lu %lu :seconds idle, signon time",user->nick, dest->nick, idle, signon); + ServerInstance->SendWhoisLine(user, dest, 317, "%s %s %lu %lu :seconds idle, signon time",user->nick.c_str(), dest->nick.c_str(), idle, signon); } - ServerInstance->SendWhoisLine(user, dest, 318, "%s %s :End of /WHOIS list.",user->nick, dest->nick); + ServerInstance->SendWhoisLine(user, dest, 318, "%s %s :End of /WHOIS list.",user->nick.c_str(), dest->nick.c_str()); } else { - ServerInstance->SendWhoisLine(user, dest, 401, "%s %s :No such nick/channel",user->nick, *nick ? nick : "*"); - ServerInstance->SendWhoisLine(user, dest, 318, "%s %s :End of /WHOIS list.",user->nick, *nick ? nick : "*"); + ServerInstance->SendWhoisLine(user, dest, 401, "%s %s :No such nick/channel",user->nick.c_str(), *nick ? nick : "*"); + ServerInstance->SendWhoisLine(user, dest, 318, "%s %s :End of /WHOIS list.",user->nick.c_str(), *nick ? nick : "*"); } } @@ -146,8 +146,8 @@ CmdResult CommandWhois::Handle (const std::vector<std::string>& parameters, User else { /* no such nick/channel */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, !parameters[userindex].empty() ? parameters[userindex].c_str() : "*"); - user->WriteNumeric(318, "%s %s :End of /WHOIS list.",user->nick, parameters[userindex].empty() ? parameters[userindex].c_str() : "*"); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), !parameters[userindex].empty() ? parameters[userindex].c_str() : "*"); + user->WriteNumeric(318, "%s %s :End of /WHOIS list.",user->nick.c_str(), parameters[userindex].empty() ? parameters[userindex].c_str() : "*"); return CMD_FAILURE; } diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp index 8bc188eee..efd15e3d6 100644 --- a/src/commands/cmd_whowas.cpp +++ b/src/commands/cmd_whowas.cpp @@ -33,7 +33,7 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use /* if whowas disabled in config */ if (ServerInstance->Config->WhoWasGroupSize == 0 || ServerInstance->Config->WhoWasMaxGroups == 0) { - user->WriteNumeric(421, "%s %s :This command has been disabled.",user->nick,command.c_str()); + user->WriteNumeric(421, "%s %s :This command has been disabled.",user->nick.c_str(),command.c_str()); return CMD_FAILURE; } @@ -41,8 +41,8 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use if (i == whowas.end()) { - user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick,parameters[0].c_str()); - user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick,parameters[0].c_str()); + user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick.c_str(),parameters[0].c_str()); + user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick.c_str(),parameters[0].c_str()); return CMD_FAILURE; } else @@ -63,26 +63,26 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use strlcpy(b,asctime(timeinfo),MAXBUF); b[24] = 0; - user->WriteNumeric(314, "%s %s %s %s * :%s",user->nick,parameters[0].c_str(),u->ident,u->dhost,u->gecos); + user->WriteNumeric(314, "%s %s %s %s * :%s",user->nick.c_str(),parameters[0].c_str(),u->ident,u->dhost,u->gecos); if (IS_OPER(user)) - user->WriteNumeric(379, "%s %s :was connecting from *@%s", user->nick, parameters[0].c_str(), u->host); + user->WriteNumeric(379, "%s %s :was connecting from *@%s", user->nick.c_str(), parameters[0].c_str(), u->host); if (*ServerInstance->Config->HideWhoisServer && !IS_OPER(user)) - user->WriteNumeric(312, "%s %s %s :%s",user->nick,parameters[0].c_str(), ServerInstance->Config->HideWhoisServer, b); + user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), ServerInstance->Config->HideWhoisServer, b); else - user->WriteNumeric(312, "%s %s %s :%s",user->nick,parameters[0].c_str(), u->server, b); + user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), u->server, b); } } else { - user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick,parameters[0].c_str()); - user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick,parameters[0].c_str()); + user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick.c_str(),parameters[0].c_str()); + user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick.c_str(),parameters[0].c_str()); return CMD_FAILURE; } } - user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick,parameters[0].c_str()); + user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick.c_str(),parameters[0].c_str()); return CMD_SUCCESS; } @@ -138,15 +138,15 @@ void CommandWhowas::AddToWhoWas(User* user) return; } - whowas_users::iterator iter = whowas.find(user->nick); + whowas_users::iterator iter = whowas.find(irc::string(user->nick.c_str())); if (iter == whowas.end()) { whowas_set* n = new whowas_set; WhoWasGroup *a = new WhoWasGroup(user); n->push_back(a); - whowas[user->nick] = n; - whowas_fifo.push_back(std::make_pair(ServerInstance->Time(),user->nick)); + whowas[user->nick.c_str()] = n; + whowas_fifo.push_back(std::make_pair(ServerInstance->Time(),user->nick.c_str())); if ((int)(whowas.size()) > ServerInstance->Config->WhoWasMaxGroups) { @@ -318,10 +318,10 @@ CommandWhowas::~CommandWhowas() WhoWasGroup::WhoWasGroup(User* user) : host(NULL), dhost(NULL), ident(NULL), server(NULL), gecos(NULL), signon(user->signon) { this->host = strdup(user->host); - this->dhost = strdup(user->dhost); - this->ident = strdup(user->ident); + this->dhost = strdup(user->dhost.c_str()); + this->ident = strdup(user->ident.c_str()); this->server = user->server; - this->gecos = strdup(user->fullname); + this->gecos = strdup(user->fullname.c_str()); } WhoWasGroup::~WhoWasGroup() diff --git a/src/commands/cmd_zline.cpp b/src/commands/cmd_zline.cpp index c1951d447..6151d7181 100644 --- a/src/commands/cmd_zline.cpp +++ b/src/commands/cmd_zline.cpp @@ -30,7 +30,7 @@ CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User { if (target.find('!') != std::string::npos) { - user->WriteServ("NOTICE %s :*** You cannot include a nickname in a zline, a zline must ban only an IP mask",user->nick); + user->WriteServ("NOTICE %s :*** You cannot include a nickname in a zline, a zline must ban only an IP mask",user->nick.c_str()); return CMD_FAILURE; } @@ -62,17 +62,17 @@ CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User ipaddr++; } } - ZLine* zl = new ZLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2].c_str(), ipaddr); + ZLine* zl = new ZLine(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ipaddr); if (ServerInstance->XLines->AddLine(zl,user)) { if (!duration) { - ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Z-line for %s.",user->nick,target.c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Z-line for %s.",user->nick.c_str(),target.c_str()); } else { time_t c_requires_crap = duration + ServerInstance->Time(); - ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s",user->nick,target.c_str(), + ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s",user->nick.c_str(),target.c_str(), ServerInstance->TimeString(c_requires_crap).c_str()); } ServerInstance->XLines->ApplyLines(); @@ -80,18 +80,18 @@ CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User else { delete zl; - user->WriteServ("NOTICE %s :*** Z-Line for %s already exists",user->nick,target.c_str()); + user->WriteServ("NOTICE %s :*** Z-Line for %s already exists",user->nick.c_str(),target.c_str()); } } else { if (ServerInstance->XLines->DelLine(target.c_str(),"Z",user)) { - ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Z-line on %s.",user->nick,target.c_str()); + ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Z-line on %s.",user->nick.c_str(),target.c_str()); } else { - user->WriteServ("NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick,target.c_str()); + user->WriteServ("NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick.c_str(),target.c_str()); return CMD_FAILURE; } } diff --git a/src/configreader.cpp b/src/configreader.cpp index 68c8b7e59..bc26cbd95 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -125,7 +125,7 @@ void ServerConfig::Update005() void ServerConfig::Send005(User* user) { for (std::vector<std::string>::iterator line = ServerInstance->Config->isupport.begin(); line != ServerInstance->Config->isupport.end(); line++) - user->WriteNumeric(005, "%s %s", user->nick, line->c_str()); + user->WriteNumeric(005, "%s %s", user->nick.c_str(), line->c_str()); } bool ServerConfig::CheckOnce(const char* tag, ConfigDataHash &newconf) @@ -731,11 +731,11 @@ void ServerConfig::ReportConfigError(const std::string &errormessage, bool bail, /* ":ServerInstance->Config->ServerName NOTICE user->nick :" */ if (user) { - prefixlen = strlen(this->ServerName) + strlen(user->nick) + 11; - user->WriteServ("NOTICE %s :There were errors in the configuration file:",user->nick); + prefixlen = strlen(this->ServerName) + user->nick.length() + 11; + user->WriteServ("NOTICE %s :There were errors in the configuration file:",user->nick.c_str()); while (start < errors.length()) { - user->WriteServ("NOTICE %s :%s",user->nick, errors.substr(start, 510 - prefixlen).c_str()); + user->WriteServ("NOTICE %s :%s",user->nick.c_str(), errors.substr(start, 510 - prefixlen).c_str()); start += 510 - prefixlen; } } @@ -1192,7 +1192,7 @@ void ServerConfig::Read(bool bail, User* user) if (!foundclass) { if (user) - user->WriteServ("NOTICE %s :*** Warning: Oper type '%s' has a missing class named '%s', this does nothing!", user->nick, item, classname.c_str()); + user->WriteServ("NOTICE %s :*** Warning: Oper type '%s' has a missing class named '%s', this does nothing!", user->nick.c_str(), item, classname.c_str()); else { if (bail) @@ -1229,12 +1229,12 @@ void ServerConfig::Read(bool bail, User* user) if (pl.size() && user) { ServerInstance->Threads->Mutex(true); - user->WriteServ("NOTICE %s :*** Not all your client ports could be bound.", user->nick); - user->WriteServ("NOTICE %s :*** The following port(s) failed to bind:", user->nick); + user->WriteServ("NOTICE %s :*** Not all your client ports could be bound.", user->nick.c_str()); + user->WriteServ("NOTICE %s :*** The following port(s) failed to bind:", user->nick.c_str()); int j = 1; for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++) { - user->WriteServ("NOTICE %s :*** %d. IP: %s Port: %lu", user->nick, j, i->first.empty() ? "<all>" : i->first.c_str(), (unsigned long)i->second); + user->WriteServ("NOTICE %s :*** %d. IP: %s Port: %lu", user->nick.c_str(), j, i->first.empty() ? "<all>" : i->first.c_str(), (unsigned long)i->second); } ServerInstance->Threads->Mutex(false); } @@ -1249,14 +1249,14 @@ void ServerConfig::Read(bool bail, User* user) ServerInstance->SNO->WriteToSnoMask('A', "*** REHASH UNLOADED MODULE: %s",removing->c_str()); if (user) - user->WriteNumeric(973, "%s %s :Module %s successfully unloaded.",user->nick, removing->c_str(), removing->c_str()); + user->WriteNumeric(973, "%s %s :Module %s successfully unloaded.",user->nick.c_str(), removing->c_str(), removing->c_str()); rem++; } else { if (user) - user->WriteNumeric(972, "%s %s :Failed to unload module %s: %s",user->nick, removing->c_str(), removing->c_str(), ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(972, "%s %s :Failed to unload module %s: %s",user->nick.c_str(), removing->c_str(), removing->c_str(), ServerInstance->Modules->LastError().c_str()); } } } @@ -1270,14 +1270,14 @@ void ServerConfig::Read(bool bail, User* user) ServerInstance->SNO->WriteToSnoMask('A', "*** REHASH LOADED MODULE: %s",adding->c_str()); if (user) - user->WriteNumeric(975, "%s %s :Module %s successfully loaded.",user->nick, adding->c_str(), adding->c_str()); + user->WriteNumeric(975, "%s %s :Module %s successfully loaded.",user->nick.c_str(), adding->c_str(), adding->c_str()); add++; } else { if (user) - user->WriteNumeric(974, "%s %s :Failed to load module %s: %s",user->nick, adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(974, "%s %s :Failed to load module %s: %s",user->nick.c_str(), adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str()); } } } @@ -1294,7 +1294,7 @@ void ServerConfig::Read(bool bail, User* user) ServerInstance->Threads->Mutex(false); if (user) - user->WriteServ("NOTICE %s :*** Successfully rehashed server.", user->nick); + user->WriteServ("NOTICE %s :*** Successfully rehashed server.", user->nick.c_str()); else ServerInstance->SNO->WriteToSnoMask('A', "*** Successfully rehashed server."); diff --git a/src/cull_list.cpp b/src/cull_list.cpp index db9d4978e..26f3b4e43 100644 --- a/src/cull_list.cpp +++ b/src/cull_list.cpp @@ -25,7 +25,7 @@ void CullList::AddItem(User* user) { if (user->quitting) { - ServerInstance->Logs->Log("CULLLIST",DEBUG, "*** Warning *** - You tried to quit a user (%s) twice. Did your module call QuitUser twice?", user->nick); + ServerInstance->Logs->Log("CULLLIST",DEBUG, "*** Warning *** - You tried to quit a user (%s) twice. Did your module call QuitUser twice?", user->nick.c_str()); return; } @@ -50,14 +50,12 @@ int CullList::Apply() User *u = (*a); user_hash::iterator iter = ServerInstance->Users->clientlist->find(u->nick); - const char* preset_reason = u->GetOperQuit(); - std::string reason = u->quitmsg; - std::string oper_reason = *preset_reason ? preset_reason : u->operquitmsg; + const std::string& preset_reason = u->GetOperQuit(); + std::string reason; + std::string oper_reason; - if (reason.length() > MAXQUIT - 1) - reason.resize(MAXQUIT - 1); - if (oper_reason.length() > MAXQUIT - 1) - oper_reason.resize(MAXQUIT - 1); + reason.assign(u->quitmsg, 0, MAXQUIT - 1); + oper_reason.assign(preset_reason.empty() ? preset_reason : u->operquitmsg, 0, MAXQUIT - 1); if (u->registered != REG_ALL) if (ServerInstance->Users->unregistered_count) @@ -106,14 +104,14 @@ int CullList::Apply() { if (!u->quietquit) { - ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",u->nick,u->ident,u->host,oper_reason.c_str()); + ServerInstance->SNO->WriteToSnoMask('q',"Client exiting: %s!%s@%s [%s]",u->nick.c_str(),u->ident.c_str(),u->host,oper_reason.c_str()); } } else { if ((!ServerInstance->SilentULine(u->server)) && (!u->quietquit)) { - ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",u->server,u->nick,u->ident,u->host,oper_reason.c_str()); + ServerInstance->SNO->WriteToSnoMask('Q',"Client exiting on server %s: %s!%s@%s [%s]",u->server,u->nick.c_str(),u->ident.c_str(),u->host,oper_reason.c_str()); } } u->AddToWhoWas(); diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 0edb09084..8b93be245 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -128,7 +128,7 @@ void InspIRCd::SendError(const std::string &s) { if ((*i)->registered == REG_ALL) { - (*i)->WriteServ("NOTICE %s :%s",(*i)->nick,s.c_str()); + (*i)->WriteServ("NOTICE %s :%s",(*i)->nick.c_str(),s.c_str()); } else { diff --git a/src/mode.cpp b/src/mode.cpp index d73a5d1b8..2fb001037 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -251,7 +251,7 @@ User* ModeParser::SanityChecks(User *user, const char *dest, Channel *chan, int) d = ServerInstance->FindNick(dest); if (!d) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, dest); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), dest); return NULL; } return d; @@ -282,7 +282,7 @@ const char* ModeParser::Grant(User *d,Channel *chan,int MASK) n->first->AddVoicedUser(d); break; } - return d->nick; + return d->nick.c_str(); } return ""; } @@ -312,7 +312,7 @@ const char* ModeParser::Revoke(User *d,Channel *chan,int MASK) n->first->DelVoicedUser(d); break; } - return d->nick; + return d->nick.c_str(); } return ""; } @@ -322,35 +322,35 @@ void ModeParser::DisplayCurrentModes(User *user, User* targetuser, Channel* targ if (targetchannel) { /* Display channel's current mode string */ - user->WriteNumeric(324, "%s %s +%s",user->nick, targetchannel->name, targetchannel->ChanModes(targetchannel->HasUser(user))); - user->WriteNumeric(329, "%s %s %lu", user->nick, targetchannel->name, (unsigned long)targetchannel->age); + user->WriteNumeric(324, "%s %s +%s",user->nick.c_str(), targetchannel->name, targetchannel->ChanModes(targetchannel->HasUser(user))); + user->WriteNumeric(329, "%s %s %lu", user->nick.c_str(), targetchannel->name, (unsigned long)targetchannel->age); return; } else if (targetuser) { if (targetuser->Visibility && !targetuser->Visibility->VisibleTo(user)) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, text); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), text); return; } if ((targetuser == user) || (IS_OPER(user))) { /* Display user's current mode string */ - user->WriteNumeric(221, "%s :+%s",targetuser->nick,targetuser->FormatModes()); + user->WriteNumeric(221, "%s :+%s",targetuser->nick.c_str(),targetuser->FormatModes()); if (IS_OPER(targetuser)) - user->WriteNumeric(8, "%s +%s :Server notice mask", targetuser->nick, targetuser->FormatNoticeMasks()); + user->WriteNumeric(8, "%s +%s :Server notice mask", targetuser->nick.c_str(), targetuser->FormatNoticeMasks()); return; } else { - user->WriteNumeric(502, "%s :Can't change mode for other users", user->nick); + user->WriteNumeric(502, "%s :Can't change mode for other users", user->nick.c_str()); return; } } /* No such nick/channel */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, text); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), text); return; } @@ -414,7 +414,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, if (ServerInstance->Config->HideModeLists[mletter] && (targetchannel->GetStatus(user) < STATUS_HOP)) { - user->WriteNumeric(482, "%s %s :Only half-operators and above may view the +%c list",user->nick, targetchannel->name, *mode++); + user->WriteNumeric(482, "%s %s :Only half-operators and above may view the +%c list",user->nick.c_str(), targetchannel->name, *mode++); mh->DisplayEmptyList(user, targetchannel); continue; } @@ -478,14 +478,14 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, mask = MASK_USER; if ((user != targetuser) && (!ServerInstance->ULine(user->server))) { - user->WriteNumeric(502, "%s :Can't change mode for other users", user->nick); + user->WriteNumeric(502, "%s :Can't change mode for other users", user->nick.c_str()); return; } } else { /* No such nick/channel */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick, parameters[0].c_str()); + user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); return; } @@ -612,7 +612,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, { /* Bog off */ user->WriteNumeric(482, "%s %s :You must have channel privilege %c or above to %sset channel mode %c", - user->nick, targetchannel->name, needed, adding ? "" : "un", modechar); + user->nick.c_str(), targetchannel->name, needed, adding ? "" : "un", modechar); continue; } } @@ -646,15 +646,15 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, if (IS_OPER(user)) { user->WriteNumeric(481, "%s :Permission Denied - Oper type %s does not have access to set %s mode %c", - user->nick, - user->oper, + user->nick.c_str(), + user->oper.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modehandlers[handler_id]->GetModeChar()); } else { user->WriteNumeric(481, "%s :Permission Denied - Only operators may set %s mode %c", - user->nick, + user->nick.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modehandlers[handler_id]->GetModeChar()); } @@ -723,7 +723,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, else { /* No mode handler? Unknown mode character then. */ - user->WriteServ("%d %s %c :is unknown mode char to me", type == MODETYPE_CHANNEL ? 472 : 501, user->nick, modechar); + user->WriteServ("%d %s %c :is unknown mode char to me", type == MODETYPE_CHANNEL ? 472 : 501, user->nick.c_str(), modechar); } break; } @@ -741,7 +741,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, } else { - targetuser->WriteServ("MODE %s %s%s",targetuser->nick,output_sequence.c_str(), parameter_list.str().c_str()); + targetuser->WriteServ("MODE %s %s%s",targetuser->nick.c_str(),output_sequence.c_str(), parameter_list.str().c_str()); this->LastParse = targetuser->nick; } } @@ -755,7 +755,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user, } else { - user->WriteTo(targetuser,"MODE %s %s%s",targetuser->nick,output_sequence.c_str(), parameter_list.str().c_str()); + user->WriteTo(targetuser,"MODE %s %s%s",targetuser->nick.c_str(),output_sequence.c_str(), parameter_list.str().c_str()); FOREACH_MOD(I_OnMode,OnMode(user, targetuser, TYPE_USER, output_sequence + parameter_list.str())); this->LastParse = targetuser->nick; } diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp index d6495313a..92001b7fd 100644 --- a/src/modes/cmode_b.cpp +++ b/src/modes/cmode_b.cpp @@ -81,15 +81,15 @@ void ModeChannelBan::DisplayList(User* user, Channel* channel) /* Display the channel banlist */ for (BanList::reverse_iterator i = channel->bans.rbegin(); i != channel->bans.rend(); ++i) { - user->WriteServ("367 %s %s %s %s %lu",user->nick, channel->name, i->data, i->set_by, (unsigned long)i->set_time); + user->WriteServ("367 %s %s %s %s %lu",user->nick.c_str(), channel->name, i->data, i->set_by, (unsigned long)i->set_time); } - user->WriteServ("368 %s %s :End of channel ban list",user->nick, channel->name); + user->WriteServ("368 %s %s :End of channel ban list",user->nick.c_str(), channel->name); return; } void ModeChannelBan::DisplayEmptyList(User* user, Channel* channel) { - user->WriteServ("368 %s %s :End of channel ban list",user->nick, channel->name); + user->WriteServ("368 %s %s :End of channel ban list",user->nick.c_str(), channel->name); } std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan, int, bool servermode) @@ -110,7 +110,7 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan long maxbans = chan->GetMaxBans(); if ((unsigned)chan->bans.size() > (unsigned)maxbans) { - user->WriteServ("478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %ld)",user->nick, chan->name,chan->name,maxbans); + user->WriteServ("478 %s %s :Channel ban list for %s is full (maximum entries for this channel is %ld)",user->nick.c_str(), chan->name,chan->name,maxbans); dest = ""; return dest; } @@ -135,7 +135,7 @@ std::string& ModeChannelBan::AddBan(User *user, std::string &dest, Channel *chan b.set_time = ServerInstance->Time(); strlcpy(b.data, dest.c_str(), MAXBUF); - strlcpy(b.set_by, servermode ? ServerInstance->Config->ServerName : user->nick, 63); + strlcpy(b.set_by, servermode ? ServerInstance->Config->ServerName : user->nick.c_str(), 63); chan->bans.push_back(b); return dest; } diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp index 6dd941353..df27c3f50 100644 --- a/src/modes/cmode_h.cpp +++ b/src/modes/cmode_h.cpp @@ -125,7 +125,7 @@ std::string ModeChannelHalfOp::AddHalfOp(User *user,const char* dest,Channel *ch { if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server))) { - user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name); + user->WriteServ("482 %s %s :You're not a channel operator",user->nick.c_str(), chan->name); return ""; } } @@ -153,7 +153,7 @@ std::string ModeChannelHalfOp::DelHalfOp(User *user,const char *dest,Channel *ch { if ((user != d) && ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)))) { - user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name); + user->WriteServ("482 %s %s :You are not a channel operator",user->nick.c_str(), chan->name); return ""; } } diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp index 0582dbee5..fe40adba6 100644 --- a/src/modes/cmode_o.cpp +++ b/src/modes/cmode_o.cpp @@ -114,7 +114,7 @@ std::string ModeChannelOp::AddOp(User *user,const char* dest,Channel *chan,int s { if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server))) { - user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name); + user->WriteServ("482 %s %s :You're not a channel operator",user->nick.c_str(), chan->name); return ""; } } @@ -142,7 +142,7 @@ std::string ModeChannelOp::DelOp(User *user,const char *dest,Channel *chan,int s { if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)) && (IS_LOCAL(user))) { - user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name); + user->WriteServ("482 %s %s :You are not a channel operator",user->nick.c_str(), chan->name); return ""; } } diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp index 8e13ba6f1..7feb2efc2 100644 --- a/src/modes/cmode_v.cpp +++ b/src/modes/cmode_v.cpp @@ -114,7 +114,7 @@ std::string ModeChannelVoice::AddVoice(User *user,const char* dest,Channel *chan { if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server))) { - user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick, chan->name); + user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick.c_str(), chan->name); return ""; } } @@ -142,7 +142,7 @@ std::string ModeChannelVoice::DelVoice(User *user,const char *dest,Channel *chan { if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server))) { - user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick, chan->name); + user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick.c_str(), chan->name); return ""; } } diff --git a/src/modes/umode_n.cpp b/src/modes/umode_n.cpp index fe75fd222..ed08b60f4 100644 --- a/src/modes/umode_n.cpp +++ b/src/modes/umode_n.cpp @@ -24,7 +24,7 @@ ModeUserServerNoticeMask::ModeUserServerNoticeMask(InspIRCd* Instance) : ModeHan ModeAction ModeUserServerNoticeMask::OnModeChange(User* source, User* dest, Channel*, std::string ¶meter, bool adding, bool servermode) { /* Only opers can change other users modes */ - if ((source != dest) && (!*source->oper)) + if ((source != dest) && (!IS_OPER(source))) return MODEACTION_DENY; /* Set the array fields */ diff --git a/src/modes/umode_o.cpp b/src/modes/umode_o.cpp index 17476c707..7cee7d238 100644 --- a/src/modes/umode_o.cpp +++ b/src/modes/umode_o.cpp @@ -24,7 +24,7 @@ ModeUserOperator::ModeUserOperator(InspIRCd* Instance) : ModeHandler(Instance, ' ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, std::string&, bool adding, bool servermode) { /* Only opers can execute this class at all */ - if (!*source->oper) + if (!IS_OPER(source)) return MODEACTION_DENY; /* Not even opers can GIVE the +o mode, only take it away */ @@ -37,7 +37,7 @@ ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, st * verifying as an oper and getting an opertype assigned * to your User! */ - ServerInstance->SNO->WriteToSnoMask('o', "User %s de-opered (by %s)", dest->nick, source->nick); + ServerInstance->SNO->WriteToSnoMask('o', "User %s de-opered (by %s)", dest->nick.c_str(), source->nick.c_str()); dest->UnOper(); return MODEACTION_ALLOW; diff --git a/src/snomasks.cpp b/src/snomasks.cpp index f4dfdc1e1..e4c02057f 100644 --- a/src/snomasks.cpp +++ b/src/snomasks.cpp @@ -138,10 +138,10 @@ void Snomask::Flush() if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsModeSet('n') && a->IsNoticeMaskSet(MySnomask) && !a->quitting) { - a->WriteServ("NOTICE %s :*** %s: %s", a->nick, this->Description.c_str(), this->LastMessage.c_str()); + a->WriteServ("NOTICE %s :*** %s: %s", a->nick.c_str(), this->Description.c_str(), this->LastMessage.c_str()); if (Count > 1) { - a->WriteServ("NOTICE %s :*** %s: (last message repeated %u times)", a->nick, this->Description.c_str(), Count); + a->WriteServ("NOTICE %s :*** %s: (last message repeated %u times)", a->nick.c_str(), this->Description.c_str(), Count); } } } diff --git a/src/user_resolver.cpp b/src/user_resolver.cpp index 3f010df03..b962be781 100644 --- a/src/user_resolver.cpp +++ b/src/user_resolver.cpp @@ -76,7 +76,7 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, this->bound_user->WriteServ("NOTICE Auth :*** Found your hostname (%s)%s", hostname.c_str(), (cached ? " -- cached" : "")); this->bound_user->dns_done = true; - strlcpy(this->bound_user->dhost, hostname.c_str(),64); + this->bound_user->dhost.assign(hostname, 0, 64); strlcpy(this->bound_user->host, hostname.c_str(),64); /* Invalidate cache */ this->bound_user->InvalidateCache(); diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 139ccb4c4..985e0e289 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -70,11 +70,11 @@ void UserManager::AddUser(InspIRCd* Instance, int socket, int port, bool iscache (*(this->clientlist))[New->uuid] = New; /* The users default nick is their UUID */ - strlcpy(New->nick, New->uuid, NICKMAX - 1); + New->nick.assign(New->uuid, 0, NICKMAX - 1); New->server = Instance->FindServerNamePtr(Instance->Config->ServerName); /* We don't need range checking here, we KNOW 'unknown\0' will fit into the ident field. */ - strcpy(New->ident, "unknown"); + New->ident.assign("unknown"); New->registered = REG_NONE; New->signon = Instance->Time() + Instance->Config->dns_timeout; @@ -145,7 +145,7 @@ void UserManager::AddUser(InspIRCd* Instance, int socket, int port, bool iscache /* user banned */ Instance->Logs->Log("BANCACHE", DEBUG, std::string("BanCache: Positive hit for ") + New->GetIPString()); if (*Instance->Config->MoronBanner) - New->WriteServ("NOTICE %s :*** %s", New->nick, Instance->Config->MoronBanner); + New->WriteServ("NOTICE %s :*** %s", New->nick.c_str(), Instance->Config->MoronBanner); this->QuitUser(New, b->Reason); return; } @@ -181,7 +181,7 @@ void UserManager::AddUser(InspIRCd* Instance, int socket, int port, bool iscache if (Instance->Config->NoUserDns) { - New->WriteServ("NOTICE %s :*** Skipping host resolution (disabled by server administrator)", New->nick); + New->WriteServ("NOTICE %s :*** Skipping host resolution (disabled by server administrator)", New->nick.c_str()); New->dns_done = true; } else @@ -192,8 +192,8 @@ void UserManager::AddUser(InspIRCd* Instance, int socket, int port, bool iscache void UserManager::QuitUser(User *user, const std::string &quitreason, const char* operreason) { - ServerInstance->Logs->Log("USERS", DEBUG,"QuitUser: %s '%s'", user->nick, quitreason.c_str()); - user->Write("ERROR :Closing link (%s@%s) [%s]", user->ident, user->host, *operreason ? operreason : quitreason.c_str()); + ServerInstance->Logs->Log("USERS", DEBUG,"QuitUser: %s '%s'", user->nick.c_str(), quitreason.c_str()); + user->Write("ERROR :Closing link (%s@%s) [%s]", user->ident.c_str(), user->host, *operreason ? operreason : quitreason.c_str()); user->quietquit = false; user->quitmsg = quitreason; @@ -377,7 +377,7 @@ void UserManager::WriteMode(const char* modes, int flags, const char* text, ...) } if (send_to_user) { - t->WriteServ("NOTICE %s :%s", t->nick, textbuffer); + t->WriteServ("NOTICE %s :%s", t->nick.c_str(), textbuffer); } } } @@ -399,7 +399,7 @@ void UserManager::WriteMode(const char* modes, int flags, const char* text, ...) if (send_to_user) { - t->WriteServ("NOTICE %s :%s", t->nick, textbuffer); + t->WriteServ("NOTICE %s :%s", t->nick.c_str(), textbuffer); } } } diff --git a/src/userprocess.cpp b/src/userprocess.cpp index 286135f22..cf1fd86c1 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -21,10 +21,10 @@ void FloodQuitUserHandler::Call(User* current) { - Server->Logs->Log("USERS",DEFAULT,"Excess flood from: %s@%s", current->ident, current->host); + Server->Logs->Log("USERS",DEFAULT,"Excess flood from: %s@%s", current->ident.c_str(), current->host); Server->SNO->WriteToSnoMask('f',"Excess flood from: %s%s%s@%s", - current->registered == REG_ALL ? current->nick : "", - current->registered == REG_ALL ? "!" : "", current->ident, current->host); + current->registered == REG_ALL ? current->nick.c_str() : "", + current->registered == REG_ALL ? "!" : "", current->ident.c_str(), current->host); Server->Users->QuitUser(current, "Excess flood"); if (current->registered != REG_ALL) @@ -120,7 +120,7 @@ void ProcessUserHandler::Call(User* cu) Server->FloodQuitUser(current); else { - current->WriteServ("NOTICE %s :Your previous line was too long and was not delivered (Over %d chars) Please shorten it.", current->nick, MAXBUF-2); + current->WriteServ("NOTICE %s :Your previous line was too long and was not delivered (Over %d chars) Please shorten it.", current->nick.c_str(), MAXBUF-2); current->recvq.clear(); } } diff --git a/src/users.cpp b/src/users.cpp index db23d5672..aa9d570ac 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -82,7 +82,7 @@ std::string User::ProcessNoticeMasks(const char *sm) } } else - this->WriteNumeric(501, "%s %c :is unknown snomask char to me", this->nick, *c); + this->WriteNumeric(501, "%s %c :is unknown snomask char to me", this->nick.c_str(), *c); oldadding = adding; break; @@ -185,7 +185,7 @@ void User::DecrementModes() User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance) { - *password = *nick = *ident = *host = *dhost = *fullname = *awaymsg = *oper = *uuid = 0; + *host = 0; server = (char*)Instance->FindServerNamePtr(Instance->Config->ServerName); reset_due = ServerInstance->Time(); age = ServerInstance->Time(); @@ -209,15 +209,13 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance invites.clear(); memset(modes,0,sizeof(modes)); memset(snomasks,0,sizeof(snomasks)); - /* Invalidate cache */ - cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL; if (uid.empty()) - strlcpy(uuid, Instance->GetUID().c_str(), UUID_LENGTH); + uuid.assign(Instance->GetUID(), 0, UUID_LENGTH); else - strlcpy(uuid, uid.c_str(), UUID_LENGTH); + uuid.assign(uid, 0, UUID_LENGTH); - ServerInstance->Logs->Log("USERS", DEBUG,"New UUID for user: %s (%s)", uuid, uid.empty() ? "allocated new" : "used remote"); + ServerInstance->Logs->Log("USERS", DEBUG,"New UUID for user: %s (%s)", uuid.c_str(), uid.empty() ? "allocated new" : "used remote"); user_hash::iterator finduuid = Instance->Users->uuidlist->find(uuid); if (finduuid == Instance->Users->uuidlist->end()) @@ -274,42 +272,42 @@ User::~User() ServerInstance->Users->uuidlist->erase(uuid); } -char* User::MakeHost() +const std::string& User::MakeHost() { - if (this->cached_makehost) + if (!this->cached_makehost.empty()) return this->cached_makehost; char nhost[MAXBUF]; /* This is much faster than snprintf */ char* t = nhost; - for(char* n = ident; *n; n++) + for(const char* n = ident.c_str(); *n; n++) *t++ = *n; *t++ = '@'; - for(char* n = host; *n; n++) + for(const char* n = host; *n; n++) *t++ = *n; *t = 0; - this->cached_makehost = strdup(nhost); + this->cached_makehost.assign(nhost); return this->cached_makehost; } -char* User::MakeHostIP() +const std::string& User::MakeHostIP() { - if (this->cached_hostip) + if (!this->cached_hostip.empty()) return this->cached_hostip; char ihost[MAXBUF]; /* This is much faster than snprintf */ char* t = ihost; - for(char* n = ident; *n; n++) + for(const char* n = ident.c_str(); *n; n++) *t++ = *n; *t++ = '@'; for(const char* n = this->GetIPString(); *n; n++) *t++ = *n; *t = 0; - this->cached_hostip = strdup(ihost); + this->cached_hostip = ihost; return this->cached_hostip; } @@ -323,24 +321,24 @@ void User::CloseSocket() } } -char* User::GetFullHost() +const std::string& User::GetFullHost() { - if (this->cached_fullhost) + if (!this->cached_fullhost.empty()) return this->cached_fullhost; char result[MAXBUF]; char* t = result; - for(char* n = nick; *n; n++) + for(const char* n = nick.c_str(); *n; n++) *t++ = *n; *t++ = '!'; - for(char* n = ident; *n; n++) + for(const char* n = ident.c_str(); *n; n++) *t++ = *n; *t++ = '@'; - for(char* n = dhost; *n; n++) + for(const char* n = dhost.c_str(); *n; n++) *t++ = *n; *t = 0; - this->cached_fullhost = strdup(result); + this->cached_fullhost = result; return this->cached_fullhost; } @@ -351,7 +349,7 @@ char* User::MakeWildHost() char* t = nresult; *t++ = '*'; *t++ = '!'; *t++ = '*'; *t++ = '@'; - for(char* n = dhost; *n; n++) + for(const char* n = dhost.c_str(); *n; n++) *t++ = *n; *t = 0; return nresult; @@ -372,24 +370,24 @@ int User::ReadData(void* buffer, size_t size) } -char* User::GetFullRealHost() +const std::string& User::GetFullRealHost() { - if (this->cached_fullrealhost) + if (!this->cached_fullrealhost.empty()) return this->cached_fullrealhost; char fresult[MAXBUF]; char* t = fresult; - for(char* n = nick; *n; n++) + for(const char* n = nick.c_str(); *n; n++) *t++ = *n; *t++ = '!'; - for(char* n = ident; *n; n++) + for(const char* n = ident.c_str(); *n; n++) *t++ = *n; *t++ = '@'; for(char* n = host; *n; n++) *t++ = *n; *t = 0; - this->cached_fullrealhost = strdup(fresult); + this->cached_fullrealhost = fresult; return this->cached_fullrealhost; } @@ -564,7 +562,7 @@ bool User::AddBuffer(const std::string &a) if (this->MyClass && (recvq.length() > this->MyClass->GetRecvqMax())) { this->SetWriteError("RecvQ exceeded"); - ServerInstance->SNO->WriteToSnoMask('A', "User %s RecvQ of %lu exceeds connect class maximum of %lu",this->nick,(unsigned long int)recvq.length(),this->MyClass->GetRecvqMax()); + ServerInstance->SNO->WriteToSnoMask('A', "User %s RecvQ of %lu exceeds connect class maximum of %lu",this->nick.c_str(),(unsigned long int)recvq.length(),this->MyClass->GetRecvqMax()); return false; } @@ -634,7 +632,7 @@ void User::AddWriteBuf(const std::string &data) * to repeatedly add the text to the sendq! */ this->SetWriteError("SendQ exceeded"); - ServerInstance->SNO->WriteToSnoMask('A', "User %s SendQ of %lu exceeds connect class maximum of %lu",this->nick,(unsigned long int)sendq.length() + data.length(),this->MyClass->GetSendqMax()); + ServerInstance->SNO->WriteToSnoMask('A', "User %s SendQ of %lu exceeds connect class maximum of %lu",this->nick.c_str(),(unsigned long int)sendq.length() + data.length(),this->MyClass->GetSendqMax()); return; } @@ -721,13 +719,13 @@ void User::Oper(const std::string &opertype, const std::string &opername) try { this->modes[UM_OPERATOR] = 1; - this->WriteServ("MODE %s :+o", this->nick); + this->WriteServ("MODE %s :+o", this->nick.c_str()); FOREACH_MOD(I_OnOper, OnOper(this, opertype)); - ServerInstance->Logs->Log("OPER", DEFAULT, "%s!%s@%s opered as type: %s", this->nick, this->ident, this->host, opertype.c_str()); - strlcpy(this->oper, opertype.c_str(), NICKMAX - 1); + ServerInstance->Logs->Log("OPER", DEFAULT, "%s!%s@%s opered as type: %s", this->nick.c_str(), this->ident.c_str(), this->host, opertype.c_str()); + this->oper.assign(opertype, 0, NICKMAX - 1); ServerInstance->Users->all_opers.push_back(this); - opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper); + opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper.c_str()); if (iter_opertype != ServerInstance->Config->opertypes.end()) { @@ -822,7 +820,7 @@ void User::UnOper() ServerInstance->Parser->CallHandler("MODE", parameters, this); /* unset their oper type (what IS_OPER checks), and remove +o */ - *this->oper = 0; + this->oper.clear(); this->modes[UM_OPERATOR] = 0; /* remove the user from the oper list. Will remove multiple entries as a safeguard against bug #404 */ @@ -933,13 +931,13 @@ void User::FullConnect() CheckLines(); this->WriteServ("NOTICE Auth :Welcome to \002%s\002!",ServerInstance->Config->Network); - this->WriteNumeric(001, "%s :Welcome to the %s IRC Network %s!%s@%s",this->nick, ServerInstance->Config->Network, this->nick, this->ident, this->host); - this->WriteNumeric(002, "%s :Your host is %s, running version InspIRCd-1.2",this->nick,ServerInstance->Config->ServerName); - this->WriteNumeric(003, "%s :This server was created %s %s", this->nick, __TIME__, __DATE__); - this->WriteNumeric(004, "%s %s InspIRCd-1.2 %s %s %s", this->nick, ServerInstance->Config->ServerName, ServerInstance->Modes->UserModeList().c_str(), ServerInstance->Modes->ChannelModeList().c_str(), ServerInstance->Modes->ParaModeList().c_str()); + this->WriteNumeric(001, "%s :Welcome to the %s IRC Network %s!%s@%s",this->nick.c_str(), ServerInstance->Config->Network, this->nick.c_str(), this->ident.c_str(), this->host); + this->WriteNumeric(002, "%s :Your host is %s, running version InspIRCd-1.2",this->nick.c_str(),ServerInstance->Config->ServerName); + this->WriteNumeric(003, "%s :This server was created %s %s", this->nick.c_str(), __TIME__, __DATE__); + this->WriteNumeric(004, "%s %s InspIRCd-1.2 %s %s %s", this->nick.c_str(), ServerInstance->Config->ServerName, ServerInstance->Modes->UserModeList().c_str(), ServerInstance->Modes->ChannelModeList().c_str(), ServerInstance->Modes->ParaModeList().c_str()); ServerInstance->Config->Send005(this); - this->WriteNumeric(42, "%s %s :your unique ID", this->nick, this->uuid); + this->WriteNumeric(42, "%s %s :your unique ID", this->nick.c_str(), this->uuid.c_str()); this->ShowMOTD(); @@ -964,7 +962,7 @@ void User::FullConnect() FOREACH_MOD(I_OnPostConnect,OnPostConnect(this)); - ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d: %s!%s@%s [%s] [%s]", this->GetPort(), this->nick, this->ident, this->host, this->GetIPString(), this->fullname); + ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d: %s!%s@%s [%s] [%s]", this->GetPort(), this->nick.c_str(), this->ident.c_str(), this->host, this->GetIPString(), this->fullname.c_str()); ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Adding NEGATIVE hit for %s", this->GetIPString()); ServerInstance->BanCache->AddHit(this->GetIPString(), "", ""); } @@ -978,7 +976,7 @@ User* User::UpdateNickHash(const char* New) //user_hash::iterator newnick; user_hash::iterator oldnick = ServerInstance->Users->clientlist->find(this->nick); - if (!strcasecmp(this->nick,New)) + if (!irc::string(this->nick.c_str()).compare(New)) return oldnick->second; if (oldnick == ServerInstance->Users->clientlist->end()) @@ -993,15 +991,10 @@ User* User::UpdateNickHash(const char* New) void User::InvalidateCache() { /* Invalidate cache */ - if (cached_fullhost) - free(cached_fullhost); - if (cached_hostip) - free(cached_hostip); - if (cached_makehost) - free(cached_makehost); - if (cached_fullrealhost) - free(cached_fullrealhost); - cached_fullhost = cached_hostip = cached_makehost = cached_fullrealhost = NULL; + cached_fullhost.clear(); + cached_hostip.clear(); + cached_makehost.clear(); + cached_fullrealhost.clear(); } bool User::ForceNickChange(const char* newnick) @@ -1061,7 +1054,7 @@ void User::SetSockAddr(int protocol_family, const char* sip, int port) } break; default: - ServerInstance->Logs->Log("USERS",DEBUG,"Uh oh, I dont know protocol %d to be set on '%s'!", protocol_family, this->nick); + ServerInstance->Logs->Log("USERS",DEBUG,"Uh oh, I dont know protocol %d to be set on '%s'!", protocol_family, this->nick.c_str()); break; } } @@ -1273,7 +1266,7 @@ void User::WriteFrom(User *user, const std::string &text) { char tb[MAXBUF]; - snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),text.c_str()); + snprintf(tb,MAXBUF,":%s %s",user->GetFullHost().c_str(),text.c_str()); this->Write(std::string(tb)); } @@ -1343,7 +1336,7 @@ void User::WriteCommon(const std::string &text) InitializeAlreadySent(ServerInstance->SE); /* We dont want to be doing this n times, just once */ - snprintf(tb,MAXBUF,":%s %s",this->GetFullHost(),text.c_str()); + snprintf(tb,MAXBUF,":%s %s",this->GetFullHost().c_str(),text.c_str()); std::string out = tb; for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++) @@ -1400,8 +1393,8 @@ void User::WriteCommonQuit(const std::string &normal_text, const std::string &op if (!already_sent) InitializeAlreadySent(ServerInstance->SE); - snprintf(tb1,MAXBUF,":%s QUIT :%s",this->GetFullHost(),normal_text.c_str()); - snprintf(tb2,MAXBUF,":%s QUIT :%s",this->GetFullHost(),oper_text.c_str()); + snprintf(tb1,MAXBUF,":%s QUIT :%s",this->GetFullHost().c_str(),normal_text.c_str()); + snprintf(tb2,MAXBUF,":%s QUIT :%s",this->GetFullHost().c_str(),oper_text.c_str()); std::string out1 = tb1; std::string out2 = tb2; @@ -1435,7 +1428,7 @@ void User::WriteCommonExcept(const std::string &text) if (!already_sent) InitializeAlreadySent(ServerInstance->SE); - snprintf(tb1,MAXBUF,":%s %s",this->GetFullHost(),text.c_str()); + snprintf(tb1,MAXBUF,":%s %s",this->GetFullHost().c_str(),text.c_str()); out1 = tb1; for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++) @@ -1518,7 +1511,7 @@ bool User::SharesChannelWith(User *other) bool User::ChangeName(const char* gecos) { - if (!strcmp(gecos, this->fullname)) + if (!this->fullname.compare(gecos)) return true; if (IS_LOCAL(this)) @@ -1529,14 +1522,14 @@ bool User::ChangeName(const char* gecos) return false; FOREACH_MOD(I_OnChangeName,OnChangeName(this,gecos)); } - strlcpy(this->fullname,gecos,MAXGECOS+1); + this->fullname.assign(gecos, 0, MAXGECOS+1); return true; } bool User::ChangeDisplayedHost(const char* shost) { - if (!strcmp(shost, this->dhost)) + if (!this->dhost.compare(shost)) return true; if (IS_LOCAL(this)) @@ -1552,7 +1545,7 @@ bool User::ChangeDisplayedHost(const char* shost) this->WriteCommonExcept("QUIT :Changing hosts"); /* Fix by Om: User::dhost is 65 long, this was truncating some long hosts */ - strlcpy(this->dhost,shost,64); + this->dhost.assign(shost, 0, 64); this->InvalidateCache(); @@ -1568,20 +1561,20 @@ bool User::ChangeDisplayedHost(const char* shost) } if (IS_LOCAL(this)) - this->WriteNumeric(396, "%s %s :is now your displayed host",this->nick,this->dhost); + this->WriteNumeric(396, "%s %s :is now your displayed host",this->nick.c_str(),this->dhost.c_str()); return true; } bool User::ChangeIdent(const char* newident) { - if (!strcmp(newident, this->ident)) + if (!this->ident.compare(newident)) return true; if (this->ServerInstance->Config->CycleHosts) this->WriteCommonExcept("%s","QUIT :Changing ident"); - strlcpy(this->ident, newident, IDENTMAX+1); + this->ident.assign(newident, 0, IDENTMAX + 1); this->InvalidateCache(); @@ -1609,7 +1602,7 @@ void User::SendAll(const char* command, const char* text, ...) vsnprintf(textbuffer, MAXBUF, text, argsPtr); va_end(argsPtr); - snprintf(formatbuffer,MAXBUF,":%s %s $* :%s", this->GetFullHost(), command, textbuffer); + snprintf(formatbuffer,MAXBUF,":%s %s $* :%s", this->GetFullHost().c_str(), command, textbuffer); std::string fmt = formatbuffer; for (std::vector<User*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++) @@ -1695,7 +1688,7 @@ ConnectClass* User::SetClass(const std::string &explicit_name) if (!IS_LOCAL(this)) return NULL; - ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "Setting connect class for UID %s", this->uuid); + ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "Setting connect class for UID %s", this->uuid.c_str()); if (!explicit_name.empty()) { @@ -1845,31 +1838,31 @@ void User::ShowMOTD() { if (!ServerInstance->Config->MOTD.size()) { - this->WriteNumeric(422, "%s :Message of the day file is missing.",this->nick); + this->WriteNumeric(422, "%s :Message of the day file is missing.",this->nick.c_str()); return; } - this->WriteNumeric(375, "%s :%s message of the day", this->nick, ServerInstance->Config->ServerName); + this->WriteNumeric(375, "%s :%s message of the day", this->nick.c_str(), ServerInstance->Config->ServerName); for (file_cache::iterator i = ServerInstance->Config->MOTD.begin(); i != ServerInstance->Config->MOTD.end(); i++) - this->WriteNumeric(372, "%s :- %s",this->nick,i->c_str()); + this->WriteNumeric(372, "%s :- %s",this->nick.c_str(),i->c_str()); - this->WriteNumeric(376, "%s :End of message of the day.", this->nick); + this->WriteNumeric(376, "%s :End of message of the day.", this->nick.c_str()); } void User::ShowRULES() { if (!ServerInstance->Config->RULES.size()) { - this->WriteNumeric(434, "%s :RULES File is missing",this->nick); + this->WriteNumeric(434, "%s :RULES File is missing",this->nick.c_str()); return; } - this->WriteNumeric(308, "%s :- %s Server Rules -",this->nick,ServerInstance->Config->ServerName); + this->WriteNumeric(308, "%s :- %s Server Rules -",this->nick.c_str(),ServerInstance->Config->ServerName); for (file_cache::iterator i = ServerInstance->Config->RULES.begin(); i != ServerInstance->Config->RULES.end(); i++) - this->WriteNumeric(232, "%s :- %s",this->nick,i->c_str()); + this->WriteNumeric(232, "%s :- %s",this->nick.c_str(),i->c_str()); - this->WriteNumeric(309, "%s :End of RULES command.",this->nick); + this->WriteNumeric(309, "%s :End of RULES command.",this->nick.c_str()); } void User::HandleEvent(EventType et, int errornum) @@ -1916,9 +1909,9 @@ void User::SetOperQuit(const std::string &oquit) operquitmsg = oquit; } -const char* User::GetOperQuit() +const std::string& User::GetOperQuit() { - return operquitmsg.c_str(); + return operquitmsg; } void User::IncreasePenalty(int increase) diff --git a/src/xline.cpp b/src/xline.cpp index 1b56f2920..5d5a95516 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -419,7 +419,7 @@ void XLine::DefaultApply(User* u, const std::string &line, bool bancache) char sreason[MAXBUF]; snprintf(sreason, MAXBUF, "%s-Lined: %s", line.c_str(), this->reason); if (*ServerInstance->Config->MoronBanner) - u->WriteServ("NOTICE %s :*** %s", u->nick, ServerInstance->Config->MoronBanner); + u->WriteServ("NOTICE %s :*** %s", u->nick.c_str(), ServerInstance->Config->MoronBanner); if (ServerInstance->Config->HideBans) ServerInstance->Users->QuitUser(u, line + "-Lined", sreason); @@ -526,7 +526,7 @@ bool QLine::Matches(User *u) void QLine::Apply(User* u) { /* Force to uuid on apply of qline, no need to disconnect any more :) */ - u->ForceNickChange(u->uuid); + u->ForceNickChange(u->uuid.c_str()); } |