From 71bedf497cde8b0b38afbb366828b3df9c2803d6 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 19 Dec 2005 18:04:22 +0000 Subject: git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2578 e03df62e-2008-0410-955e-edbf42e46eb7 --- docs/module-doc/channels_8cpp-source.html | 520 +++++++++++++++--------------- 1 file changed, 260 insertions(+), 260 deletions(-) (limited to 'docs/module-doc/channels_8cpp-source.html') diff --git a/docs/module-doc/channels_8cpp-source.html b/docs/module-doc/channels_8cpp-source.html index c8421934a..be9c4fc43 100644 --- a/docs/module-doc/channels_8cpp-source.html +++ b/docs/module-doc/channels_8cpp-source.html @@ -28,269 +28,269 @@ 00019 #include "inspircd_config.h" 00020 #include "inspircd.h" 00021 #include "inspircd_io.h" -00022 #include "inspircd_util.h" -00023 #include <unistd.h> -00024 #include <sys/errno.h> -00025 #include <sys/ioctl.h> -00026 #include <sys/utsname.h> -00027 #include <time.h> -00028 #include <string> -00029 #ifdef GCC3 -00030 #include <ext/hash_map> -00031 #else -00032 #include <hash_map> -00033 #endif -00034 #include <map> -00035 #include <sstream> -00036 #include <vector> -00037 #include <deque> -00038 #include "users.h" -00039 #include "ctables.h" -00040 #include "globals.h" -00041 #include "modules.h" -00042 #include "dynamic.h" -00043 #include "commands.h" -00044 #include "wildcard.h" -00045 #include "message.h" -00046 #include "mode.h" -00047 #include "xline.h" -00048 #include "inspstring.h" -00049 #include "helperfuncs.h" -00050 #include "typedefs.h" -00051 -00052 #ifdef GCC3 -00053 #define nspace __gnu_cxx -00054 #else -00055 #define nspace std -00056 #endif -00057 -00058 extern ServerConfig* Config; -00059 -00060 extern int MODCOUNT; -00061 extern std::vector<Module*> modules; -00062 extern std::vector<ircd_module*> factory; -00063 extern int WHOWAS_STALE; -00064 extern int WHOWAS_MAX; -00065 extern time_t TIME; -00066 extern chan_hash chanlist; -00067 -00068 using namespace std; -00069 -00070 std::vector<ModeParameter> custom_mode_params; -00071 -00072 chanrec* ForceChan(chanrec* Ptr,ucrec &a,userrec* user, int created); -00073 -00074 chanrec::chanrec() -00075 { -00076 strcpy(name,""); -00077 strcpy(custom_modes,""); -00078 strcpy(topic,""); -00079 strcpy(setby,""); -00080 strcpy(key,""); -00081 created = topicset = limit = 0; -00082 binarymodes = 0; -00083 internal_userlist.clear(); -00084 } -00085 -00086 void chanrec::SetCustomMode(char mode,bool mode_on) -00087 { -00088 if (mode_on) { -00089 static char m[3]; -00090 m[0] = mode; -00091 m[1] = '\0'; -00092 if (!strchr(this->custom_modes,mode)) -00093 { -00094 strlcat(custom_modes,m,MAXMODES); -00095 } -00096 log(DEBUG,"Custom mode %c set",mode); -00097 } -00098 else { -00099 -00100 std::string a = this->custom_modes; -00101 int pos = a.find(mode); -00102 a.erase(pos,1); -00103 strncpy(this->custom_modes,a.c_str(),MAXMODES); -00104 -00105 log(DEBUG,"Custom mode %c removed: modelist='%s'",mode,this->custom_modes); -00106 this->SetCustomModeParam(mode,"",false); -00107 } -00108 } +00022 #include <unistd.h> +00023 #include <sys/errno.h> +00024 #include <sys/ioctl.h> +00025 #include <sys/utsname.h> +00026 #include <time.h> +00027 #include <string> +00028 #ifdef GCC3 +00029 #include <ext/hash_map> +00030 #else +00031 #include <hash_map> +00032 #endif +00033 #include <map> +00034 #include <sstream> +00035 #include <vector> +00036 #include <deque> +00037 #include "users.h" +00038 #include "ctables.h" +00039 #include "globals.h" +00040 #include "modules.h" +00041 #include "dynamic.h" +00042 #include "commands.h" +00043 #include "wildcard.h" +00044 #include "message.h" +00045 #include "mode.h" +00046 #include "xline.h" +00047 #include "inspstring.h" +00048 #include "helperfuncs.h" +00049 #include "typedefs.h" +00050 +00051 #ifdef GCC3 +00052 #define nspace __gnu_cxx +00053 #else +00054 #define nspace std +00055 #endif +00056 +00057 extern ServerConfig* Config; +00058 +00059 extern int MODCOUNT; +00060 extern std::vector<Module*> modules; +00061 extern std::vector<ircd_module*> factory; +00062 extern int WHOWAS_STALE; +00063 extern int WHOWAS_MAX; +00064 extern time_t TIME; +00065 extern chan_hash chanlist; +00066 +00067 using namespace std; +00068 +00069 std::vector<ModeParameter> custom_mode_params; +00070 +00071 chanrec* ForceChan(chanrec* Ptr,ucrec &a,userrec* user, int created); +00072 +00073 chanrec::chanrec() +00074 { +00075 strcpy(name,""); +00076 strcpy(custom_modes,""); +00077 strcpy(topic,""); +00078 strcpy(setby,""); +00079 strcpy(key,""); +00080 created = topicset = limit = 0; +00081 binarymodes = 0; +00082 internal_userlist.clear(); +00083 } +00084 +00085 void chanrec::SetCustomMode(char mode,bool mode_on) +00086 { +00087 if (mode_on) { +00088 static char m[3]; +00089 m[0] = mode; +00090 m[1] = '\0'; +00091 if (!strchr(this->custom_modes,mode)) +00092 { +00093 strlcat(custom_modes,m,MAXMODES); +00094 } +00095 log(DEBUG,"Custom mode %c set",mode); +00096 } +00097 else { +00098 +00099 std::string a = this->custom_modes; +00100 int pos = a.find(mode); +00101 a.erase(pos,1); +00102 strncpy(this->custom_modes,a.c_str(),MAXMODES); +00103 +00104 log(DEBUG,"Custom mode %c removed: modelist='%s'",mode,this->custom_modes); +00105 this->SetCustomModeParam(mode,"",false); +00106 } +00107 } +00108 00109 -00110 -00111 void chanrec::SetCustomModeParam(char mode,char* parameter,bool mode_on) -00112 { -00113 -00114 log(DEBUG,"SetCustomModeParam called"); -00115 ModeParameter M; -00116 M.mode = mode; -00117 strlcpy(M.channel,this->name,CHANMAX); -00118 strlcpy(M.parameter,parameter,MAXBUF); -00119 if (mode_on) -00120 { -00121 log(DEBUG,"Custom mode parameter %c %s added",mode,parameter); -00122 custom_mode_params.push_back(M); -00123 } -00124 else -00125 { -00126 if (custom_mode_params.size()) -00127 { -00128 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++) -00129 { -00130 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel))) -00131 { -00132 log(DEBUG,"Custom mode parameter %c %s removed",mode,parameter); -00133 custom_mode_params.erase(i); -00134 return; -00135 } -00136 } -00137 } -00138 log(DEBUG,"*** BUG *** Attempt to remove non-existent mode parameter!"); -00139 } -00140 } -00141 -00142 bool chanrec::IsCustomModeSet(char mode) -00143 { -00144 return (strchr(this->custom_modes,mode)); -00145 } -00146 -00147 std::string chanrec::GetModeParameter(char mode) -00148 { -00149 if (custom_mode_params.size()) -00150 { -00151 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++) -00152 { -00153 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel))) -00154 { -00155 return i->parameter; -00156 } -00157 } -00158 } -00159 return ""; -00160 } -00161 -00162 long chanrec::GetUserCounter() -00163 { -00164 return (this->internal_userlist.size()); -00165 } -00166 -00167 void chanrec::AddUser(char* castuser) -00168 { -00169 internal_userlist.push_back(castuser); -00170 log(DEBUG,"Added casted user to channel's internal list"); -00171 } -00172 -00173 void chanrec::DelUser(char* castuser) -00174 { -00175 for (std::vector<char*>::iterator a = internal_userlist.begin(); a < internal_userlist.end(); a++) -00176 { -00177 if (*a == castuser) -00178 { -00179 log(DEBUG,"Removed casted user from channel's internal list"); -00180 internal_userlist.erase(a); -00181 return; -00182 } -00183 } -00184 log(DEBUG,"BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!",name); -00185 } -00186 -00187 std::vector<char*> *chanrec::GetUsers() -00188 { -00189 return &internal_userlist; -00190 } -00191 -00192 /* add a channel to a user, creating the record for it if needed and linking -00193 * it to the user record */ -00194 -00195 chanrec* add_channel(userrec *user, const char* cn, const char* key, bool override) -00196 { -00197 if ((!user) || (!cn)) -00198 { -00199 log(DEFAULT,"*** BUG *** add_channel was given an invalid parameter"); -00200 return 0; -00201 } -00202 -00203 int created = 0; -00204 char cname[MAXBUF]; -00205 int MOD_RESULT = 0; -00206 strncpy(cname,cn,CHANMAX); -00207 -00208 log(DEBUG,"add_channel: %s %s",user->nick,cname); -00209 -00210 chanrec* Ptr = FindChan(cname); -00211 -00212 if (!Ptr) -00213 { -00214 if (user->fd > -1) -00215 { -00216 MOD_RESULT = 0; -00217 FOREACH_RESULT(OnUserPreJoin(user,NULL,cname)); -00218 if (MOD_RESULT == 1) -00219 return NULL; -00220 } -00221 /* create a new one */ -00222 chanlist[cname] = new chanrec(); -00223 strlcpy(chanlist[cname]->name, cname,CHANMAX); -00224 chanlist[cname]->binarymodes = CM_TOPICLOCK | CM_NOEXTERNAL; -00225 chanlist[cname]->created = TIME; -00226 strcpy(chanlist[cname]->topic, ""); -00227 strncpy(chanlist[cname]->setby, user->nick,NICKMAX); -00228 chanlist[cname]->topicset = 0; -00229 Ptr = chanlist[cname]; -00230 log(DEBUG,"add_channel: created: %s",cname); -00231 /* set created to 2 to indicate user -00232 * is the first in the channel -00233 * and should be given ops */ -00234 created = 2; -00235 } -00236 else -00237 { -00238 /* Already on the channel */ -00239 if (has_channel(user,Ptr)) -00240 return NULL; -00241 -00242 // remote users are allowed us to bypass channel modes -00243 // and bans (used by servers) -00244 if (user->fd > -1) -00245 { -00246 MOD_RESULT = 0; -00247 FOREACH_RESULT(OnUserPreJoin(user,Ptr,cname)); -00248 if (MOD_RESULT == 1) -00249 { -00250 return NULL; -00251 } -00252 else -00253 { -00254 if (*Ptr->key) -00255 { -00256 MOD_RESULT = 0; -00257 FOREACH_RESULT(OnCheckKey(user, Ptr, key ? key : "")); -00258 if (!MOD_RESULT) -00259 { -00260 if (!key) -00261 { -00262 log(DEBUG,"add_channel: no key given in JOIN"); -00263 WriteServ(user->fd,"475 %s %s :Cannot join channel (Requires key)",user->nick, Ptr->name); -00264 return NULL; -00265 } -00266 else -00267 { -00268 if (strcasecmp(key,Ptr->key)) -00269 { -00270 log(DEBUG,"add_channel: bad key given in JOIN"); -00271 WriteServ(user->fd,"475 %s %s :Cannot join channel (Incorrect key)",user->nick, Ptr->name); -00272 return NULL; -00273 } -00274 } -00275 } -00276 } -00277 if (Ptr->binarymodes & CM_INVITEONLY) -00278 { -00279 MOD_RESULT = 0; +00110 void chanrec::SetCustomModeParam(char mode,char* parameter,bool mode_on) +00111 { +00112 +00113 log(DEBUG,"SetCustomModeParam called"); +00114 ModeParameter M; +00115 M.mode = mode; +00116 strlcpy(M.channel,this->name,CHANMAX); +00117 strlcpy(M.parameter,parameter,MAXBUF); +00118 if (mode_on) +00119 { +00120 log(DEBUG,"Custom mode parameter %c %s added",mode,parameter); +00121 custom_mode_params.push_back(M); +00122 } +00123 else +00124 { +00125 if (custom_mode_params.size()) +00126 { +00127 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++) +00128 { +00129 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel))) +00130 { +00131 log(DEBUG,"Custom mode parameter %c %s removed",mode,parameter); +00132 custom_mode_params.erase(i); +00133 return; +00134 } +00135 } +00136 } +00137 log(DEBUG,"*** BUG *** Attempt to remove non-existent mode parameter!"); +00138 } +00139 } +00140 +00141 bool chanrec::IsCustomModeSet(char mode) +00142 { +00143 return (strchr(this->custom_modes,mode)); +00144 } +00145 +00146 std::string chanrec::GetModeParameter(char mode) +00147 { +00148 if (custom_mode_params.size()) +00149 { +00150 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++) +00151 { +00152 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel))) +00153 { +00154 return i->parameter; +00155 } +00156 } +00157 } +00158 return ""; +00159 } +00160 +00161 long chanrec::GetUserCounter() +00162 { +00163 return (this->internal_userlist.size()); +00164 } +00165 +00166 void chanrec::AddUser(char* castuser) +00167 { +00168 internal_userlist.push_back(castuser); +00169 log(DEBUG,"Added casted user to channel's internal list"); +00170 } +00171 +00172 void chanrec::DelUser(char* castuser) +00173 { +00174 for (std::vector<char*>::iterator a = internal_userlist.begin(); a < internal_userlist.end(); a++) +00175 { +00176 if (*a == castuser) +00177 { +00178 log(DEBUG,"Removed casted user from channel's internal list"); +00179 internal_userlist.erase(a); +00180 return; +00181 } +00182 } +00183 log(DEBUG,"BUG BUG BUG! Attempt to remove an uncasted user from the internal list of %s!",name); +00184 } +00185 +00186 std::vector<char*> *chanrec::GetUsers() +00187 { +00188 return &internal_userlist; +00189 } +00190 +00191 /* add a channel to a user, creating the record for it if needed and linking +00192 * it to the user record */ +00193 +00194 chanrec* add_channel(userrec *user, const char* cn, const char* key, bool override) +00195 { +00196 if ((!user) || (!cn)) +00197 { +00198 log(DEFAULT,"*** BUG *** add_channel was given an invalid parameter"); +00199 return 0; +00200 } +00201 +00202 int created = 0; +00203 char cname[MAXBUF]; +00204 int MOD_RESULT = 0; +00205 strncpy(cname,cn,CHANMAX); +00206 +00207 log(DEBUG,"add_channel: %s %s",user->nick,cname); +00208 +00209 chanrec* Ptr = FindChan(cname); +00210 +00211 if (!Ptr) +00212 { +00213 if (user->fd > -1) +00214 { +00215 MOD_RESULT = 0; +00216 FOREACH_RESULT(OnUserPreJoin(user,NULL,cname)); +00217 if (MOD_RESULT == 1) +00218 return NULL; +00219 } +00220 /* create a new one */ +00221 chanlist[cname] = new chanrec(); +00222 strlcpy(chanlist[cname]->name, cname,CHANMAX); +00223 chanlist[cname]->binarymodes = CM_TOPICLOCK | CM_NOEXTERNAL; +00224 chanlist[cname]->created = TIME; +00225 strcpy(chanlist[cname]->topic, ""); +00226 strncpy(chanlist[cname]->setby, user->nick,NICKMAX); +00227 chanlist[cname]->topicset = 0; +00228 Ptr = chanlist[cname]; +00229 log(DEBUG,"add_channel: created: %s",cname); +00230 /* set created to 2 to indicate user +00231 * is the first in the channel +00232 * and should be given ops */ +00233 created = 2; +00234 } +00235 else +00236 { +00237 /* Already on the channel */ +00238 if (has_channel(user,Ptr)) +00239 return NULL; +00240 +00241 // remote users are allowed us to bypass channel modes +00242 // and bans (used by servers) +00243 if (user->fd > -1) +00244 { +00245 MOD_RESULT = 0; +00246 FOREACH_RESULT(OnUserPreJoin(user,Ptr,cname)); +00247 if (MOD_RESULT == 1) +00248 { +00249 return NULL; +00250 } +00251 else +00252 { +00253 if (*Ptr->key) +00254 { +00255 MOD_RESULT = 0; +00256 FOREACH_RESULT(OnCheckKey(user, Ptr, key ? key : "")); +00257 if (!MOD_RESULT) +00258 { +00259 if (!key) +00260 { +00261 log(DEBUG,"add_channel: no key given in JOIN"); +00262 WriteServ(user->fd,"475 %s %s :Cannot join channel (Requires key)",user->nick, Ptr->name); +00263 return NULL; +00264 } +00265 else +00266 { +00267 if (strcasecmp(key,Ptr->key)) +00268 { +00269 log(DEBUG,"add_channel: bad key given in JOIN"); +00270 WriteServ(user->fd,"475 %s %s :Cannot join channel (Incorrect key)",user->nick, Ptr->name); +00271 return NULL; +00272 } +00273 } +00274 } +00275 } +00276 if (Ptr->binarymodes & CM_INVITEONLY) +00277 { +00278 MOD_RESULT = 0; +00279 irc::string xname(Ptr->name); 00280 FOREACH_RESULT(OnCheckInvite(user, Ptr)); 00281 if (!MOD_RESULT) 00282 { 00283 log(DEBUG,"add_channel: channel is +i"); -00284 if (user->IsInvited(Ptr->name)) +00284 if (user->IsInvited(xname)) 00285 { 00286 /* user was invited to channel */ 00287 /* there may be an optional channel NOTICE here */ @@ -301,7 +301,7 @@ 00292 return NULL; 00293 } 00294 } -00295 user->RemoveInvite(Ptr->name); +00295 user->RemoveInvite(xname); 00296 } 00297 if (Ptr->limit) 00298 { @@ -552,7 +552,7 @@ 00543 } 00544 00545 -
Generated on Thu Dec 15 11:14:14 2005 for InspIRCd by  +
Generated on Mon Dec 19 18:02:13 2005 for InspIRCd by  doxygen 1.4.4-20050815
-- cgit v1.2.3