/** Command parser, handles client to server commands
*/
- CommandParser* Parser;
+ CommandParser Parser;
/** Thread engine, Handles threading where required
*/
Command::~Command()
{
- ServerInstance->Parser->RemoveCommand(this);
+ ServerInstance->Parser.RemoveCommand(this);
}
void CommandParser::ProcessBuffer(std::string &buffer,LocalUser *user)
std::string thiscmd;
/* Enable everything first */
- const CommandParser::CommandMap& commands = ServerInstance->Parser->GetCommands();
+ const CommandParser::CommandMap& commands = ServerInstance->Parser.GetCommands();
for (CommandParser::CommandMap::const_iterator x = commands.begin(); x != commands.end(); ++x)
x->second->Disable(false);
/* Now disable all the ones which the user wants disabled */
while (dcmds >> thiscmd)
{
- Command* handler = ServerInstance->Parser->GetHandler(thiscmd);
+ Command* handler = ServerInstance->Parser.GetHandler(thiscmd);
if (handler)
handler->Disable(true);
}
*/
CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user)
{
- const CommandParser::CommandMap& commands = ServerInstance->Parser->GetCommands();
+ const CommandParser::CommandMap& commands = ServerInstance->Parser.GetCommands();
std::vector<std::string> list;
list.reserve(commands.size());
for (CommandParser::CommandMap::const_iterator i = commands.begin(); i != commands.end(); ++i)
/* stats m (list number of times each command has been used, plus bytecount) */
case 'm':
{
- const CommandParser::CommandMap& commands = ServerInstance->Parser->GetCommands();
+ const CommandParser::CommandMap& commands = ServerInstance->Parser.GetCommands();
for (CommandParser::CommandMap::const_iterator i = commands.begin(); i != commands.end(); ++i)
{
if (i->second->use_count)
{
results.push_back("249 "+user->nick+" :Users: "+ConvToStr(ServerInstance->Users->GetUsers().size()));
results.push_back("249 "+user->nick+" :Channels: "+ConvToStr(ServerInstance->GetChans().size()));
- results.push_back("249 "+user->nick+" :Commands: "+ConvToStr(ServerInstance->Parser->GetCommands().size()));
+ results.push_back("249 "+user->nick+" :Commands: "+ConvToStr(ServerInstance->Parser.GetCommands().size()));
float kbitpersec_in, kbitpersec_out, kbitpersec_total;
char kbitpersec_in_s[30], kbitpersec_out_s[30], kbitpersec_total_s[30];
DeleteZero(this->Users);
DeleteZero(this->Modes);
DeleteZero(this->XLines);
- DeleteZero(this->Parser);
DeleteZero(this->Modules);
DeleteZero(this->SNO);
DeleteZero(this->Config);
this->Config = 0;
this->SNO = 0;
this->Modules = 0;
- this->Parser = 0;
this->XLines = 0;
this->Modes = 0;
this->ConfigThread = NULL;
this->SNO = new SnomaskManager;
this->Modules = new ModuleManager();
dynamic_reference_base::reset_all();
- this->Parser = new CommandParser;
this->XLines = new XLineManager;
this->Config->cmdline.argv = argv;
switch (item.service)
{
case SERVICE_COMMAND:
- if (!ServerInstance->Parser->AddCommand(static_cast<Command*>(&item)))
+ if (!ServerInstance->Parser.AddCommand(static_cast<Command*>(&item)))
throw ModuleException("Command "+std::string(item.name)+" already exists.");
return;
case SERVICE_MODE:
size_t clen = command.length() - 1;
std::string foundcommand, matchlist;
bool foundmatch = false;
- const CommandParser::CommandMap& commands = ServerInstance->Parser->GetCommands();
+ const CommandParser::CommandMap& commands = ServerInstance->Parser.GetCommands();
for (CommandParser::CommandMap::const_iterator n = commands.begin(); n != commands.end(); ++n)
{
if (!command.compare(0, clen, n->first, 0, clen))
{
pars.push_back(token);
}
- ServerInstance->Parser->CallHandler(command, pars, user);
+ ServerInstance->Parser.CallHandler(command, pars, user);
}
void Prioritize()
if (!user)
return;
- Command* oper_command = ServerInstance->Parser->GetHandler("OPER");
+ Command* oper_command = ServerInstance->Parser.GetHandler("OPER");
if (!oper_command)
return;
if ((user->IsOper()) && (user->HasPermission(command)))
{
- Command* thiscommand = ServerInstance->Parser->GetHandler(command);
+ Command* thiscommand = ServerInstance->Parser.GetHandler(command);
if ((thiscommand) && (thiscommand->flags_needed == 'o'))
{
std::string msg = "[" + user->GetFullRealHost() + "] " + command + " " + irc::stringjoiner(parameters);
tmp.clear();
FormatStr(tmp,forwardcmd, user);
- ServerInstance->Parser->ProcessBuffer(tmp,user);
+ ServerInstance->Parser.ProcessBuffer(tmp,user);
}
};
FileReader reader(file);
CommandShowFile* sfcmd;
- Command* handler = ServerInstance->Parser->GetHandler(cmdname);
+ Command* handler = ServerInstance->Parser.GetHandler(cmdname);
if (handler)
{
// Command exists, check if it is ours
if (IS_LOCAL(u))
{
- ServerInstance->Parser->CallHandler("SILENCE", std::vector<std::string>(parameters.begin() + 1, parameters.end()), u);
+ ServerInstance->Parser.CallHandler("SILENCE", std::vector<std::string>(parameters.begin() + 1, parameters.end()), u);
}
return CMD_SUCCESS;
{
parameterlist plist(params.begin() + 2, params.end());
Command* cmd = NULL;
- ServerInstance->Parser->CallHandler(params[1], plist, user, &cmd);
+ ServerInstance->Parser.CallHandler(params[1], plist, user, &cmd);
// Discard return value, ENCAP shall succeed even if the command does not exist
if ((cmd) && (cmd->force_manual_route))
if (params.size() >= 2)
{
- ServerInstance->Parser->CallHandler("WHOIS", params, issuer);
+ ServerInstance->Parser.CallHandler("WHOIS", params, issuer);
}
else
{
if (!scmd)
{
// Not a special server-to-server command
- cmd = ServerInstance->Parser->GetHandler(command);
+ cmd = ServerInstance->Parser.GetHandler(command);
if (!cmd)
{
if (command == "ERROR")
if (!user)
return;
- Command* oper_command = ServerInstance->Parser->GetHandler("OPER");
+ Command* oper_command = ServerInstance->Parser.GetHandler("OPER");
if (oper_command)
{
if (IS_LOCAL(u))
{
- ServerInstance->Parser->CallHandler("WATCH", parameters, u);
+ ServerInstance->Parser.CallHandler("WATCH", parameters, u);
}
return CMD_SUCCESS;
user->bytes_in += qpos;
user->cmds_in++;
- ServerInstance->Parser->ProcessBuffer(line, user);
+ ServerInstance->Parser.ProcessBuffer(line, user);
if (user->quitting)
return;
}
std::vector<std::string> parameters;
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, command));
if (!MOD_RESULT)
- ServerInstance->Parser->CallHandler(command, parameters, this);
+ ServerInstance->Parser.CallHandler(command, parameters, this);
MOD_RESULT = MOD_RES_PASSTHRU;
command = "MOTD";
FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true, command));
if (!MOD_RESULT)
- ServerInstance->Parser->CallHandler(command, parameters, this);
+ ServerInstance->Parser.CallHandler(command, parameters, this);
if (ServerInstance->Config->RawLog)
WriteServ("PRIVMSG %s :*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.", nick.c_str());