Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

channels.cpp

Go to the documentation of this file.
00001 #include "inspircd.h"
00002 #include "inspircd_io.h"
00003 #include "inspircd_util.h"
00004 #include "inspircd_config.h"
00005 #include <unistd.h>
00006 #include <fcntl.h>
00007 #include <sys/errno.h>
00008 #include <sys/ioctl.h>
00009 #include <sys/utsname.h>
00010 #include <cstdio>
00011 #include <time.h>
00012 #include <string>
00013 #ifdef GCC3
00014 #include <ext/hash_map>
00015 #else
00016 #include <hash_map>
00017 #endif
00018 #include <map>
00019 #include <sstream>
00020 #include <vector>
00021 #include <errno.h>
00022 #include <deque>
00023 #include <errno.h>
00024 #include <unistd.h>
00025 #include <sched.h>
00026 #include "connection.h"
00027 #include "users.h"
00028 #include "servers.h"
00029 #include "ctables.h"
00030 #include "globals.h"
00031 #include "modules.h"
00032 #include "dynamic.h"
00033 #include "wildcard.h"
00034 #include "message.h"
00035 #include "mode.h"
00036 #include "xline.h"
00037 
00038 #ifdef GCC3
00039 #define nspace __gnu_cxx
00040 #else
00041 #define nspace std
00042 #endif
00043 
00044 using namespace std;
00045 
00046 extern int MODCOUNT;
00047 extern vector<Module*> modules;
00048 extern vector<ircd_module*> factory;
00049 
00050 extern int LogLevel;
00051 extern char ServerName[MAXBUF];
00052 extern char Network[MAXBUF];
00053 extern char ServerDesc[MAXBUF];
00054 extern char AdminName[MAXBUF];
00055 extern char AdminEmail[MAXBUF];
00056 extern char AdminNick[MAXBUF];
00057 extern char diepass[MAXBUF];
00058 extern char restartpass[MAXBUF];
00059 extern char motd[MAXBUF];
00060 extern char rules[MAXBUF];
00061 extern char list[MAXBUF];
00062 extern char PrefixQuit[MAXBUF];
00063 extern char DieValue[MAXBUF];
00064 
00065 extern int debugging;
00066 extern int WHOWAS_STALE;
00067 extern int WHOWAS_MAX;
00068 extern int DieDelay;
00069 extern time_t startup_time;
00070 extern int NetBufferSize;
00071 int MaxWhoResults;
00072 extern time_t nb_start;
00073 
00074 extern std::vector<int> fd_reap;
00075 extern std::vector<std::string> module_names;
00076 
00077 extern char bannerBuffer[MAXBUF];
00078 extern int boundPortCount;
00079 extern int portCount;
00080 extern int UDPportCount;
00081 extern int ports[MAXSOCKS];
00082 extern int defaultRoute;
00083 
00084 extern std::vector<long> auth_cookies;
00085 extern std::stringstream config_f;
00086 
00087 extern serverrec* me[32];
00088 
00089 extern FILE *log_file;
00090 
00091 
00092 using namespace std;
00093 
00094 std::vector<ModeParameter> custom_mode_params;
00095 
00096 chanrec::chanrec()
00097 {
00098         strcpy(name,"");
00099         strcpy(custom_modes,"");
00100         strcpy(topic,"");
00101         strcpy(setby,"");
00102         strcpy(key,"");
00103         created = topicset = limit = 0;
00104         topiclock = noexternal = inviteonly = moderated = secret = c_private = false;
00105 }
00106 
00107 void chanrec::SetCustomMode(char mode,bool mode_on)
00108 {
00109         if (mode_on) {
00110                 char m[3];
00111                 m[0] = mode;
00112                 m[1] = '\0';
00113                 if (!strchr(this->custom_modes,mode))
00114                 {
00115                         strncat(custom_modes,m,MAXMODES);
00116                 }
00117                 log(DEBUG,"Custom mode %c set",mode);
00118         }
00119         else {
00120                 char temp[MAXBUF];
00121                 int count = 0;
00122                 for (int q = 0; q < strlen(custom_modes); q++) {
00123                         if (custom_modes[q] != mode) {
00124                                 temp[count++] = mode;
00125                         }
00126                 }
00127                 temp[count] = '\0';
00128                 strncpy(custom_modes,temp,MAXMODES);
00129                 log(DEBUG,"Custom mode %c removed",mode);
00130                 this->SetCustomModeParam(mode,"",false);
00131         }
00132 }
00133 
00134 
00135 void chanrec::SetCustomModeParam(char mode,char* parameter,bool mode_on)
00136 {
00137 
00138         log(DEBUG,"SetCustomModeParam called");
00139         ModeParameter M;
00140         M.mode = mode;
00141         strcpy(M.channel,this->name);
00142         strcpy(M.parameter,parameter);
00143         if (mode_on)
00144         {
00145                 log(DEBUG,"Custom mode parameter %c %s added",mode,parameter);
00146                 custom_mode_params.push_back(M);
00147         }
00148         else
00149         {
00150                 if (custom_mode_params.size())
00151                 {
00152                         for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
00153                         {
00154                                 if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
00155                                 {
00156                                         log(DEBUG,"Custom mode parameter %c %s removed",mode,parameter);
00157                                         custom_mode_params.erase(i);
00158                                         return;
00159                                 }
00160                         }
00161                 }
00162                 log(DEBUG,"*** BUG *** Attempt to remove non-existent mode parameter!");
00163         }
00164 }
00165 
00166 bool chanrec::IsCustomModeSet(char mode)
00167 {
00168         log(DEBUG,"Checking ISCustomModeSet: %c %s",mode,this->custom_modes);
00169         return (strchr(this->custom_modes,mode) != 0);
00170 }
00171 
00172 std::string chanrec::GetModeParameter(char mode)
00173 {
00174         if (custom_mode_params.size())
00175         {
00176                 for (vector<ModeParameter>::iterator i = custom_mode_params.begin(); i < custom_mode_params.end(); i++)
00177                 {
00178                         if ((i->mode == mode) && (!strcasecmp(this->name,i->channel)))
00179                         {
00180                                 return std::string(i->parameter);
00181                         }
00182                 }
00183         }
00184         return std::string("");
00185 }

Generated on Sat May 1 20:57:46 2004 for InspIRCd by doxygen1.3-rc3