2 Manages userrec objects
5 #include "inspircd_config.h"
11 extern std::stringstream config_f;
15 // the PROPER way to do it, AVOID bzero at *ALL* costs
17 strcpy(ip,"127.0.0.1");
27 fd = lastping = signon = idle_lastmsg = nping = registered = 0;
28 flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
31 for (int i = 0; i < MAXCHANS; i++)
33 this->chans[i].channel = NULL;
34 this->chans[i].uc_modes = 0;
41 char* userrec::GetFullHost()
43 sprintf(result,"%s!%s@%s",nick,ident,dhost);
48 char* userrec::GetFullRealHost()
50 sprintf(result,"%s!%s@%s",nick,ident,host);
54 bool userrec::IsInvited(char* channel)
56 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
59 if (!strcasecmp(i->channel,channel))
68 void userrec::InviteTo(char* channel)
71 strcpy(i.channel,channel);
75 void userrec::RemoveInvite(char* channel)
77 log(DEBUG,"Removing invites");
82 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
86 if (!strcasecmp(i->channel,channel))
97 bool userrec::HasPermission(char* command)
99 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
105 // are they even an oper at all?
106 if (strchr(this->modes,'o'))
108 log(DEBUG,"*** HasPermission: %s is an oper",this->nick);
109 for (int j =0; j < ConfValueEnum("type",&config_f); j++)
111 ConfValue("type","name",j,TypeName,&config_f);
112 if (!strcmp(TypeName,this->oper))
114 log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper);
115 ConfValue("type","classes",j,Classes,&config_f);
116 char* myclass = strtok_r(Classes," ",&savept);
119 log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass);
120 for (int k =0; k < ConfValueEnum("class",&config_f); k++)
122 ConfValue("class","name",k,ClassName,&config_f);
123 if (!strcmp(ClassName,myclass))
125 ConfValue("class","commands",k,CommandList,&config_f);
126 log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList);
129 mycmd = strtok_r(CommandList," ",&savept2);
132 if (!strcasecmp(mycmd,command))
134 log(DEBUG,"*** Command %s found, returning true",command);
137 mycmd = strtok_r(NULL," ",&savept2);
141 myclass = strtok_r(NULL," ",&savept);