1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 #include "inspircd_config.h"
22 #include "inspstring.h"
24 extern std::stringstream config_f;
30 // the PROPER way to do it, AVOID bzero at *ALL* costs
32 strcpy(ip,"127.0.0.1");
43 fd = lastping = signon = idle_lastmsg = nping = registered = 0;
44 flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
48 for (int i = 0; i < MAXCHANS; i++)
50 this->chans[i].channel = NULL;
51 this->chans[i].uc_modes = 0;
58 char* userrec::GetFullHost()
60 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,dhost);
65 char* userrec::GetFullRealHost()
67 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,host);
71 bool userrec::IsInvited(char* channel)
73 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
76 if (!strcasecmp(i->channel,channel))
85 void userrec::InviteTo(char* channel)
88 strlcpy(i.channel,channel,CHANMAX);
92 void userrec::RemoveInvite(char* channel)
94 log(DEBUG,"Removing invites");
99 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
103 if (!strcasecmp(i->channel,channel))
114 bool userrec::HasPermission(char* command)
116 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
122 // are they even an oper at all?
123 if (strchr(this->modes,'o'))
125 log(DEBUG,"*** HasPermission: %s is an oper",this->nick);
126 for (int j =0; j < ConfValueEnum("type",&config_f); j++)
128 ConfValue("type","name",j,TypeName,&config_f);
129 if (!strcmp(TypeName,this->oper))
131 log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper);
132 ConfValue("type","classes",j,Classes,&config_f);
133 char* myclass = strtok_r(Classes," ",&savept);
136 log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass);
137 for (int k =0; k < ConfValueEnum("class",&config_f); k++)
139 ConfValue("class","name",k,ClassName,&config_f);
140 if (!strcmp(ClassName,myclass))
142 ConfValue("class","commands",k,CommandList,&config_f);
143 log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList);
146 mycmd = strtok_r(CommandList," ",&savept2);
149 if (!strcasecmp(mycmd,command))
151 log(DEBUG,"*** Command %s found, returning true",command);
154 mycmd = strtok_r(NULL," ",&savept2);
158 myclass = strtok_r(NULL," ",&savept);