From 4e5bd889d93a389299ad73544012149055342d63 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 31 Oct 2007 22:00:25 +0000 Subject: Fix (?) stats chars git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8448 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/xline.h | 23 +++-------------------- src/commands/cmd_stats.cpp | 21 ++++++++------------- src/xline.cpp | 44 ++++++++++++++++---------------------------- 3 files changed, 27 insertions(+), 61 deletions(-) diff --git a/include/xline.h b/include/xline.h index fd7de6d2a..e395c8fba 100644 --- a/include/xline.h +++ b/include/xline.h @@ -501,29 +501,12 @@ class CoreExport XLineManager */ void ApplyLines(); - /** Handle /STATS K + /** Handle /STATS for a given type. + * @param numeric The numeric to give to each result line * @param user The username making the query * @param results The string_list to receive the results */ - void stats_k(User* user, string_list &results); - - /** Handle /STATS G - * @param user The username making the query - * @param results The string_list to receive the results - */ - void stats_g(User* user, string_list &results); - - /** Handle /STATS Q - * @param user The username making the query - * @param results The string_list to receive the results - */ - void stats_q(User* user, string_list &results); - - /** Handle /STATS Z - * @param user The username making the query - * @param results The string_list to receive the results - */ - void stats_z(User* user, string_list &results); + void InvokeStats(const char type, int numeric, User* user, string_list &results); /** Handle /STATS E * @param user The username making the query diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index 73b68dabe..5d4417689 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -140,23 +140,18 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str break; case 'k': - ServerInstance->XLines->stats_k(user,results); - break; - case 'g': - ServerInstance->XLines->stats_g(user,results); - break; - case 'q': - ServerInstance->XLines->stats_q(user,results); - break; - case 'Z': - ServerInstance->XLines->stats_z(user,results); - break; - case 'e': - ServerInstance->XLines->stats_e(user,results); + /* FIXME: Make the 216 here different depending on stats char: + * k: 216 + * g: 223 + * q: 217 + * z: 223 + * e: 223 + */ + ServerInstance->XLines->InvokeStats(toupper(statschar),216,user,results); break; /* stats m (list number of times each command has been used, plus bytecount) */ diff --git a/src/xline.cpp b/src/xline.cpp index 37dc2c0e9..be5bf8588 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -409,40 +409,28 @@ void XLineManager::ApplyLines() pending_lines.clear(); } -void XLineManager::stats_k(User* user, string_list &results) -{ - /*std::string sn = ServerInstance->Config->ServerName; - for (std::vector::iterator i = klines.begin(); i != klines.end(); i++) - results.push_back(sn+" 216 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);*/ -} +/* k: 216 + * g: 223 + * q: 217 + * z: 223 + * e: 223 + */ -void XLineManager::stats_g(User* user, string_list &results) +void XLineManager::InvokeStats(const char type, int numeric, User* user, string_list &results) { - /*std::string sn = ServerInstance->Config->ServerName; - for (std::vector::iterator i = glines.begin(); i != glines.end(); i++) - results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);*/ -} + std::string sn = ServerInstance->Config->ServerName; -void XLineManager::stats_q(User* user, string_list &results) -{ - /*std::string sn = ServerInstance->Config->ServerName; - for (std::vector::iterator i = qlines.begin(); i != qlines.end(); i++) - results.push_back(sn+" 217 "+user->nick+" :"+(*i)->nick+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);*/ -} + std::map >::iterator n = lookup_lines.find(type); -void XLineManager::stats_z(User* user, string_list &results) -{ - /*std::string sn = ServerInstance->Config->ServerName; - for (std::vector::iterator i = zlines.begin(); i != zlines.end(); i++) - results.push_back(sn+" 223 "+user->nick+" :"+(*i)->ipaddr+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);*/ + if (n != lookup_lines.end()) + { + std::map& list = n->second; + for (std::map::iterator i = list.begin(); i != list.end(); i++) + results.push_back(sn+" "+ConvToStr(numeric)+" "+user->nick+" :"+i->second->Displayable()+" "+ + ConvToStr(i->second->set_time)+" "+ConvToStr(i->second->duration)+" "+std::string(i->second->source)+" :"+(i->second->reason)); + } } -void XLineManager::stats_e(User* user, string_list &results) -{ - /*std::string sn = ServerInstance->Config->ServerName; - for (std::vector::iterator i = elines.begin(); i != elines.end(); i++) - results.push_back(sn+" 223 "+user->nick+" :"+(*i)->identmask+"@"+(*i)->hostmask+" "+ConvToStr((*i)->set_time)+" "+ConvToStr((*i)->duration)+" "+(*i)->source+" :"+(*i)->reason);*/ -} XLineManager::XLineManager(InspIRCd* Instance) : ServerInstance(Instance), PermLines(0) { -- cgit v1.2.3