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;
28 // the PROPER way to do it, AVOID bzero at *ALL* costs
30 strcpy(ip,"127.0.0.1");
41 fd = lastping = signon = idle_lastmsg = nping = registered = 0;
42 flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
45 for (int i = 0; i < MAXCHANS; i++)
47 this->chans[i].channel = NULL;
48 this->chans[i].uc_modes = 0;
55 char* userrec::GetFullHost()
57 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,dhost);
62 char* userrec::GetFullRealHost()
64 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,host);
68 bool userrec::IsInvited(char* channel)
70 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
73 if (!strcasecmp(i->channel,channel))
82 void userrec::InviteTo(char* channel)
85 strlcpy(i.channel,channel,CHANMAX);
89 void userrec::RemoveInvite(char* channel)
91 log(DEBUG,"Removing invites");
96 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
100 if (!strcasecmp(i->channel,channel))
111 bool userrec::HasPermission(char* command)
113 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
119 // are they even an oper at all?
120 if (strchr(this->modes,'o'))
122 log(DEBUG,"*** HasPermission: %s is an oper",this->nick);
123 for (int j =0; j < ConfValueEnum("type",&config_f); j++)
125 ConfValue("type","name",j,TypeName,&config_f);
126 if (!strcmp(TypeName,this->oper))
128 log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper);
129 ConfValue("type","classes",j,Classes,&config_f);
130 char* myclass = strtok_r(Classes," ",&savept);
133 log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass);
134 for (int k =0; k < ConfValueEnum("class",&config_f); k++)
136 ConfValue("class","name",k,ClassName,&config_f);
137 if (!strcmp(ClassName,myclass))
139 ConfValue("class","commands",k,CommandList,&config_f);
140 log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList);
143 mycmd = strtok_r(CommandList," ",&savept2);
146 if (!strcasecmp(mycmd,command))
148 log(DEBUG,"*** Command %s found, returning true",command);
151 mycmd = strtok_r(NULL," ",&savept2);
155 myclass = strtok_r(NULL," ",&savept);