/*
-
-$Log$
-Revision 1.1 2003/01/23 19:45:58 brain
-Initial revision
-
-Revision 1.3 2003/01/17 13:21:38 brain
-Added CONNECT ALLOW and CONNECT DENY config tags
-Added PASS command
-
-Revision 1.2 2003/01/17 10:37:55 brain
-Added /INVITE command and relevent structures
-
-Revision 1.1 2003/01/16 01:10:04 brain
-forgot to add this
-
-
+Manages userrec objects
*/
#include "inspircd_config.h"
#include "inspircd.h"
#include <stdio.h>
+extern std::stringstream config_f;
+
userrec::userrec()
{
// the PROPER way to do it, AVOID bzero at *ALL* costs
strcpy(nick,"");
- ip = 0;
+ strcpy(ip,"127.0.0.1");
+ timeout = 0;
strcpy(ident,"");
strcpy(host,"");
strcpy(dhost,"");
strcpy(server,"");
strcpy(awaymsg,"");
fd = lastping = signon = idle_lastmsg = nping = registered = 0;
- port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
+ flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
haspassed = false;
strcpy(result,"");
for (int i = 0; i < MAXCHANS; i++)
{
- chans[i].channel = NULL;
+ this->chans[i].channel = NULL;
+ this->chans[i].uc_modes = 0;
}
invites.clear();
}
+
char* userrec::GetFullHost()
{
{
for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
{
- if (!strcasecmp(i->channel,channel))
- {
- return true;
+ if (i->channel) {
+ if (!strcasecmp(i->channel,channel))
+ {
+ return true;
+ }
}
}
+ return false;
}
void userrec::InviteTo(char* channel)
void userrec::RemoveInvite(char* channel)
{
- for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
- {
- if (!strcasecmp(i->channel,channel))
- {
- invites.erase(i);
- return;
- }
+ log(DEBUG,"Removing invites");
+ if (channel)
+ {
+ if (invites.size())
+ {
+ for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
+ {
+ if (i->channel)
+ {
+ if (!strcasecmp(i->channel,channel))
+ {
+ invites.erase(i);
+ return;
+ }
+ }
+ }
+ }
}
}
+
+bool userrec::HasPermission(char* command)
+{
+ char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
+ char* myclass;
+ char* mycmd;
+ char* savept;
+ char* savept2;
+
+ // are they even an oper at all?
+ if (strchr(this->modes,'o'))
+ {
+ log(DEBUG,"*** HasPermission: %s is an oper",this->nick);
+ for (int j =0; j < ConfValueEnum("type",&config_f); j++)
+ {
+ ConfValue("type","name",j,TypeName,&config_f);
+ if (!strcmp(TypeName,this->oper))
+ {
+ log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper);
+ ConfValue("type","classes",j,Classes,&config_f);
+ char* myclass = strtok_r(Classes," ",&savept);
+ while (myclass)
+ {
+ log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass);
+ for (int k =0; k < ConfValueEnum("class",&config_f); k++)
+ {
+ ConfValue("class","name",k,ClassName,&config_f);
+ if (!strcmp(ClassName,myclass))
+ {
+ ConfValue("class","commands",k,CommandList,&config_f);
+ log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList);
+
+
+ mycmd = strtok_r(CommandList," ",&savept2);
+ while (mycmd)
+ {
+ if (!strcasecmp(mycmd,command))
+ {
+ log(DEBUG,"*** Command %s found, returning true",command);
+ return true;
+ }
+ mycmd = strtok_r(NULL," ",&savept2);
+ }
+ }
+ }
+ myclass = strtok_r(NULL," ",&savept);
+ }
+ }
+ }
+ }
+ return false;
+}
+
+