*/
irc::commasepstream items1(parameters[splithere]);
irc::commasepstream items2(parameters[extra]);
- std::string item("*");
+ std::string extrastuff;
+ std::string item;
unsigned int max = 0;
/* Attempt to iterate these lists and call the command objech
* which called us, for every parameter pair until there are
* no more left to parse.
*/
- while (((item = items1.GetToken()) != "") && (max++ < ServerInstance->Config->MaxTargets))
+ while (items1.GetToken(item) && (max++ < ServerInstance->Config->MaxTargets))
{
if (dupes.find(item.c_str()) == dupes.end())
{
for (int t = 0; (t < pcnt) && (t < MAXPARAMETERS); t++)
new_parameters[t] = parameters[t];
- std::string extrastuff = items2.GetToken();
+ if (!items2.GetToken(extrastuff))
+ extrastuff = "";
new_parameters[splithere] = item.c_str();
new_parameters[extra] = extrastuff.c_str();
/* Only one commasepstream here */
irc::commasepstream items1(parameters[splithere]);
- std::string item("*");
+ std::string item;
unsigned int max = 0;
/* Parse the commasepstream until there are no tokens remaining.
* Each token we parse out, call the command handler that called us
* with it
*/
- while (((item = items1.GetToken()) != "") && (max++ < ServerInstance->Config->MaxTargets))
+ while (items1.GetToken(item) && (max++ < ServerInstance->Config->MaxTargets))
{
if (dupes.find(item.c_str()) == dupes.end())
{
{
/* command is disabled! */
user->WriteServ("421 %s %s :This command has been disabled.",user->nick,command.c_str());
+ ServerInstance->SNO->WriteToSnoMask('d', "%s denied for %s (%s@%s)",
+ command.c_str(), user->nick, user->ident, user->host);
return;
}
if (items < cm->second->min_params)
CommandParser::CommandParser(InspIRCd* Instance) : ServerInstance(Instance)
{
para.resize(128);
- this->SetupCommandTable();
}
bool CommandParser::FindSym(void** v, void* h)
snprintf(filename, MAXBUF, "cmd_%s.so", commandname);
const char* err = this->LoadCommand(filename);
if (err)
- user->WriteServ("NOTICE %s :*** Error loading 'cmd_%s.so': %s", user->nick, cmd, err);
+ {
+ if (user)
+ user->WriteServ("NOTICE %s :*** Error loading 'cmd_%s.so': %s", user->nick, cmd, err);
+ return false;
+ }
return true;
}
}
else
{
- user->WriteServ("NOTICE %s :*** Could not reload command '%s'", user->nick, parameters[0]);
+ user->WriteServ("NOTICE %s :*** Could not reload command '%s' -- fix this problem, then /REHASH as soon as possible!", user->nick, parameters[0]);
return CMD_FAILURE;
}
}
void* h;
command_t* (*cmd_factory_func)(InspIRCd*);
+ /* Command already exists? Succeed silently - this is needed for REHASH */
+ if (RFCCommands.find(name) != RFCCommands.end())
+ {
+ ServerInstance->Log(DEBUG,"Not reloading command %s/%s, it already exists", LIBRARYDIR, name);
+ return NULL;
+ }
+
snprintf(filename, MAXBUF, "%s/%s", LIBRARYDIR, name);
h = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
return NULL;
}
-void CommandParser::SetupCommandTable()
+void CommandParser::SetupCommandTable(userrec* user)
{
RFCCommands.clear();
- printf("\nLoading core commands");
- fflush(stdout);
+ if (!user)
+ {
+ printf("\nLoading core commands");
+ fflush(stdout);
+ }
DIR* library = opendir(LIBRARYDIR);
if (library)
{
if (match(entry->d_name, "cmd_*.so"))
{
- printf(".");
- fflush(stdout);
+ if (!user)
+ {
+ printf(".");
+ fflush(stdout);
+ }
const char* err = this->LoadCommand(entry->d_name);
if (err)
{
- printf("Error loading %s: %s", entry->d_name, err);
- exit(EXIT_STATUS_BADHANDLER);
+ if (user)
+ {
+ user->WriteServ("NOTICE %s :*** Failed to load core command %s: %s", user->nick, entry->d_name, err);
+ }
+ else
+ {
+ printf("Error loading %s: %s", entry->d_name, err);
+ exit(EXIT_STATUS_BADHANDLER);
+ }
}
}
}
closedir(library);
- printf("\n");
+ if (!user)
+ printf("\n");
}
- this->CreateCommand(new cmd_reload(ServerInstance));
+ if (cmdlist.find("RELOAD") == cmdlist.end())
+ this->CreateCommand(new cmd_reload(ServerInstance));
}