diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-10 18:04:19 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-10 18:04:19 +0000 |
commit | fd2eb26472bcc0b7b144f40523ff820cba82f574 (patch) | |
tree | 367926c5a429de9eca5db303c8d12d146fa8c6c8 /src | |
parent | afa1ec0e9586d93482b5dfdc2d77e93c9499ea10 (diff) |
Move IsNick, IsIdent into class InspIRCd, update modules that use it.
Change message.h to just a #warning saying its deprecated, and remove all use of it from the core :)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4847 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
41 files changed, 68 insertions, 143 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 20353ff1f..0a544b1d4 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -32,7 +32,6 @@ using namespace std; #include "dynamic.h" #include "commands.h" #include "wildcard.h" -#include "message.h" #include "mode.h" #include "xline.h" #include "inspstring.h" diff --git a/src/cmd_invite.cpp b/src/cmd_invite.cpp index 33cc6bb5e..9ca25aa08 100644 --- a/src/cmd_invite.cpp +++ b/src/cmd_invite.cpp @@ -20,7 +20,6 @@ #include "modules.h" #include "commands.h" #include "helperfuncs.h" -#include "message.h" #include "commands/cmd_invite.h" extern InspIRCd* ServerInstance; diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp index 9313899f7..681c495aa 100644 --- a/src/cmd_nick.cpp +++ b/src/cmd_nick.cpp @@ -102,7 +102,7 @@ void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user) return; } } - if ((isnick(parameters[0]) == 0) && (IS_LOCAL(user))) + if ((!ServerInstance->IsNick(parameters[0])) && (IS_LOCAL(user))) { user->WriteServ("432 %s %s :Erroneous Nickname",user->nick,parameters[0]); return; diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp index 156fc8f55..c32960719 100644 --- a/src/cmd_notice.cpp +++ b/src/cmd_notice.cpp @@ -22,7 +22,6 @@ #include "hash_map.h" #include "users.h" #include "modules.h" -#include "message.h" #include "wildcard.h" #include "commands.h" #include "helperfuncs.h" diff --git a/src/cmd_oper.cpp b/src/cmd_oper.cpp index 085b6983d..2b4e3e206 100644 --- a/src/cmd_oper.cpp +++ b/src/cmd_oper.cpp @@ -25,7 +25,6 @@ #include "modules.h" #include "dynamic.h" #include "wildcard.h" -#include "message.h" #include "commands.h" #include "mode.h" #include "xline.h" @@ -94,7 +93,7 @@ void cmd_oper::Handle (const char** parameters, int pcnt, userrec *user) ServerInstance->Config->ConfValue(ServerInstance->Config->config_data, "type","host", j, HostName, MAXBUF); if (*HostName) user->ChangeDisplayedHost(HostName); - if (!isnick(TypeName)) + if (!ServerInstance->IsNick(TypeName)) { user->WriteServ("491 %s :Invalid oper type (oper types must follow the same syntax as nicknames)",user->nick); ServerInstance->WriteOpers("*** CONFIGURATION ERROR! Oper type invalid for OperType '%s'",OperType); diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp index 9255b67e3..f77c47c98 100644 --- a/src/cmd_privmsg.cpp +++ b/src/cmd_privmsg.cpp @@ -20,7 +20,6 @@ #include "configreader.h" #include "users.h" #include "modules.h" -#include "message.h" #include "wildcard.h" #include "commands.h" #include "helperfuncs.h" diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp index 3673b8427..afc4e9d8c 100644 --- a/src/cmd_quit.cpp +++ b/src/cmd_quit.cpp @@ -25,7 +25,6 @@ #include "modules.h" #include "dynamic.h" #include "wildcard.h" -#include "message.h" #include "commands.h" #include "mode.h" #include "xline.h" diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp index 194b8b24c..98a46569f 100644 --- a/src/cmd_stats.cpp +++ b/src/cmd_stats.cpp @@ -31,7 +31,6 @@ #include "modules.h" #include "dynamic.h" #include "wildcard.h" -#include "message.h" #include "commands.h" #include "mode.h" #include "xline.h" @@ -214,7 +213,7 @@ void DoStats(char statschar, userrec* user, string_list &results) for (std::vector<userrec*>::iterator n = ServerInstance->local_users.begin(); n != ServerInstance->local_users.end(); n++) { userrec* i = *n; - if (isnick(i->nick)) + if (ServerInstance->IsNick(i->nick)) { results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->dhost+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(TIME - i->age)); } @@ -228,7 +227,7 @@ void DoStats(char statschar, userrec* user, string_list &results) for (std::vector<userrec*>::iterator n = ServerInstance->local_users.begin(); n != ServerInstance->local_users.end(); n++) { userrec* i = *n; - if (isnick(i->nick)) + if (ServerInstance->IsNick(i->nick)) { results.push_back(sn+" 211 "+user->nick+" "+i->nick+"["+i->ident+"@"+i->GetIPString()+"] "+ConvToStr(i->sendq.length())+" "+ConvToStr(i->cmds_out)+" "+ConvToStr(i->bytes_out)+" "+ConvToStr(i->cmds_in)+" "+ConvToStr(i->bytes_in)+" "+ConvToStr(TIME - i->age)); } diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp index 57b4e0433..adb460c80 100644 --- a/src/cmd_topic.cpp +++ b/src/cmd_topic.cpp @@ -18,7 +18,6 @@ #include "configreader.h" #include "users.h" #include "modules.h" -#include "message.h" #include "commands.h" #include "commands/cmd_topic.h" #include "helperfuncs.h" diff --git a/src/cmd_trace.cpp b/src/cmd_trace.cpp index 26a94f7a0..48f00c62d 100644 --- a/src/cmd_trace.cpp +++ b/src/cmd_trace.cpp @@ -28,7 +28,7 @@ void cmd_trace::Handle (const char** parameters, int pcnt, userrec *user) { if (i->second) { - if (isnick(i->second->nick)) + if (ServerInstance->IsNick(i->second->nick)) { if (*i->second->oper) { diff --git a/src/cmd_user.cpp b/src/cmd_user.cpp index cd7f26d09..72eb3afcf 100644 --- a/src/cmd_user.cpp +++ b/src/cmd_user.cpp @@ -17,12 +17,12 @@ #include "inspircd_config.h" #include "configreader.h" #include "users.h" -#include "message.h" #include "commands.h" #include "helperfuncs.h" #include "commands/cmd_user.h" extern InspIRCd* ServerInstance; + extern int MODCOUNT; extern ModuleList modules; extern FactoryList factory; @@ -31,7 +31,7 @@ void cmd_user::Handle (const char** parameters, int pcnt, userrec *user) { if (user->registered < REG_NICKUSER) { - if (!isident(parameters[0])) { + if (!ServerInstance->IsIdent(parameters[0])) { // This kinda Sucks, According to the RFC thou, its either this, // or "You have already registered" :p -- Craig user->WriteServ("461 %s USER :Not enough parameters",user->nick); diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp index cc29801cc..7601a1069 100644 --- a/src/cmd_who.cpp +++ b/src/cmd_who.cpp @@ -16,7 +16,6 @@ #include "configreader.h" #include "users.h" -#include "message.h" #include "modules.h" #include "commands.h" #include "helperfuncs.h" diff --git a/src/cmd_whois.cpp b/src/cmd_whois.cpp index 09e8eea65..bbd3f28e4 100644 --- a/src/cmd_whois.cpp +++ b/src/cmd_whois.cpp @@ -15,7 +15,6 @@ */ #include "inspircd.h" -#include "message.h" #include "configreader.h" #include "users.h" #include "modules.h" diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 4a375f365..3e6a9ed20 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -32,7 +32,6 @@ #include "modules.h" #include "dynamic.h" #include "wildcard.h" -#include "message.h" #include "mode.h" #include "commands.h" #include "xline.h" diff --git a/src/commands.cpp b/src/commands.cpp index 8a7e38204..edaa8045d 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -39,7 +39,6 @@ #include "modules.h" #include "dynamic.h" #include "wildcard.h" -#include "message.h" #include "commands.h" #include "mode.h" #include "xline.h" diff --git a/src/configreader.cpp b/src/configreader.cpp index 184387890..726192cc6 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -20,7 +20,6 @@ #include <sstream> #include <iostream> #include <fstream> -#include "message.h" #include "inspircd.h" #include "inspstring.h" #include "helperfuncs.h" diff --git a/src/cull_list.cpp b/src/cull_list.cpp index 2fb31014b..18c86f631 100644 --- a/src/cull_list.cpp +++ b/src/cull_list.cpp @@ -29,7 +29,6 @@ using namespace std; #include "modules.h" #include "dynamic.h" #include "wildcard.h" -#include "message.h" #include "commands.h" #include "xline.h" #include "inspstring.h" diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 8bfba1ca5..a1b1b8bc2 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -34,7 +34,6 @@ #include "modules.h" #include "dynamic.h" #include "wildcard.h" -#include "message.h" #include "mode.h" #include "xline.h" #include "commands.h" diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 96518fe56..14f88e0a3 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -1,13 +1,13 @@ /* --------------------------------------------------------------------- * - * +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ + * +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ * - * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. - * E-mail: - * <brain@chatspike.net> - * <Craig@chatspike.net> + * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. + * E-mail: + * <brain@chatspike.net> + * <Craig@chatspike.net> * * Written by Craig Edwards, Craig McLure, and others. * This program is free but copyrighted software; you can redistribute @@ -51,7 +51,6 @@ #include "modules.h" #include "dynamic.h" #include "wildcard.h" -#include "message.h" #include "mode.h" #include "commands.h" #include "xline.h" @@ -889,6 +888,51 @@ void InspIRCd::DoOneIteration(bool process_module_sockets) } } +bool InspIRCd::IsIdent(const char* n) +{ + if (!n || !*n) + return false; + + for (char* i = (char*)n; *i; i++) + { + if ((*i >= 'A') && (*i <= '}')) + { + continue; + } + if (((*i >= '0') && (*i <= '9')) || (*i == '-') || (*i == '.')) + { + continue; + } + return false; + } + return true; +} + + +bool InspIRCd::IsNick(const char* n) +{ + if (!n || !*n) + return false; + + int p = 0; + for (char* i = (char*)n; *i; i++, p++) + { + /* "A"-"}" can occur anywhere in a nickname */ + if ((*i >= 'A') && (*i <= '}')) + { + continue; + } + /* "0"-"9", "-" can occur anywhere BUT the first char of a nickname */ + if ((((*i >= '0') && (*i <= '9')) || (*i == '-')) && (i > n)) + { + continue; + } + /* invalid character! abort */ + return false; + } + return (p < NICKMAX - 1); +} + int InspIRCd::Run() { this->Res = new DNS(this); diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 187a5265d..184eec0f3 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -25,7 +25,6 @@ #include "inspstring.h" #include "helperfuncs.h" #include "socketengine.h" -#include "message.h" #include "inspircd.h" using irc::sockets::BindSocket; diff --git a/src/message.cpp b/src/message.cpp index 7a1811a63..09385df22 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -13,87 +13,3 @@ * * --------------------------------------------------- */ - -using namespace std; - -#include "inspircd_config.h" -#include "inspircd.h" -#include "configreader.h" -#include <unistd.h> -#include <fcntl.h> -#include <sys/errno.h> -#include <sys/utsname.h> -#include <time.h> -#include <string> -#include <ext/hash_map> -#include <map> -#include <sstream> -#include <vector> -#include <deque> -#include "users.h" -#include "ctables.h" -#include "globals.h" -#include "modules.h" -#include "dynamic.h" -#include "wildcard.h" -#include "commands.h" -#include "message.h" -#include "inspstring.h" -#include "dns.h" -#include "helperfuncs.h" - -extern int MODCOUNT; -extern std::vector<Module*> modules; -extern std::vector<ircd_module*> factory; -extern time_t TIME; -extern InspIRCd* ServerInstance; - -/* verify that a user's ident and nickname is valid */ - -int isident(const char* n) -{ - if (!n || !*n) - { - return 0; - } - for (char* i = (char*)n; *i; i++) - { - if ((*i >= 'A') && (*i <= '}')) - { - continue; - } - if (((*i >= '0') && (*i <= '9')) || (*i == '-') || (*i == '.')) - { - continue; - } - return 0; - } - return 1; -} - - -int isnick(const char* n) -{ - if (!n || !*n) - { - return 0; - } - int p = 0; - for (char* i = (char*)n; *i; i++, p++) - { - /* "A"-"}" can occur anywhere in a nickname */ - if ((*i >= 'A') && (*i <= '}')) - { - continue; - } - /* "0"-"9", "-" can occur anywhere BUT the first char of a nickname */ - if ((((*i >= '0') && (*i <= '9')) || (*i == '-')) && (i > n)) - { - continue; - } - /* invalid character! abort */ - return 0; - } - return (p < NICKMAX - 1); -} - diff --git a/src/mode.cpp b/src/mode.cpp index d34770ab4..915dcd809 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -24,7 +24,6 @@ using namespace std; #include "connection.h" #include "users.h" #include "modules.h" -#include "message.h" #include "inspstring.h" #include "helperfuncs.h" #include "commands.h" diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp index d03213f2e..8c1c2cd63 100644 --- a/src/modes/cmode_b.cpp +++ b/src/modes/cmode_b.cpp @@ -8,7 +8,6 @@ #include "channels.h" #include "users.h" #include "helperfuncs.h" -#include "message.h" #include "modules.h" #include "inspstring.h" #include "hashcomp.h" diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp index 3e5d5a372..0fd4bfa07 100644 --- a/src/modes/cmode_h.cpp +++ b/src/modes/cmode_h.cpp @@ -8,7 +8,6 @@ #include "channels.h" #include "users.h" #include "helperfuncs.h" -#include "message.h" #include "commands.h" #include "modules.h" #include "inspstring.h" diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp index 4e60a1abd..75e088635 100644 --- a/src/modes/cmode_o.cpp +++ b/src/modes/cmode_o.cpp @@ -8,7 +8,6 @@ #include "channels.h" #include "users.h" #include "helperfuncs.h" -#include "message.h" #include "commands.h" #include "modules.h" #include "inspstring.h" diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp index b71775885..7888666ca 100644 --- a/src/modes/cmode_v.cpp +++ b/src/modes/cmode_v.cpp @@ -8,7 +8,6 @@ #include "channels.h" #include "users.h" #include "helperfuncs.h" -#include "message.h" #include "commands.h" #include "modules.h" #include "inspstring.h" diff --git a/src/modules.cpp b/src/modules.cpp index 78beb5715..918e2b6f6 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -31,7 +31,6 @@ #include "modules.h" #include "dynamic.h" #include "wildcard.h" -#include "message.h" #include "mode.h" #include "xline.h" #include "commands.h" @@ -400,11 +399,6 @@ void Server::DumpText(userrec* User, const std::string &LinePrefix, stringstream User->WriteServ(CompleteLine); } -bool Server::IsNick(const std::string &nick) -{ - return (isnick(nick.c_str()) != 0); -} - userrec* Server::FindDescriptor(int socket) { return (socket < 65536 ? ServerInstance->fd_ref_table[socket] : NULL); diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 8da57d9f2..180a989c9 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -19,7 +19,6 @@ using namespace std; #include "users.h" #include "channels.h" #include "modules.h" -#include "message.h" #include "commands.h" #include "inspircd.h" #include "helperfuncs.h" diff --git a/src/modules/m_chgident.cpp b/src/modules/m_chgident.cpp index 391f4b20b..7efe2e755 100644 --- a/src/modules/m_chgident.cpp +++ b/src/modules/m_chgident.cpp @@ -1,7 +1,6 @@ #include <string> #include "users.h" #include "modules.h" -#include "message.h" #include "helperfuncs.h" #include "inspircd.h" @@ -26,7 +25,7 @@ class cmd_chgident : public command_t if(dest) { - if(!isident(parameters[1])) + if(!ServerInstance->IsIdent(parameters[1])) { user->WriteServ("NOTICE %s :*** Invalid characters in ident", user->nick); return; diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 3d924bb0f..32e87272a 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -87,9 +87,12 @@ class RFC1413 : public InspSocket { if (u && (fd_ref_table[ufd] == u)) { - strlcpy(u->ident,section,IDENTMAX); - log(DEBUG,"IDENT SET: "+std::string(u->ident)); - u->WriteServ("NOTICE "+std::string(u->nick)+" :*** Found your ident: "+std::string(u->ident)); + if (ServerInstance->IsIdent(section)) + { + strlcpy(u->ident,section,IDENTMAX); + log(DEBUG,"IDENT SET: "+std::string(u->ident)); + u->WriteServ("NOTICE "+std::string(u->nick)+" :*** Found your ident: "+std::string(u->ident)); + } } } return false; diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp index 58a4c2686..f6f88993a 100644 --- a/src/modules/m_nicklock.cpp +++ b/src/modules/m_nicklock.cpp @@ -53,7 +53,7 @@ class cmd_nicklock : public command_t user->WriteServ("946 %s %s :This user's nickname is already locked.",user->nick,source->nick); return; } - if (Srv->IsNick(std::string(parameters[1]))) + if (ServerInstance->IsNick(parameters[1])) { // give them a lock flag ServerInstance->WriteOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+parameters[0]+" to "+parameters[1]); diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp index 091d59d1a..2ffb851b9 100644 --- a/src/modules/m_safelist.cpp +++ b/src/modules/m_safelist.cpp @@ -20,7 +20,6 @@ using namespace std; #include "channels.h" #include "modules.h" #include "helperfuncs.h" -#include "message.h" #include <vector> #include "configreader.h" #include "inspircd.h" diff --git a/src/modules/m_sanick.cpp b/src/modules/m_sanick.cpp index a323844d5..42d54731c 100644 --- a/src/modules/m_sanick.cpp +++ b/src/modules/m_sanick.cpp @@ -47,7 +47,7 @@ class cmd_sanick : public command_t user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick); return; } - if (Srv->IsNick(std::string(parameters[1]))) + if (ServerInstance->IsNick(parameters[1])) { // FIX by brain: Cant use source->nick here because if it traverses a server link then // source->nick becomes invalid as the object data moves in memory. diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index 00e860467..fcb2a4e94 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -20,7 +20,6 @@ using namespace std; #include "channels.h" #include "modules.h" #include "helperfuncs.h" -#include "message.h" #include <vector> #include "inspircd.h" diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index e4fbd4b33..cd13e5bfd 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -36,7 +36,6 @@ using namespace std; #include "inspircd.h" #include "inspstring.h" #include "hashcomp.h" -#include "message.h" #include "xline.h" #include "typedefs.h" #include "cull_list.h" diff --git a/src/modules/m_spy.cpp b/src/modules/m_spy.cpp index 939af8662..4ded5374f 100644 --- a/src/modules/m_spy.cpp +++ b/src/modules/m_spy.cpp @@ -38,7 +38,6 @@ using namespace std; #include "inspircd.h" #include "inspstring.h" #include "hashcomp.h" -#include "message.h" #include "xline.h" #include "typedefs.h" #include "cull_list.h" diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp index 06f5b1924..5159f218f 100644 --- a/src/modules/m_uninvite.cpp +++ b/src/modules/m_uninvite.cpp @@ -23,7 +23,6 @@ using namespace std; #include "channels.h" #include "modules.h" #include "helperfuncs.h" -#include "message.h" #include "configreader.h" #include "inspircd.h" diff --git a/src/socket.cpp b/src/socket.cpp index 0f84912de..e0d02a48a 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -22,7 +22,6 @@ #include "helperfuncs.h" #include "socketengine.h" #include "wildcard.h" -#include "message.h" extern InspIRCd* ServerInstance; extern time_t TIME; diff --git a/src/userprocess.cpp b/src/userprocess.cpp index 51235b882..d2549b7c2 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -38,7 +38,6 @@ using namespace std; #include "modules.h" #include "dynamic.h" #include "wildcard.h" -#include "message.h" #include "mode.h" #include "commands.h" #include "xline.h" diff --git a/src/users.cpp b/src/users.cpp index ad358211d..8273acc88 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -27,7 +27,6 @@ #include "typedefs.h" #include "socketengine.h" #include "hashcomp.h" -#include "message.h" #include "wildcard.h" #include "xline.h" #include "cull_list.h" diff --git a/src/xline.cpp b/src/xline.cpp index 551e98458..c32b7bd39 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -29,7 +29,6 @@ using namespace std; #include "modules.h" #include "dynamic.h" #include "wildcard.h" -#include "message.h" #include "commands.h" #include "xline.h" #include "inspstring.h" |