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");
40 fd = lastping = signon = idle_lastmsg = nping = registered = 0;
41 flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
44 for (int i = 0; i < MAXCHANS; i++)
46 this->chans[i].channel = NULL;
47 this->chans[i].uc_modes = 0;
54 char* userrec::GetFullHost()
56 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,dhost);
61 char* userrec::GetFullRealHost()
63 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,host);
67 bool userrec::IsInvited(char* channel)
69 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
72 if (!strcasecmp(i->channel,channel))
81 void userrec::InviteTo(char* channel)
84 strlcpy(i.channel,channel,CHANMAX);
88 void userrec::RemoveInvite(char* channel)
90 log(DEBUG,"Removing invites");
95 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
99 if (!strcasecmp(i->channel,channel))
110 bool userrec::HasPermission(char* command)
112 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
118 // are they even an oper at all?
119 if (strchr(this->modes,'o'))
121 log(DEBUG,"*** HasPermission: %s is an oper",this->nick);
122 for (int j =0; j < ConfValueEnum("type",&config_f); j++)
124 ConfValue("type","name",j,TypeName,&config_f);
125 if (!strcmp(TypeName,this->oper))
127 log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper);
128 ConfValue("type","classes",j,Classes,&config_f);
129 char* myclass = strtok_r(Classes," ",&savept);
132 log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass);
133 for (int k =0; k < ConfValueEnum("class",&config_f); k++)
135 ConfValue("class","name",k,ClassName,&config_f);
136 if (!strcmp(ClassName,myclass))
138 ConfValue("class","commands",k,CommandList,&config_f);
139 log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList);
142 mycmd = strtok_r(CommandList," ",&savept2);
145 if (!strcasecmp(mycmd,command))
147 log(DEBUG,"*** Command %s found, returning true",command);
150 mycmd = strtok_r(NULL," ",&savept2);
154 myclass = strtok_r(NULL," ",&savept);