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;
46 for (int i = 0; i < MAXCHANS; i++)
48 this->chans[i].channel = NULL;
49 this->chans[i].uc_modes = 0;
56 char* userrec::GetFullHost()
58 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,dhost);
63 char* userrec::GetFullRealHost()
65 snprintf(result,MAXBUF,"%s!%s@%s",nick,ident,host);
69 bool userrec::IsInvited(char* channel)
71 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
74 if (!strcasecmp(i->channel,channel))
83 void userrec::InviteTo(char* channel)
86 strlcpy(i.channel,channel,CHANMAX);
90 void userrec::RemoveInvite(char* channel)
92 log(DEBUG,"Removing invites");
97 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
101 if (!strcasecmp(i->channel,channel))
112 bool userrec::HasPermission(char* command)
114 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
120 // are they even an oper at all?
121 if (strchr(this->modes,'o'))
123 log(DEBUG,"*** HasPermission: %s is an oper",this->nick);
124 for (int j =0; j < ConfValueEnum("type",&config_f); j++)
126 ConfValue("type","name",j,TypeName,&config_f);
127 if (!strcmp(TypeName,this->oper))
129 log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper);
130 ConfValue("type","classes",j,Classes,&config_f);
131 char* myclass = strtok_r(Classes," ",&savept);
134 log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass);
135 for (int k =0; k < ConfValueEnum("class",&config_f); k++)
137 ConfValue("class","name",k,ClassName,&config_f);
138 if (!strcmp(ClassName,myclass))
140 ConfValue("class","commands",k,CommandList,&config_f);
141 log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList);
144 mycmd = strtok_r(CommandList," ",&savept2);
147 if (!strcasecmp(mycmd,command))
149 log(DEBUG,"*** Command %s found, returning true",command);
152 mycmd = strtok_r(NULL," ",&savept2);
156 myclass = strtok_r(NULL," ",&savept);