* ---------------------------------------------------
*/
-#include <stdio.h>
-#include <vector>
-#include "users.h"
-#include "channels.h"
#include "inspircd.h"
-#include "modules.h"
#include "wildcard.h"
/* $ModDesc: Sets (and unsets) modes on users when they connect */
public:
ModuleModesOnConnect(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
Conf = new ConfigReader(ServerInstance);
if (!IS_LOCAL(user))
return;
- ServerInstance->Log(DEBUG,"Post connect for mode setting");
for (int j = 0; j < Conf->Enumerate("connect"); j++)
{
std::string hostn = Conf->ReadValue("connect","allow",j);
if ((match(user->GetIPString(),hostn.c_str(),true)) || (match(user->host,hostn.c_str())))
{
- ServerInstance->Log(DEBUG,"Found matching connect block '%s'",hostn.c_str());
std::string ThisModes = Conf->ReadValue("connect","modes",j);
- if (ThisModes != "")
+ if (!ThisModes.empty())
{
std::string buf;
stringstream ss(ThisModes);
tokens.push_back(buf);
int size = tokens.size() + 1;
- const char* modes[size];
+ const char** modes = new const char*[size];
modes[0] = user->nick;
modes[1] = tokens[0].c_str();
}
}
- ServerInstance->Log(DEBUG,"Call mode handler to set modes");
ServerInstance->Parser->CallHandler("MODE", modes, size, user);
+ delete [] modes;
}
break;
}
}
};
-// stuff down here is the module-factory stuff. For basic modules you can ignore this.
-
-class ModuleModesOnConnectFactory : public ModuleFactory
-{
- public:
- ModuleModesOnConnectFactory()
- {
- }
-
- ~ModuleModesOnConnectFactory()
- {
- }
-
- virtual Module * CreateModule(InspIRCd* Me)
- {
- return new ModuleModesOnConnect(Me);
- }
-
-};
-
-
-extern "C" void * init_module( void )
-{
- return new ModuleModesOnConnectFactory;
-}
-
+MODULE_INIT(ModuleModesOnConnect)