]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/helperfuncs.cpp
Changed two fields in ConnectClass to strings, moved constructor stuff to init-list
[user/henk/code/inspircd.git] / src / helperfuncs.cpp
index 691d585093b369972329604750fb2766f5c9c5c4..3bc2bb79aed664196b9a4bf46d4c1f8ffd0996f1 100644 (file)
@@ -52,17 +52,15 @@ using namespace std;
 extern int MODCOUNT;
 extern std::vector<Module*> modules;
 extern ServerConfig *Config;
+extern InspIRCd* ServerInstance;
 extern time_t TIME;
 extern char lowermap[255];
 static char list[MAXBUF];
 extern userrec* fd_ref_table[65536];
-extern serverstats* stats;
 static char already_sent[65536];
 extern std::vector<userrec*> all_opers;
 extern user_hash clientlist;
 extern chan_hash chanlist;
-extern command_table cmdlist;
-extern Module* IOHookModule;
 
 void log(int level,char *text, ...)
 {
@@ -71,7 +69,6 @@ void log(int level,char *text, ...)
         if (level < Config->LogLevel)
                 return;
        char textbuffer[MAXBUF];
-       char tb[MAXBUF];
         timeinfo = localtime(&TIME);
 
         if (Config->log_file)
@@ -142,15 +139,15 @@ void Write(int sock,char *text, ...)
         chop(tb);
         if (fd_ref_table[sock])
         {
-               if (IOHookModule)
+               if (Config->GetIOHook(fd_ref_table[sock]->port))
                {
-                       IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+                       Config->GetIOHook(fd_ref_table[sock]->port)->OnRawSocketWrite(sock,tb,bytes);
                }
                else
                {
                        fd_ref_table[sock]->AddWriteBuf(tb);
                }
-               stats->statsSent += bytes;
+               ServerInstance->stats->statsSent += bytes;
         }
         else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
 }
@@ -175,15 +172,15 @@ void WriteServ(int sock, char* text, ...)
         chop(tb);
         if (fd_ref_table[sock])
         {
-               if (IOHookModule)
+               if (Config->GetIOHook(fd_ref_table[sock]->port))
                {
-                       IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+                       Config->GetIOHook(fd_ref_table[sock]->port)->OnRawSocketWrite(sock,tb,bytes);
                }
                else
                {
                        fd_ref_table[sock]->AddWriteBuf(tb);
                }
-                stats->statsSent += bytes;
+                ServerInstance->stats->statsSent += bytes;
         }
         else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
 }
@@ -208,15 +205,15 @@ void WriteFrom(int sock, userrec *user,char* text, ...)
         chop(tb);
         if (fd_ref_table[sock])
         {
-               if (IOHookModule)
+               if (Config->GetIOHook(fd_ref_table[sock]->port))
                {
-                       IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+                       Config->GetIOHook(fd_ref_table[sock]->port)->OnRawSocketWrite(sock,tb,bytes);
                }
                else
                {
                        fd_ref_table[sock]->AddWriteBuf(tb);
                }
-                stats->statsSent += bytes;
+                ServerInstance->stats->statsSent += bytes;
         }
         else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
 }
@@ -925,9 +922,9 @@ char* Passwd(userrec *user)
 {
         for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
         {
-                if ((i->type == CC_ALLOW) && match(user->host,i->host))
+                if ((i->type == CC_ALLOW) && match(user->host,i->host.c_str()))
                 {
-                        return i->pass;
+                        return (char*)i->pass.c_str();
                 }
         }
         return "";
@@ -937,7 +934,7 @@ bool IsDenied(userrec *user)
 {
         for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
         {
-                if ((i->type == CC_DENY) && match(user->host,i->host))
+                if ((i->type == CC_DENY) && match(user->host,i->host.c_str()))
                 {
                         return true;
                 }
@@ -1067,15 +1064,15 @@ void ShowMOTD(userrec *user)
         snprintf(mbuf,MAXBUF,":%s 376 %s :End of message of the day.\r\n", Config->ServerName, user->nick);
         WholeMOTD = WholeMOTD + mbuf;
         // only one write operation
-       if (IOHookModule)
+       if (Config->GetIOHook(user->port))
        {
-               IOHookModule->OnRawSocketWrite(user->fd,(char*)WholeMOTD.c_str(),WholeMOTD.length());
+               Config->GetIOHook(user->port)->OnRawSocketWrite(user->fd,(char*)WholeMOTD.c_str(),WholeMOTD.length());
        }
        else
        {
                user->AddWriteBuf(WholeMOTD);
        }
-        stats->statsSent += WholeMOTD.length();
+        ServerInstance->stats->statsSent += WholeMOTD.length();
 }
 
 void ShowRULES(userrec *user)
@@ -1105,79 +1102,6 @@ bool AllModulesReportReady(userrec* user)
         return true;
 }
 
-void createcommand(char* cmd, handlerfunc f, char flags, int minparams,char* source)
-{
-        command_t comm;
-        /* create the command and push it onto the table */
-        strlcpy(comm.command,cmd,MAXBUF);
-        strlcpy(comm.source,source,MAXBUF);
-        comm.handler_function = f;
-        comm.flags_needed = flags;
-        comm.min_params = minparams;
-        comm.use_count = 0;
-        comm.total_bytes = 0;
-        cmdlist.push_back(comm);
-        log(DEBUG,"Added command %s (%lu parameters)",cmd,(unsigned long)minparams);
-}
-
-
-void SetupCommandTable(void)
-{
-        createcommand("USER",handle_user,0,4,"<core>");
-        createcommand("NICK",handle_nick,0,1,"<core>");
-        createcommand("QUIT",handle_quit,0,0,"<core>");
-        createcommand("VERSION",handle_version,0,0,"<core>");
-        createcommand("PING",handle_ping,0,1,"<core>");
-        createcommand("PONG",handle_pong,0,1,"<core>");
-        createcommand("ADMIN",handle_admin,0,0,"<core>");
-        createcommand("PRIVMSG",handle_privmsg,0,2,"<core>");
-        createcommand("INFO",handle_info,0,0,"<core>");
-        createcommand("TIME",handle_time,0,0,"<core>");
-        createcommand("WHOIS",handle_whois,0,1,"<core>");
-        createcommand("WALLOPS",handle_wallops,'o',1,"<core>");
-        createcommand("NOTICE",handle_notice,0,2,"<core>");
-        createcommand("JOIN",handle_join,0,1,"<core>");
-        createcommand("NAMES",handle_names,0,0,"<core>");
-        createcommand("PART",handle_part,0,1,"<core>");
-        createcommand("KICK",handle_kick,0,2,"<core>");
-        createcommand("MODE",handle_mode,0,1,"<core>");
-        createcommand("TOPIC",handle_topic,0,1,"<core>");
-        createcommand("WHO",handle_who,0,1,"<core>");
-        createcommand("MOTD",handle_motd,0,0,"<core>");
-        createcommand("RULES",handle_rules,0,0,"<core>");
-        createcommand("OPER",handle_oper,0,2,"<core>");
-        createcommand("LIST",handle_list,0,0,"<core>");
-        createcommand("DIE",handle_die,'o',1,"<core>");
-        createcommand("RESTART",handle_restart,'o',1,"<core>");
-        createcommand("KILL",handle_kill,'o',2,"<core>");
-        createcommand("REHASH",handle_rehash,'o',0,"<core>");
-        createcommand("LUSERS",handle_lusers,0,0,"<core>");
-        createcommand("STATS",handle_stats,0,1,"<core>");
-        createcommand("USERHOST",handle_userhost,0,1,"<core>");
-        createcommand("AWAY",handle_away,0,0,"<core>");
-        createcommand("ISON",handle_ison,0,0,"<core>");
-        createcommand("SUMMON",handle_summon,0,0,"<core>");
-        createcommand("USERS",handle_users,0,0,"<core>");
-        createcommand("INVITE",handle_invite,0,0,"<core>");
-        createcommand("PASS",handle_pass,0,1,"<core>");
-        createcommand("TRACE",handle_trace,'o',0,"<core>");
-        createcommand("WHOWAS",handle_whowas,0,1,"<core>");
-        createcommand("CONNECT",handle_connect,'o',1,"<core>");
-        createcommand("SQUIT",handle_squit,'o',0,"<core>");
-        createcommand("MODULES",handle_modules,0,0,"<core>");
-        createcommand("LINKS",handle_links,0,0,"<core>");
-        createcommand("MAP",handle_map,0,0,"<core>");
-        createcommand("KLINE",handle_kline,'o',1,"<core>");
-        createcommand("GLINE",handle_gline,'o',1,"<core>");
-        createcommand("ZLINE",handle_zline,'o',1,"<core>");
-        createcommand("QLINE",handle_qline,'o',1,"<core>");
-        createcommand("ELINE",handle_eline,'o',1,"<core>");
-        createcommand("LOADMODULE",handle_loadmodule,'o',1,"<core>");
-        createcommand("UNLOADMODULE",handle_unloadmodule,'o',1,"<core>");
-        createcommand("SERVER",handle_server,0,0,"<core>");
-       createcommand("COMMANDS",handle_commands,0,0,"<core>");
-}
-
 bool DirValid(char* dirandfile)
 {
         char work[MAXBUF];