#include <string>
#include <sstream>
#include <vector>
-#include <sched.h>
-#ifdef THREADED_DNS
-#include <pthread.h>
-#endif
+#include <algorithm>
#include "users.h"
#include "globals.h"
#include "modules.h"
#include "dynamic.h"
#include "wildcard.h"
-#include "message.h"
#include "mode.h"
#include "commands.h"
#include "xline.h"
#include "inspstring.h"
-#include "dnsqueue.h"
#include "helperfuncs.h"
#include "hashcomp.h"
#include "socketengine.h"
extern InspIRCd* ServerInstance;
-extern std::vector<Module*> modules;
-extern std::vector<ircd_module*> factory;
-extern std::vector<InspSocket*> module_sockets;
-extern std::vector<userrec*> local_users;
-
-extern int MODCOUNT;
-extern InspSocket* socket_ref[MAX_DESCRIPTORS];
extern time_t TIME;
-// This table references users by file descriptor.
-// its an array to make it VERY fast, as all lookups are referenced
-// by an integer, meaning there is no need for a scan/search operation.
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
-
extern Server* MyServer;
-extern ServerConfig *Config;
-
-extern user_hash clientlist;
-extern chan_hash chanlist;
/* Special commands which may occur without registration of the user */
cmd_user* command_user;
* Therefore, we need to deal with both lists concurrently. The first instance of this method does that by creating
* two instances of irc::commasepstream and reading them both together until the first runs out of tokens.
* The second version is much simpler and just has the one stream to read, and is used in NAMES, WHOIS, PRIVMSG etc.
- * Both will only parse until they reach Config->MaxTargets number of targets, to stop abuse via spam.
+ * Both will only parse until they reach ServerInstance->Config->MaxTargets number of targets, to stop abuse via spam.
*/
int CommandParser::LoopCall(userrec* user, command_t* CommandObj, const char** parameters, int pcnt, unsigned int splithere, unsigned int extra)
{
* which called us, for every parameter pair until there are
* no more left to parse.
*/
- while (((item = items1.GetToken()) != "") && (max++ < Config->MaxTargets))
+ while (((item = items1.GetToken()) != "") && (max++ < ServerInstance->Config->MaxTargets))
{
std::string extrastuff = items2.GetToken();
parameters[splithere] = item.c_str();
* Each token we parse out, call the command handler that called us
* with it
*/
- while (((item = items1.GetToken()) != "") && (max++ < Config->MaxTargets))
+ while (((item = items1.GetToken()) != "") && (max++ < ServerInstance->Config->MaxTargets))
{
parameters[splithere] = item.c_str();
CommandObj->Handle(parameters,pcnt,user);
while (((para[items] = tokens.GetToken()) != "") && (items < 127))
command_p[items] = para[items++].c_str();
- for (std::string::iterator makeupper = command.begin(); makeupper != command.end(); makeupper++)
- *makeupper = toupper(*makeupper);
+ std::transform(command.begin(), command.end(), command.begin(), ::toupper);
int MOD_RESULT = 0;
FOREACH_RESULT(I_OnPreCommand,OnPreCommand(command,command_p,items,user,false));
{
if (!user->IsModeSet(cm->second->flags_needed))
{
- WriteServ(user->fd,"481 %s :Permission Denied- You do not have the required operator privilages",user->nick);
+ user->WriteServ("481 %s :Permission Denied- You do not have the required operator privilages",user->nick);
+ return;
+ }
+ if (!user->HasPermission(command))
+ {
+ user->WriteServ("481 %s :Permission Denied- Oper type %s does not have access to command %s",user->nick,user->oper,command.c_str());
return;
}
}
- if ((cm->second->flags_needed) && (!user->HasPermission(command)))
- {
- WriteServ(user->fd,"481 %s :Permission Denied- Oper type %s does not have access to command %s",user->nick,user->oper,command.c_str());
- return;
- }
- if ((user->registered == 7) && (!*user->oper) && (cm->second->IsDisabled()))
+ if ((user->registered == REG_ALL) && (!*user->oper) && (cm->second->IsDisabled()))
{
/* command is disabled! */
- WriteServ(user->fd,"421 %s %s :This command has been disabled.",user->nick,command.c_str());
+ user->WriteServ("421 %s %s :This command has been disabled.",user->nick,command.c_str());
return;
}
if (items < cm->second->min_params)
{
+ user->WriteServ("461 %s %s :Not enough parameters.", user->nick, command.c_str());
/* If syntax is given, display this as the 461 reply */
- if (cm->second->syntax.length())
- WriteServ(user->fd,"461 %s %s :Not enough parameters. Syntax: %s %s", user->nick, command.c_str(), cm->second->command.c_str(), cm->second->syntax.c_str());
- else
- WriteServ(user->fd,"461 %s %s :Not enough parameters", user->nick, command.c_str());
+ if ((ServerInstance->Config->SyntaxHints) && (cm->second->syntax.length()))
+ user->WriteServ("304 %s :SYNTAX %s %s", user->nick, cm->second->command.c_str(), cm->second->syntax.c_str());
return;
}
- if ((user->registered == 7) || (cm->second == command_user) || (cm->second == command_nick) || (cm->second == command_pass))
+ if ((user->registered == REG_ALL) || (cm->second == command_user) || (cm->second == command_nick) || (cm->second == command_pass))
{
/* ikky /stats counters */
cm->second->use_count++;
}
else
{
- WriteServ(user->fd,"451 %s :You have not registered",command.c_str());
+ user->WriteServ("451 %s :You have not registered",command.c_str());
return;
}
}
else if (user)
{
ServerInstance->stats->statsUnknown++;
- WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command.c_str());
+ user->WriteServ("421 %s %s :Unknown command",user->nick,command.c_str());
}
}