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
57 extern std::vector<Module*> modules;
58 extern std::vector<ircd_module*> factory;
61 extern char ServerName[MAXBUF];
62 extern char Network[MAXBUF];
63 extern char ServerDesc[MAXBUF];
64 extern char AdminName[MAXBUF];
65 extern char AdminEmail[MAXBUF];
66 extern char AdminNick[MAXBUF];
67 extern char diepass[MAXBUF];
68 extern char restartpass[MAXBUF];
69 extern char motd[MAXBUF];
70 extern char rules[MAXBUF];
71 extern char list[MAXBUF];
72 extern char PrefixQuit[MAXBUF];
73 extern char DieValue[MAXBUF];
76 extern int WHOWAS_STALE;
77 extern int WHOWAS_MAX;
79 extern time_t startup_time;
80 extern int NetBufferSize;
82 extern time_t nb_start;
84 extern std::vector<std::string> module_names;
86 extern int boundPortCount;
88 extern int SERVERportCount;
89 extern int ports[MAXSOCKS];
90 extern int defaultRoute;
92 extern std::vector<long> auth_cookies;
93 extern std::stringstream config_f;
95 extern serverrec* me[32];
97 extern FILE *log_file;
103 std::vector<ModeParameter> custom_mode_params;
108 strcpy(custom_modes,"");
112 created = topicset = limit = 0;
114 internal_userlist.clear();
117 void chanrec::SetCustomMode(char mode,bool mode_on)
123 if (!strchr(this->custom_modes,mode))
125 strlcat(custom_modes,m,MAXMODES);
127 log(DEBUG,"Custom mode %c set",mode);
131 std::string a = this->custom_modes;
132 int pos = a.find(mode);
134 strncpy(this->custom_modes,a.c_str(),MAXMODES);
136 log(DEBUG,"Custom mode %c removed: modelist='%s'",mode,this->custom_modes);
137 this->SetCustomModeParam(mode,"",false);
142 void chanrec::SetCustomModeParam(char mode,char* parameter,bool mode_on)
145 log(DEBUG,"SetCustomModeParam called");
148 strlcpy(M.channel,this->name,CHANMAX);
149 strlcpy(M.parameter,parameter,MAXBUF);
152 log(DEBUG,"Custom mode parameter %c %s added",mode,parameter);
153 custom_mode_params.push_back(M);
157 if (custom_mode_params.size())
159 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
161 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
163 log(DEBUG,"Custom mode parameter %c %s removed",mode,parameter);
164 custom_mode_params.erase(i);
169 log(DEBUG,"*** BUG *** Attempt to remove non-existent mode parameter!");
173 bool chanrec::IsCustomModeSet(char mode)
175 log(DEBUG,"Checking ISCustomModeSet: %c %s",mode,this->custom_modes);
176 return (strchr(this->custom_modes,mode) != 0);
179 std::string chanrec::GetModeParameter(char mode)
181 if (custom_mode_params.size())
183 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
185 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
194 long chanrec::GetUserCounter()
196 return (this->internal_userlist.size());
199 void chanrec::AddUser(char* castuser)
201 internal_userlist.push_back(castuser);
202 log(DEBUG,"Added casted user to channel's internal list");
205 void chanrec::DelUser(char* castuser)
207 for (std::vector<char*>::iterator a = internal_userlist.begin(); a < internal_userlist.end(); a++)
211 log(DEBUG,"Removed casted user from channel's internal list");
212 internal_userlist.erase(a);
216 log(DEBUG,"BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!",name);
219 std::vector<char*> *chanrec::GetUsers()
221 return &internal_userlist;