*
* ---------------------------------------------------
*/
+using namespace std;
#include "users.h"
#include "channels.h"
Server *Srv;
public:
- ModuleAntiBottler()
+ ModuleAntiBottler(Server* Me)
+ : Module::Module(Me)
{
- Srv = new Server;
+ Srv = Me;
}
virtual ~ModuleAntiBottler()
{
- delete Srv;
}
virtual Version GetVersion()
{
- return Version(1,0,0,0,0);
+ return Version(1,0,0,1,VF_VENDOR);
}
-
+ /* XXX - OnServerRaw? Wouldn't it be easier to use an OnUserConnect, or something? --w00t */
virtual void OnServerRaw(std::string &raw, bool inbound, userrec* user)
{
if (inbound)
bool not_bottler = false;
if (!strncmp(data,"user ",5))
{
- for (int j = 0; j < strlen(data); j++)
+ for (unsigned int j = 0; j < strlen(data); j++)
{
- if (data[j] = ':')
+ if (data[j] == ':')
break;
- if (data[j] = '"')
+ if (data[j] == '"')
{
not_bottler = true;
}
}
// Bug Fix (#14) -- FCS
- if (!strlen(data)) return;
- char *user = strtok(data," ");
- if (!strlen(data)) return;
+
+ if (!(data) || !(*data))
+ return;
+
+ /*
+ * slight efficiency fix: strtok() just returns NULL if it has no more
+ * tokens to return. Plus strlen's here really could have been replaced
+ * with above pointer voodoo :-). --w00t
+ */
+ strtok(data," ");
char *ident = strtok(NULL," ");
- if (!strlen(data)) return;
char *local = strtok(NULL," ");
- if (!strlen(data)) return;
char *remote = strtok(NULL," :");
- if (!strlen(data)) return;
char *gecos = strtok(NULL,"\r\n");
- for (int j = 0; j < strlen(remote); j++)
+
+ if (!ident || !local || !remote || !gecos)
+ return;
+
+ for (unsigned int j = 0; j < strlen(remote); j++)
{
if (((remote[j] < '0') || (remote[j] > '9')) && (remote[j] != '.'))
{
{
}
- virtual Module * CreateModule()
+ virtual Module * CreateModule(Server* Me)
{
- return new ModuleAntiBottler;
+ return new ModuleAntiBottler(Me);
}
};