summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commands/cmd_commands.cpp9
-rw-r--r--src/commands/cmd_stats.cpp24
-rw-r--r--src/modules/m_check.cpp11
-rw-r--r--src/modules/m_spanningtree/netburst.cpp70
-rw-r--r--src/users.cpp8
5 files changed, 54 insertions, 68 deletions
diff --git a/src/commands/cmd_commands.cpp b/src/commands/cmd_commands.cpp
index 36408b363..99acdfe96 100644
--- a/src/commands/cmd_commands.cpp
+++ b/src/commands/cmd_commands.cpp
@@ -53,12 +53,9 @@ CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user)
continue;
Module* src = i->second->creator;
- char buffer[MAXBUF];
- snprintf(buffer, MAXBUF, ":%s %03d %s :%s %s %d %d",
- ServerInstance->Config->ServerName.c_str(), RPL_COMMANDS, user->nick.c_str(),
- i->second->name.c_str(), src->ModuleSourceFile.c_str(),
- i->second->min_params, i->second->Penalty);
- list.push_back(buffer);
+ list.push_back(InspIRCd::Format(":%s %03d %s :%s %s %d %d", ServerInstance->Config->ServerName.c_str(),
+ RPL_COMMANDS, user->nick.c_str(), i->second->name.c_str(), src->ModuleSourceFile.c_str(),
+ i->second->min_params, i->second->Penalty));
}
sort(list.begin(), list.end());
for(unsigned int i=0; i < list.size(); i++)
diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp
index 3145940be..9fef7bbd4 100644
--- a/src/commands/cmd_stats.cpp
+++ b/src/commands/cmd_stats.cpp
@@ -271,9 +271,9 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results)
}
FILETIME CreationTime;
- FILETIME ExitTime;
- FILETIME KernelTime;
- FILETIME UserTime;
+ FILETIME ExitTime;
+ FILETIME KernelTime;
+ FILETIME UserTime;
LARGE_INTEGER ThisSample;
if(GetProcessTimes(GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &UserTime) &&
QueryPerformanceCounter(&ThisSample))
@@ -301,15 +301,13 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results)
case 'T':
{
- char buffer[MAXBUF];
results.push_back(sn+" 249 "+user->nick+" :accepts "+ConvToStr(ServerInstance->stats->statsAccept)+" refused "+ConvToStr(ServerInstance->stats->statsRefused));
results.push_back(sn+" 249 "+user->nick+" :unknown commands "+ConvToStr(ServerInstance->stats->statsUnknown));
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.c_str(),ServerInstance->stats->statsSent / 1024.0,ServerInstance->stats->statsRecv / 1024.0);
- results.push_back(sn+buffer);
+ results.push_back(InspIRCd::Format("%s 249 %s :bytes sent %5.2fK recv %5.2fK", sn.c_str(), user->nick.c_str(),
+ ServerInstance->stats->statsSent / 1024.0, ServerInstance->stats->statsRecv / 1024.0));
}
break;
@@ -382,15 +380,15 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results)
* Craig suggested this, and it seemed a good idea so in it went */
if (stime->tm_year > 70)
{
- char buffer[MAXBUF];
- 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);
+ results.push_back(InspIRCd::Format("%s 242 %s :Server up %d years, %d days, %.2d:%.2d:%.2d",
+ sn.c_str(), user->nick.c_str(), stime->tm_year - 70, stime->tm_yday, stime->tm_hour,
+ stime->tm_min, stime->tm_sec));
}
else
{
- char buffer[MAXBUF];
- 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);
+ results.push_back(InspIRCd::Format("%s 242 %s :Server up %d days, %.2d:%.2d:%.2d",
+ sn.c_str(), user->nick.c_str(), stime->tm_yday, stime->tm_hour, stime->tm_min,
+ stime->tm_sec));
}
}
break;
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp
index fda211cf8..734089c5b 100644
--- a/src/modules/m_check.cpp
+++ b/src/modules/m_check.cpp
@@ -194,12 +194,13 @@ class CommandCheck : public Command
/* note that unlike /names, we do NOT check +i vs in the channel */
for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++)
{
- char tmpbuf[MAXBUF];
/*
- * Unlike Asuka, I define a clone as coming from the same host. --w00t
- */
- snprintf(tmpbuf, MAXBUF, "%-3lu %s%s (%s@%s) %s ", ServerInstance->Users->GlobalCloneCount(i->first), targchan->GetAllPrefixChars(i->first), i->first->nick.c_str(), i->first->ident.c_str(), i->first->dhost.c_str(), i->first->fullname.c_str());
- user->SendText(checkstr + " member " + tmpbuf);
+ * Unlike Asuka, I define a clone as coming from the same host. --w00t
+ */
+ user->SendText("%s member %-3lu %s%s (%s@%s) %s ",
+ checkstr.c_str(), ServerInstance->Users->GlobalCloneCount(i->first),
+ targchan->GetAllPrefixChars(i->first), i->first->nick.c_str(),
+ i->first->ident.c_str(), i->first->dhost.c_str(), i->first->fullname.c_str());
}
// We know that the mode handler for bans is in the core and is derived from ListModeBase
diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp
index 8daaefd8a..89c8046f5 100644
--- a/src/modules/m_spanningtree/netburst.cpp
+++ b/src/modules/m_spanningtree/netburst.cpp
@@ -66,18 +66,14 @@ void TreeSocket::DoBurst(TreeServer* s)
*/
void TreeSocket::SendServers(TreeServer* Current, TreeServer* s)
{
- char command[MAXBUF];
for (unsigned int q = 0; q < Current->ChildCount(); q++)
{
TreeServer* recursive_server = Current->GetChild(q);
if (recursive_server != s)
{
- std::string recursive_servername = recursive_server->GetName();
- snprintf(command, MAXBUF, ":%s SERVER %s * 0 %s :%s", Current->GetID().c_str(), recursive_servername.c_str(),
- recursive_server->GetID().c_str(),
- recursive_server->GetDesc().c_str());
- this->WriteLine(command);
- this->WriteLine(":"+recursive_server->GetID()+" VERSION :"+recursive_server->GetVersion());
+ this->WriteLine(InspIRCd::Format(":%s SERVER %s * 0 %s :%s", Current->GetID().c_str(),
+ recursive_server->GetName().c_str(), recursive_server->GetID().c_str(), recursive_server->GetDesc().c_str()));
+ this->WriteLine(":" + recursive_server->GetID() + " VERSION :" + recursive_server->GetVersion());
/* down to next level */
this->SendServers(recursive_server, s);
}
@@ -119,8 +115,6 @@ void TreeSocket::SendFJoins(Channel* c)
/** Send all XLines we know about */
void TreeSocket::SendXLines()
{
- char data[MAXBUF];
-
std::vector<std::string> types = ServerInstance->XLines->GetAllTypes();
for (std::vector<std::string>::const_iterator it = types.begin(); it != types.end(); ++it)
@@ -139,15 +133,14 @@ void TreeSocket::SendXLines()
if (!i->second->IsBurstable())
break;
- snprintf(data, MAXBUF, ":%s ADDLINE %s %s %s %lu %lu :%s",
- ServerInstance->Config->GetSID().c_str(),
- it->c_str(),
- i->second->Displayable().c_str(),
- i->second->source.c_str(),
- (unsigned long)i->second->set_time,
- (unsigned long)i->second->duration,
- i->second->reason.c_str());
- this->WriteLine(data);
+ this->WriteLine(InspIRCd::Format(":%s ADDLINE %s %s %s %lu %lu :%s",
+ ServerInstance->Config->GetSID().c_str(),
+ it->c_str(),
+ i->second->Displayable().c_str(),
+ i->second->source.c_str(),
+ (unsigned long)i->second->set_time,
+ (unsigned long)i->second->duration,
+ i->second->reason.c_str()));
}
}
}
@@ -156,16 +149,15 @@ void TreeSocket::SendXLines()
/** Send channel topic, modes and metadata */
void TreeSocket::SyncChannel(Channel* chan)
{
- char data[MAXBUF];
-
SendFJoins(chan);
// If the topic was ever set, send it, even if it's empty now
// because a new empty topic should override an old non-empty topic
if (chan->topicset != 0)
{
- snprintf(data,MAXBUF,":%s FTOPIC %s %lu %lu %s :%s", ServerInstance->Config->GetSID().c_str(), chan->name.c_str(), (unsigned long) chan->age, (unsigned long)chan->topicset, chan->setby.c_str(), chan->topic.c_str());
- this->WriteLine(data);
+ this->WriteLine(InspIRCd::Format(":%s FTOPIC %s %lu %lu %s :%s", ServerInstance->Config->GetSID().c_str(),
+ chan->name.c_str(), (unsigned long)chan->age, (unsigned long)chan->topicset,
+ chan->setby.c_str(), chan->topic.c_str()));
}
for (Extensible::ExtensibleStore::const_iterator i = chan->GetExtList().begin(); i != chan->GetExtList().end(); i++)
@@ -182,7 +174,6 @@ void TreeSocket::SyncChannel(Channel* chan)
/** send all users and their oper state/modes */
void TreeSocket::SendUsers()
{
- char data[MAXBUF];
for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++)
{
if (u->second->registered == REG_ALL)
@@ -190,28 +181,27 @@ void TreeSocket::SendUsers()
TreeServer* theirserver = Utils->FindServer(u->second->server);
if (theirserver)
{
- snprintf(data,MAXBUF,":%s UID %s %lu %s %s %s %s %s %lu +%s :%s",
- theirserver->GetID().c_str(), /* Prefix: SID */
- u->second->uuid.c_str(), /* 0: UUID */
- (unsigned long)u->second->age, /* 1: TS */
- u->second->nick.c_str(), /* 2: Nick */
- u->second->host.c_str(), /* 3: Displayed Host */
- u->second->dhost.c_str(), /* 4: Real host */
- u->second->ident.c_str(), /* 5: Ident */
- u->second->GetIPString().c_str(), /* 6: IP string */
- (unsigned long)u->second->signon, /* 7: Signon time for WHOWAS */
- u->second->FormatModes(true), /* 8...n: Modes and params */
- u->second->fullname.c_str()); /* size-1: GECOS */
- this->WriteLine(data);
+ this->WriteLine(InspIRCd::Format(":%s UID %s %lu %s %s %s %s %s %lu +%s :%s",
+ theirserver->GetID().c_str(), // Prefix: SID
+ u->second->uuid.c_str(), // 0: UUID
+ (unsigned long)u->second->age, // 1: TS
+ u->second->nick.c_str(), // 2: Nick
+ u->second->host.c_str(), // 3: Real host
+ u->second->dhost.c_str(), // 4: Display host
+ u->second->ident.c_str(), // 5: Ident
+ u->second->GetIPString().c_str(), // 6: IP address
+ (unsigned long)u->second->signon, // 7: Signon time
+ u->second->FormatModes(true), // 8...n: User modes and params
+ u->second->fullname.c_str())); // size-1: GECOS
+
if (u->second->IsOper())
{
- snprintf(data,MAXBUF,":%s OPERTYPE :%s", u->second->uuid.c_str(), u->second->oper->name.c_str());
- this->WriteLine(data);
+ this->WriteLine(InspIRCd::Format(":%s OPERTYPE :%s", u->second->uuid.c_str(), u->second->oper->name.c_str()));
}
if (u->second->IsAway())
{
- snprintf(data,MAXBUF,":%s AWAY %ld :%s", u->second->uuid.c_str(), (long)u->second->awaytime, u->second->awaymsg.c_str());
- this->WriteLine(data);
+ this->WriteLine(InspIRCd::Format(":%s AWAY %ld :%s", u->second->uuid.c_str(), (long)u->second->awaytime,
+ u->second->awaymsg.c_str()));
}
}
diff --git a/src/users.cpp b/src/users.cpp
index cd458f68e..a12b322b7 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1051,16 +1051,16 @@ void User::WriteNumeric(unsigned int numeric, const char* text, ...)
void User::WriteNumeric(unsigned int numeric, const std::string &text)
{
- char textbuffer[MAXBUF];
ModResult MOD_RESULT;
FIRST_MOD_RESULT(OnNumeric, MOD_RESULT, (this, numeric, text));
if (MOD_RESULT == MOD_RES_DENY)
return;
-
- snprintf(textbuffer,MAXBUF,":%s %03u %s",ServerInstance->Config->ServerName.c_str(), numeric, text.c_str());
- this->Write(std::string(textbuffer));
+
+ const std::string message = InspIRCd::Format(":%s %03u %s", ServerInstance->Config->ServerName.c_str(),
+ numeric, text.c_str());
+ this->Write(message);
}
void User::WriteFrom(User *user, const std::string &text)