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 * ---------------------------------------------------
19 #include "inspircd_config.h"
21 #include "inspircd_io.h"
22 #include "inspircd_util.h"
24 #include <sys/errno.h>
25 #include <sys/ioctl.h>
26 #include <sys/utsname.h>
30 #include <ext/hash_map>
47 #include "inspstring.h"
48 #include "helperfuncs.h"
51 #define nspace __gnu_cxx
56 extern ServerConfig* Config;
59 extern std::vector<Module*> modules;
60 extern std::vector<ircd_module*> factory;
61 extern int WHOWAS_STALE;
62 extern int WHOWAS_MAX;
63 extern time_t startup_time;
64 extern std::vector<std::string> module_names;
65 extern int boundPortCount;
66 extern std::stringstream config_f;
71 std::vector<ModeParameter> custom_mode_params;
76 strcpy(custom_modes,"");
80 created = topicset = limit = 0;
82 internal_userlist.clear();
85 void chanrec::SetCustomMode(char mode,bool mode_on)
91 if (!strchr(this->custom_modes,mode))
93 strlcat(custom_modes,m,MAXMODES);
95 log(DEBUG,"Custom mode %c set",mode);
99 std::string a = this->custom_modes;
100 int pos = a.find(mode);
102 strncpy(this->custom_modes,a.c_str(),MAXMODES);
104 log(DEBUG,"Custom mode %c removed: modelist='%s'",mode,this->custom_modes);
105 this->SetCustomModeParam(mode,"",false);
110 void chanrec::SetCustomModeParam(char mode,char* parameter,bool mode_on)
113 log(DEBUG,"SetCustomModeParam called");
116 strlcpy(M.channel,this->name,CHANMAX);
117 strlcpy(M.parameter,parameter,MAXBUF);
120 log(DEBUG,"Custom mode parameter %c %s added",mode,parameter);
121 custom_mode_params.push_back(M);
125 if (custom_mode_params.size())
127 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
129 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
131 log(DEBUG,"Custom mode parameter %c %s removed",mode,parameter);
132 custom_mode_params.erase(i);
137 log(DEBUG,"*** BUG *** Attempt to remove non-existent mode parameter!");
141 bool chanrec::IsCustomModeSet(char mode)
143 return (strchr(this->custom_modes,mode));
146 std::string chanrec::GetModeParameter(char mode)
148 if (custom_mode_params.size())
150 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
152 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
161 long chanrec::GetUserCounter()
163 return (this->internal_userlist.size());
166 void chanrec::AddUser(char* castuser)
168 internal_userlist.push_back(castuser);
169 log(DEBUG,"Added casted user to channel's internal list");
172 void chanrec::DelUser(char* castuser)
174 for (std::vector<char*>::iterator a = internal_userlist.begin(); a < internal_userlist.end(); a++)
178 log(DEBUG,"Removed casted user from channel's internal list");
179 internal_userlist.erase(a);
183 log(DEBUG,"BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!",name);
186 std::vector<char*> *chanrec::GetUsers()
188 return &internal_userlist;