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"
23 extern std::stringstream config_f;
27 // the PROPER way to do it, AVOID bzero at *ALL* costs
29 strcpy(ip,"127.0.0.1");
39 fd = lastping = signon = idle_lastmsg = nping = registered = 0;
40 flood = port = bytes_in = bytes_out = cmds_in = cmds_out = 0;
43 for (int i = 0; i < MAXCHANS; i++)
45 this->chans[i].channel = NULL;
46 this->chans[i].uc_modes = 0;
53 char* userrec::GetFullHost()
55 sprintf(result,"%s!%s@%s",nick,ident,dhost);
60 char* userrec::GetFullRealHost()
62 sprintf(result,"%s!%s@%s",nick,ident,host);
66 bool userrec::IsInvited(char* channel)
68 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
71 if (!strcasecmp(i->channel,channel))
80 void userrec::InviteTo(char* channel)
83 strcpy(i.channel,channel);
87 void userrec::RemoveInvite(char* channel)
89 log(DEBUG,"Removing invites");
94 for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
98 if (!strcasecmp(i->channel,channel))
109 bool userrec::HasPermission(char* command)
111 char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
117 // are they even an oper at all?
118 if (strchr(this->modes,'o'))
120 log(DEBUG,"*** HasPermission: %s is an oper",this->nick);
121 for (int j =0; j < ConfValueEnum("type",&config_f); j++)
123 ConfValue("type","name",j,TypeName,&config_f);
124 if (!strcmp(TypeName,this->oper))
126 log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper);
127 ConfValue("type","classes",j,Classes,&config_f);
128 char* myclass = strtok_r(Classes," ",&savept);
131 log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass);
132 for (int k =0; k < ConfValueEnum("class",&config_f); k++)
134 ConfValue("class","name",k,ClassName,&config_f);
135 if (!strcmp(ClassName,myclass))
137 ConfValue("class","commands",k,CommandList,&config_f);
138 log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList);
141 mycmd = strtok_r(CommandList," ",&savept2);
144 if (!strcasecmp(mycmd,command))
146 log(DEBUG,"*** Command %s found, returning true",command);
149 mycmd = strtok_r(NULL," ",&savept2);
153 myclass = strtok_r(NULL," ",&savept);