]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_stats.cpp
Attempt to revert r11734
[user/henk/code/inspircd.git] / src / commands / cmd_stats.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #ifndef WIN32
16         #include <sys/resource.h>
17         /* This is just to be completely certain that the change which fixed getrusage on RH7 doesn't break anything else -- Om */
18         #ifndef RUSAGE_SELF
19         #define RUSAGE_SELF 0
20         #endif
21 #else
22         #include <psapi.h>
23         #include "inspircd_win32wrapper.h"
24         #pragma comment(lib, "psapi.lib")
25 #endif
26
27 #include "xline.h"
28
29 /** Handle /STATS. These command handlers can be reloaded by the core,
30  * and handle basic RFC1459 commands. Commands within modules work
31  * the same way, however, they can be fully unloaded, where these
32  * may not.
33  */
34 class CommandStats : public Command
35 {
36  public:
37         /** Constructor for stats.
38          */
39         CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { syntax = "<stats-symbol> [<servername>]"; }
40         /** Handle command.
41          * @param parameters The parameters to the comamnd
42          * @param pcnt The number of parameters passed to teh command
43          * @param user The user issuing the command
44          * @return A value from CmdResult to indicate command success or failure.
45          */
46         CmdResult Handle(const std::vector<std::string>& parameters, User *user);
47 };
48
49 CmdResult CommandStats::Handle (const std::vector<std::string>& parameters, User *user)
50 {
51         if (IS_LOCAL(user))
52         {
53                 string_list values;
54                 if (parameters[0].empty())
55                 {
56                         user->WriteNumeric(ERR_NEEDMOREPARAMS, "%s STATS :Not enough parameters.", user->nick.c_str());
57                         return CMD_FAILURE;
58                 }
59                 char search = parameters[0][0];
60                 ServerInstance->DoStats(search, user, values);
61                 for (size_t i = 0; i < values.size(); i++)
62                         user->Write(":%s", values[i].c_str());
63         }
64
65         return CMD_SUCCESS;
66 }
67
68 COMMAND_INIT(CommandStats)