summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd_admin.cpp73
-rw-r--r--src/cmd_away.cpp79
-rw-r--r--src/cmd_commands.cpp74
-rw-r--r--src/cmd_connect.cpp69
-rw-r--r--src/cmd_die.cpp80
-rw-r--r--src/cmd_eline.cpp97
-rw-r--r--src/cmd_gline.cpp97
-rw-r--r--src/cmd_info.cpp106
-rw-r--r--src/cmd_invite.cpp133
-rw-r--r--src/cmd_ison.cpp82
-rw-r--r--src/cmd_join.cpp78
-rw-r--r--src/cmd_kick.cpp102
-rw-r--r--src/cmd_kill.cpp120
-rw-r--r--src/cmd_kline.cpp97
-rw-r--r--src/cmd_links.cpp71
-rw-r--r--src/cmd_list.cpp80
-rw-r--r--src/cmd_loadmodule.cpp78
-rw-r--r--src/cmd_lusers.cpp76
-rw-r--r--src/cmd_map.cpp73
-rw-r--r--src/cmd_modules.cpp96
-rw-r--r--src/cmd_motd.cpp70
-rw-r--r--src/cmd_names.cpp94
-rw-r--r--src/cmd_nick.cpp183
-rw-r--r--src/cmd_notice.cpp155
-rw-r--r--src/cmd_oper.cpp140
-rw-r--r--src/cmd_part.cpp81
-rw-r--r--src/cmd_pass.cpp80
-rw-r--r--src/cmd_ping.cpp70
-rw-r--r--src/cmd_pong.cpp71
-rw-r--r--src/cmd_privmsg.cpp160
-rw-r--r--src/cmd_qline.cpp97
-rw-r--r--src/cmd_quit.cpp141
-rw-r--r--src/cmd_rehash.cpp81
-rw-r--r--src/cmd_restart.cpp105
-rw-r--r--src/cmd_rules.cpp70
-rw-r--r--src/cmd_server.cpp71
-rw-r--r--src/cmd_squit.cpp69
-rw-r--r--src/cmd_stats.cpp267
-rw-r--r--src/cmd_summon.cpp70
-rw-r--r--src/cmd_time.cpp76
-rw-r--r--src/cmd_topic.cpp148
-rw-r--r--src/cmd_trace.cpp90
-rw-r--r--src/cmd_unloadmodule.cpp78
-rw-r--r--src/cmd_user.cpp99
-rw-r--r--src/cmd_userhost.cpp90
-rw-r--r--src/cmd_users.cpp70
-rw-r--r--src/cmd_version.cpp70
-rw-r--r--src/cmd_wallops.cpp71
-rw-r--r--src/cmd_who.cpp191
-rw-r--r--src/cmd_whois.cpp82
-rw-r--r--src/cmd_whowas.cpp91
-rw-r--r--src/cmd_zline.cpp102
-rw-r--r--src/command_parse.cpp205
-rw-r--r--src/commands.cpp1711
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/mode.cpp2
-rw-r--r--src/modules.cpp4
-rw-r--r--src/modules/m_chghost.cpp49
-rw-r--r--src/modules/m_globops.cpp30
-rw-r--r--src/modules/m_helpop.cpp105
-rw-r--r--src/modules/m_knock.cpp63
-rw-r--r--src/modules/m_nicklock.cpp92
-rw-r--r--src/modules/m_opermd5.cpp23
-rw-r--r--src/modules/m_opermotd.cpp22
-rw-r--r--src/modules/m_park.cpp235
-rw-r--r--src/modules/m_randquote.cpp58
-rw-r--r--src/users.cpp3
67 files changed, 5596 insertions, 2102 deletions
diff --git a/src/cmd_admin.cpp b/src/cmd_admin.cpp
new file mode 100644
index 000000000..09a0b88fd
--- /dev/null
+++ b/src/cmd_admin.cpp
@@ -0,0 +1,73 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_admin.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_admin::Handle (char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"256 %s :Administrative info for %s",user->nick,Config->ServerName);
+ WriteServ(user->fd,"257 %s :Name - %s",user->nick,Config->AdminName);
+ WriteServ(user->fd,"258 %s :Nickname - %s",user->nick,Config->AdminNick);
+ WriteServ(user->fd,"258 %s :E-Mail - %s",user->nick,Config->AdminEmail);
+}
+
+
diff --git a/src/cmd_away.cpp b/src/cmd_away.cpp
new file mode 100644
index 000000000..38a9eb77e
--- /dev/null
+++ b/src/cmd_away.cpp
@@ -0,0 +1,79 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_away.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_away::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (pcnt)
+ {
+ strlcpy(user->awaymsg,parameters[0],MAXAWAY);
+ WriteServ(user->fd,"306 %s :You have been marked as being away",user->nick);
+ }
+ else
+ {
+ strlcpy(user->awaymsg,"",MAXAWAY);
+ WriteServ(user->fd,"305 %s :You are no longer marked as being away",user->nick);
+ }
+}
+
+
diff --git a/src/cmd_commands.cpp b/src/cmd_commands.cpp
new file mode 100644
index 000000000..8d4f74122
--- /dev/null
+++ b/src/cmd_commands.cpp
@@ -0,0 +1,74 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_commands.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_commands::Handle (char **parameters, int pcnt, userrec *user)
+{
+ for (unsigned int i = 0; i < ServerInstance->Parser->cmdlist.size(); i++)
+ {
+ WriteServ(user->fd,"902 %s :%s %s %d",user->nick,ServerInstance->Parser->cmdlist[i]->command.c_str(),ServerInstance->Parser->cmdlist[i]->source.c_str(),ServerInstance->Parser->cmdlist[i]->min_params);
+}
+ WriteServ(user->fd,"903 %s :End of COMMANDS list",user->nick);
+}
+
+
diff --git a/src/cmd_connect.cpp b/src/cmd_connect.cpp
new file mode 100644
index 000000000..19a07703f
--- /dev/null
+++ b/src/cmd_connect.cpp
@@ -0,0 +1,69 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_connect.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_connect::Handle (char **parameters, int pcnt, userrec *user)
+{
+}
+
+
diff --git a/src/cmd_die.cpp b/src/cmd_die.cpp
new file mode 100644
index 000000000..e1a6a70a4
--- /dev/null
+++ b/src/cmd_die.cpp
@@ -0,0 +1,80 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_die.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_die::Handle (char **parameters, int pcnt, userrec *user)
+{
+ log(DEBUG,"die: %s",user->nick);
+ if (!strcmp(parameters[0],Config->diepass))
+ {
+ WriteOpers("*** DIE command from %s!%s@%s, terminating...",user->nick,user->ident,user->host);
+ sleep(Config->DieDelay);
+ Exit(ERROR);
+ }
+ else
+ {
+ WriteOpers("*** Failed DIE Command from %s!%s@%s.",user->nick,user->ident,user->host);
+ }
+}
+
+
diff --git a/src/cmd_eline.cpp b/src/cmd_eline.cpp
new file mode 100644
index 000000000..eafa83913
--- /dev/null
+++ b/src/cmd_eline.cpp
@@ -0,0 +1,97 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_eline.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_eline::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (pcnt >= 3)
+ {
+ if (host_matches_everyone(parameters[0],user))
+ return;
+ add_eline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
+ FOREACH_MOD OnAddELine(duration(parameters[1]), user, parameters[2], parameters[0]);
+ if (!duration(parameters[1]))
+ {
+ WriteOpers("*** %s added permenant E-line for %s.",user->nick,parameters[0]);
+ }
+ else
+ {
+ WriteOpers("*** %s added timed E-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+ }
+ }
+ else
+ {
+ if (del_eline(parameters[0]))
+ {
+ FOREACH_MOD OnDelELine(user, parameters[0]);
+ WriteOpers("*** %s Removed E-line on %s.",user->nick,parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"NOTICE %s :*** E-Line %s not found in list, try /stats e.",user->nick,parameters[0]);
+ }
+ }
+ // no need to apply the lines for an eline
+}
+
+
diff --git a/src/cmd_gline.cpp b/src/cmd_gline.cpp
new file mode 100644
index 000000000..7304e6fc2
--- /dev/null
+++ b/src/cmd_gline.cpp
@@ -0,0 +1,97 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_gline.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_gline::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (pcnt >= 3)
+ {
+ if (host_matches_everyone(parameters[0],user))
+ return;
+ add_gline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
+ FOREACH_MOD OnAddGLine(duration(parameters[1]), user, parameters[2], parameters[0]);
+ if (!duration(parameters[1]))
+ {
+ WriteOpers("*** %s added permenant G-line for %s.",user->nick,parameters[0]);
+ }
+ else
+ {
+ WriteOpers("*** %s added timed G-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+ }
+ apply_lines(APPLY_GLINES);
+ }
+ else
+ {
+ if (del_gline(parameters[0]))
+ {
+ FOREACH_MOD OnDelGLine(user, parameters[0]);
+ WriteOpers("*** %s Removed G-line on %s.",user->nick,parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"NOTICE %s :*** G-Line %s not found in list, try /stats g.",user->nick,parameters[0]);
+ }
+ }
+}
+
+
diff --git a/src/cmd_info.cpp b/src/cmd_info.cpp
new file mode 100644
index 000000000..3cda8c770
--- /dev/null
+++ b/src/cmd_info.cpp
@@ -0,0 +1,106 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_info.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_info::Handle (char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"371 %s :. o O (The Inspire Internet Relay Chat Server) O o .",user->nick);
+ WriteServ(user->fd,"371 %s : ",user->nick);
+ WriteServ(user->fd,"371 %s :Core developers: Craig Edwards (Brain)",user->nick);
+ WriteServ(user->fd,"371 %s : Craig McLure",user->nick);
+ WriteServ(user->fd,"371 %s : ",user->nick);
+ WriteServ(user->fd,"371 %s :Contributors: typobox43",user->nick);
+ WriteServ(user->fd,"371 %s : w00t",user->nick);
+ WriteServ(user->fd,"371 %s : Om",user->nick);
+ WriteServ(user->fd,"371 %s : Jazza",user->nick);
+ WriteServ(user->fd,"371 %s : ",user->nick);
+ WriteServ(user->fd,"371 %s :Testers: CC",user->nick);
+ WriteServ(user->fd,"371 %s : Om",user->nick);
+ WriteServ(user->fd,"371 %s : Piggles",user->nick);
+ WriteServ(user->fd,"371 %s : Foamy",user->nick);
+ WriteServ(user->fd,"371 %s : Hart",user->nick);
+ WriteServ(user->fd,"371 %s : RageD",user->nick);
+ WriteServ(user->fd,"371 %s : [ed]",user->nick);
+ WriteServ(user->fd,"371 %s : Azhrarn",user->nick);
+ WriteServ(user->fd,"371 %s : nenolod",user->nick);
+ WriteServ(user->fd,"371 %s : luigiman",user->nick);
+ WriteServ(user->fd,"371 %s : Chu",user->nick);
+ WriteServ(user->fd,"371 %s : aquanight",user->nick);
+ WriteServ(user->fd,"371 %s : xptek",user->nick);
+ WriteServ(user->fd,"371 %s : Grantlinks",user->nick);
+ WriteServ(user->fd,"371 %s : Rob",user->nick);
+ WriteServ(user->fd,"371 %s : angelic",user->nick);
+ WriteServ(user->fd,"371 %s : Jason",user->nick);
+ WriteServ(user->fd,"371 %s : ThaPrince",user->nick);
+ WriteServ(user->fd,"371 %s : ",user->nick);
+ WriteServ(user->fd,"371 %s :Thanks to irc-junkie and searchirc",user->nick);
+ WriteServ(user->fd,"371 %s :for the nice comments and the help",user->nick);
+ WriteServ(user->fd,"371 %s :you gave us in attracting users to",user->nick);
+ WriteServ(user->fd,"371 %s :this software.",user->nick);
+ WriteServ(user->fd,"371 %s : ",user->nick);
+ WriteServ(user->fd,"371 %s :Best experienced with: An IRC client.",user->nick);
+ FOREACH_MOD OnInfo(user);
+ WriteServ(user->fd,"374 %s :End of /INFO list",user->nick);
+}
+
+
diff --git a/src/cmd_invite.cpp b/src/cmd_invite.cpp
new file mode 100644
index 000000000..0c1b01eba
--- /dev/null
+++ b/src/cmd_invite.cpp
@@ -0,0 +1,133 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_invite.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_invite::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (pcnt == 2)
+ {
+ userrec* u = Find(parameters[0]);
+ chanrec* c = FindChan(parameters[1]);
+
+ if ((!c) || (!u))
+ {
+ if (!c)
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[1]);
+ }
+ else
+ {
+ if (c->binarymodes & CM_INVITEONLY)
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
+ }
+
+ return;
+ }
+
+ if (c->binarymodes & CM_INVITEONLY)
+ {
+ if (cstatus(user,c) < STATUS_HOP)
+ {
+ WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
+ return;
+ }
+ }
+ if (has_channel(u,c))
+ {
+ WriteServ(user->fd,"443 %s %s %s :Is already on channel %s",user->nick,u->nick,c->name,c->name);
+ return;
+ }
+ if (!has_channel(user,c))
+ {
+ WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, c->name);
+ return;
+ }
+
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(OnUserPreInvite(user,u,c));
+ if (MOD_RESULT == 1) {
+ return;
+ }
+
+ irc::string xname(c->name);
+ u->InviteTo(xname);
+ WriteFrom(u->fd,user,"INVITE %s :%s",u->nick,c->name);
+ WriteServ(user->fd,"341 %s %s %s",user->nick,u->nick,c->name);
+ FOREACH_MOD OnUserInvite(user,u,c);
+ }
+ else
+ {
+ // pinched from ircu - invite with not enough parameters shows channels
+ // youve been invited to but haven't joined yet.
+ InvitedList* il = user->GetInviteList();
+ for (InvitedList::iterator i = il->begin(); i != il->end(); i++)
+ {
+ WriteServ(user->fd,"346 %s :%s",user->nick,i->channel.c_str());
+ }
+ WriteServ(user->fd,"347 %s :End of INVITE list",user->nick);
+ }
+}
+
+
diff --git a/src/cmd_ison.cpp b/src/cmd_ison.cpp
new file mode 100644
index 000000000..a0999ec58
--- /dev/null
+++ b/src/cmd_ison.cpp
@@ -0,0 +1,82 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_ison.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_ison::Handle (char **parameters, int pcnt, userrec *user)
+{
+ char Return[MAXBUF];
+ snprintf(Return,MAXBUF,"303 %s :",user->nick);
+ for (int i = 0; i < pcnt; i++)
+ {
+ userrec *u = Find(parameters[i]);
+ if (u)
+ {
+ strlcat(Return,u->nick,MAXBUF);
+ strlcat(Return," ",MAXBUF);
+ }
+ }
+ WriteServ(user->fd,Return);
+}
+
+
+
diff --git a/src/cmd_join.cpp b/src/cmd_join.cpp
new file mode 100644
index 000000000..5e4f886a7
--- /dev/null
+++ b/src/cmd_join.cpp
@@ -0,0 +1,78 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_join.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_join::Handle (char **parameters, int pcnt, userrec *user)
+{
+ chanrec* Ptr;
+
+ /*if (ServerInstance->Parser->LoopCall(handle_join,parameters,pcnt,user,0,0,1))
+ return;*/
+ if (parameters[0][0] == '#')
+ {
+ Ptr = add_channel(user,parameters[0],parameters[1],false);
+ }
+}
+
+
+
diff --git a/src/cmd_kick.cpp b/src/cmd_kick.cpp
new file mode 100644
index 000000000..b3c55b180
--- /dev/null
+++ b/src/cmd_kick.cpp
@@ -0,0 +1,102 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_kick.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_kick::Handle (char **parameters, int pcnt, userrec *user)
+{
+ chanrec* Ptr = FindChan(parameters[0]);
+ userrec* u = Find(parameters[1]);
+
+ if ((!u) || (!Ptr))
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ return;
+ }
+
+ if ((!has_channel(user,Ptr)) && (!is_uline(user->server)))
+ {
+ WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, parameters[0]);
+ return;
+ }
+
+ char reason[MAXBUF];
+
+ if (pcnt > 2)
+ {
+ strlcpy(reason,parameters[2],MAXBUF);
+ if (strlen(reason)>MAXKICK)
+ {
+ reason[MAXKICK-1] = '\0';
+ }
+
+ kick_channel(user,u,Ptr,reason);
+ }
+ else
+ {
+ strlcpy(reason,user->nick,MAXBUF);
+ kick_channel(user,u,Ptr,reason);
+ }
+
+}
+
+
diff --git a/src/cmd_kill.cpp b/src/cmd_kill.cpp
new file mode 100644
index 000000000..c1b282bfa
--- /dev/null
+++ b/src/cmd_kill.cpp
@@ -0,0 +1,120 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_kill.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_kill::Handle (char **parameters, int pcnt, userrec *user)
+{
+ userrec *u = Find(parameters[0]);
+ char killreason[MAXBUF];
+
+ log(DEBUG,"kill: %s %s",parameters[0],parameters[1]);
+ if (u)
+ {
+ log(DEBUG,"into kill mechanism");
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(OnKill(user,u,parameters[1]));
+ if (MOD_RESULT) {
+ log(DEBUG,"A module prevented the kill with result %d",MOD_RESULT);
+ return;
+ }
+
+ if (u->fd < 0)
+ {
+ // remote kill
+ WriteOpers("*** Remote kill by %s: %s!%s@%s (%s)",user->nick,u->nick,u->ident,u->host,parameters[1]);
+ snprintf(killreason,MAXBUF,"[%s] Killed (%s (%s))",Config->ServerName,user->nick,parameters[1]);
+ WriteCommonExcept(u,"QUIT :%s",killreason);
+
+ FOREACH_MOD OnRemoteKill(user,u,killreason);
+
+ user_hash::iterator iter = clientlist.find(u->nick);
+ if (iter != clientlist.end())
+ {
+ log(DEBUG,"deleting user hash value %d",iter->second);
+ clientlist.erase(iter);
+ }
+ if (u->registered == 7)
+ {
+ purge_empty_chans(u);
+ }
+ if (u->fd > -1)
+ fd_ref_table[u->fd] = NULL;
+ delete u;
+ }
+ else
+ {
+ // local kill
+ log(DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, Config->ServerName,user->dhost,user->nick,parameters[1]);
+ WriteTo(user, u, "KILL %s :%s!%s!%s (%s)", u->nick, Config->ServerName,user->dhost,user->nick,parameters[1]);
+ WriteOpers("*** Local Kill by %s: %s!%s@%s (%s)",user->nick,u->nick,u->ident,u->host,parameters[1]);
+ snprintf(killreason,MAXBUF,"Killed (%s (%s))",user->nick,parameters[1]);
+ kill_link(u,killreason);
+ }
+ }
+ else
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
+}
+
+
diff --git a/src/cmd_kline.cpp b/src/cmd_kline.cpp
new file mode 100644
index 000000000..a14c2bf99
--- /dev/null
+++ b/src/cmd_kline.cpp
@@ -0,0 +1,97 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_kline.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_kline::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (pcnt >= 3)
+ {
+ if (host_matches_everyone(parameters[0],user))
+ return;
+ add_kline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
+ FOREACH_MOD OnAddKLine(duration(parameters[1]), user, parameters[2], parameters[0]);
+ if (!duration(parameters[1]))
+ {
+ WriteOpers("*** %s added permenant K-line for %s.",user->nick,parameters[0]);
+ }
+ else
+ {
+ WriteOpers("*** %s added timed K-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+ }
+ apply_lines(APPLY_KLINES);
+ }
+ else
+ {
+ if (del_kline(parameters[0]))
+ {
+ FOREACH_MOD OnDelKLine(user, parameters[0]);
+ WriteOpers("*** %s Removed K-line on %s.",user->nick,parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"NOTICE %s :*** K-Line %s not found in list, try /stats k.",user->nick,parameters[0]);
+ }
+ }
+}
+
+
diff --git a/src/cmd_links.cpp b/src/cmd_links.cpp
new file mode 100644
index 000000000..e2ed864d6
--- /dev/null
+++ b/src/cmd_links.cpp
@@ -0,0 +1,71 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_links.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_links::Handle (char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"364 %s %s %s :0 %s",user->nick,Config->ServerName,Config->ServerName,Config->ServerDesc);
+ WriteServ(user->fd,"365 %s * :End of /LINKS list.",user->nick);
+}
+
+
diff --git a/src/cmd_list.cpp b/src/cmd_list.cpp
new file mode 100644
index 000000000..46109e4d8
--- /dev/null
+++ b/src/cmd_list.cpp
@@ -0,0 +1,80 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_list.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_list::Handle (char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"321 %s Channel :Users Name",user->nick);
+ for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++)
+ {
+ // if the channel is not private/secret, OR the user is on the channel anyway
+ if (((!(i->second->binarymodes & CM_PRIVATE)) && (!(i->second->binarymodes & CM_SECRET))) || (has_channel(user,i->second)))
+ {
+ WriteServ(user->fd,"322 %s %s %d :[+%s] %s",user->nick,i->second->name,usercount_i(i->second),chanmodes(i->second),i->second->topic);
+ }
+ }
+ WriteServ(user->fd,"323 %s :End of channel list.",user->nick);
+}
+
+
+
diff --git a/src/cmd_loadmodule.cpp b/src/cmd_loadmodule.cpp
new file mode 100644
index 000000000..e7bf37202
--- /dev/null
+++ b/src/cmd_loadmodule.cpp
@@ -0,0 +1,78 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_loadmodule.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_loadmodule::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (ServerInstance->LoadModule(parameters[0]))
+ {
+ WriteOpers("*** NEW MODULE: %s",parameters[0]);
+ WriteServ(user->fd,"975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
+ }
+}
+
+
diff --git a/src/cmd_lusers.cpp b/src/cmd_lusers.cpp
new file mode 100644
index 000000000..bfe208e12
--- /dev/null
+++ b/src/cmd_lusers.cpp
@@ -0,0 +1,76 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_lusers.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_lusers::Handle (char **parameters, int pcnt, userrec *user)
+{
+ // this lusers command shows one server at all times because
+ // a protocol module must override it to show those stats.
+ WriteServ(user->fd,"251 %s :There are %d users and %d invisible on 1 server",user->nick,usercnt()-usercount_invisible(),usercount_invisible());
+ WriteServ(user->fd,"252 %s %d :operator(s) online",user->nick,usercount_opers());
+ WriteServ(user->fd,"253 %s %d :unknown connections",user->nick,usercount_unknown());
+ WriteServ(user->fd,"254 %s %d :channels formed",user->nick,chancount());
+ WriteServ(user->fd,"254 %s :I have %d clients and 0 servers",user->nick,local_count());
+}
+
+
diff --git a/src/cmd_map.cpp b/src/cmd_map.cpp
new file mode 100644
index 000000000..4ada9a68d
--- /dev/null
+++ b/src/cmd_map.cpp
@@ -0,0 +1,73 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_map.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_map::Handle (char **parameters, int pcnt, userrec *user)
+{
+ // as with /LUSERS this does nothing without a linking
+ // module to override its behaviour and display something
+ // better.
+ WriteServ(user->fd,"006 %s :%s",user->nick,Config->ServerName);
+ WriteServ(user->fd,"007 %s :End of /MAP",user->nick);
+}
+
diff --git a/src/cmd_modules.cpp b/src/cmd_modules.cpp
new file mode 100644
index 000000000..5d8625576
--- /dev/null
+++ b/src/cmd_modules.cpp
@@ -0,0 +1,96 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_modules.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_modules::Handle (char **parameters, int pcnt, userrec *user)
+{
+ for (unsigned int i = 0; i < Config->module_names.size(); i++)
+ {
+ Version V = modules[i]->GetVersion();
+ char modulename[MAXBUF];
+ char flagstate[MAXBUF];
+ strcpy(flagstate,"");
+ if (V.Flags & VF_STATIC)
+ strlcat(flagstate,", static",MAXBUF);
+ if (V.Flags & VF_VENDOR)
+ strlcat(flagstate,", vendor",MAXBUF);
+ if (V.Flags & VF_COMMON)
+ strlcat(flagstate,", common",MAXBUF);
+ if (V.Flags & VF_SERVICEPROVIDER)
+ strlcat(flagstate,", service provider",MAXBUF);
+ if (!flagstate[0])
+ strcpy(flagstate," <no flags>");
+ strlcpy(modulename,Config->module_names[i].c_str(),256);
+ if (strchr(user->modes,'o'))
+ {
+ WriteServ(user->fd,"900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,modules[i],V.Major,V.Minor,V.Revision,V.Build,CleanFilename(modulename),flagstate+2);
+ }
+ else
+ {
+ WriteServ(user->fd,"900 %s :%s",user->nick,CleanFilename(modulename));
+ }
+ }
+ WriteServ(user->fd,"901 %s :End of MODULES list",user->nick);
+}
+
+
diff --git a/src/cmd_motd.cpp b/src/cmd_motd.cpp
new file mode 100644
index 000000000..e1193e40b
--- /dev/null
+++ b/src/cmd_motd.cpp
@@ -0,0 +1,70 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_motd.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_motd::Handle (char **parameters, int pcnt, userrec *user)
+{
+ ShowMOTD(user);
+}
+
+
diff --git a/src/cmd_names.cpp b/src/cmd_names.cpp
new file mode 100644
index 000000000..e319ad31e
--- /dev/null
+++ b/src/cmd_names.cpp
@@ -0,0 +1,94 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_names.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_names::Handle (char **parameters, int pcnt, userrec *user)
+{
+ chanrec* c;
+
+ if (!pcnt)
+ {
+ WriteServ(user->fd,"366 %s * :End of /NAMES list.",user->nick);
+ return;
+ }
+
+ /*if (ServerInstance->Parser->LoopCall(handle_names,parameters,pcnt,user,0,pcnt-1,0))
+ return;*/
+ c = FindChan(parameters[0]);
+ if (c)
+ {
+ if (((c) && (!has_channel(user,c))) && (c->binarymodes & CM_SECRET))
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, c->name);
+ return;
+ }
+ userlist(user,c);
+ WriteServ(user->fd,"366 %s %s :End of /NAMES list.", user->nick, c->name);
+ }
+ else
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
+}
+
+
diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp
new file mode 100644
index 000000000..83bb96859
--- /dev/null
+++ b/src/cmd_nick.cpp
@@ -0,0 +1,183 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_nick.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_nick::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (pcnt < 1)
+ {
+ log(DEBUG,"not enough params for handle_nick");
+ return;
+ }
+ if (!parameters[0])
+ {
+ log(DEBUG,"invalid parameter passed to handle_nick");
+ return;
+ }
+ if (!parameters[0][0])
+ {
+ log(DEBUG,"zero length new nick passed to handle_nick");
+ return;
+ }
+ if (!user)
+ {
+ log(DEBUG,"invalid user passed to handle_nick");
+ return;
+ }
+ if (!user->nick)
+ {
+ log(DEBUG,"invalid old nick passed to handle_nick");
+ return;
+ }
+ if (!strcasecmp(user->nick,parameters[0]))
+ {
+ log(DEBUG,"old nick is new nick, skipping");
+ return;
+ }
+ else
+ {
+ if (strlen(parameters[0]) > 1)
+ {
+ if (parameters[0][0] == ':')
+ {
+ *parameters[0]++;
+ }
+ }
+ if (matches_qline(parameters[0]))
+ {
+ WriteOpers("*** Q-Lined nickname %s from %s!%s@%s: %s",parameters[0],user->nick,user->ident,user->host,matches_qline(parameters[0]));
+ WriteServ(user->fd,"432 %s %s :Invalid nickname: %s",user->nick,parameters[0],matches_qline(parameters[0]));
+ return;
+ }
+ if ((Find(parameters[0])) && (Find(parameters[0]) != user))
+ {
+ WriteServ(user->fd,"433 %s %s :Nickname is already in use.",user->nick,parameters[0]);
+ return;
+ }
+ }
+ if (isnick(parameters[0]) == 0)
+ {
+ WriteServ(user->fd,"432 %s %s :Erroneous Nickname",user->nick,parameters[0]);
+ return;
+ }
+
+ if (user->registered == 7)
+ {
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(OnUserPreNick(user,parameters[0]));
+ if (MOD_RESULT) {
+ // if a module returns true, the nick change is silently forbidden.
+ return;
+ }
+
+ WriteCommon(user,"NICK %s",parameters[0]);
+
+ }
+
+ char oldnick[NICKMAX];
+ strlcpy(oldnick,user->nick,NICKMAX);
+
+ /* change the nick of the user in the users_hash */
+ user = ReHashNick(user->nick, parameters[0]);
+ /* actually change the nick within the record */
+ if (!user) return;
+ if (!user->nick) return;
+
+ strlcpy(user->nick, parameters[0],NICKMAX);
+
+ log(DEBUG,"new nick set: %s",user->nick);
+
+ if (user->registered < 3)
+ {
+ user->registered = (user->registered | 2);
+ // dont attempt to look up the dns until they pick a nick... because otherwise their pointer WILL change
+ // and unless we're lucky we'll get a duff one later on.
+ //user->dns_done = (!lookup_dns(user->nick));
+ //if (user->dns_done)
+ // log(DEBUG,"Aborting dns lookup of %s because dns server experienced a failure.",user->nick);
+
+#ifdef THREADED_DNS
+ // initialize their dns lookup thread
+ if (pthread_create(&user->dnsthread, NULL, dns_task, (void *)user) != 0)
+ {
+ log(DEBUG,"Failed to create DNS lookup thread for user %s",user->nick);
+ }
+#else
+ user->dns_done = (!lookup_dns(user->nick));
+ if (user->dns_done)
+ log(DEBUG,"Aborting dns lookup of %s because dns server experienced a failure.",user->nick);
+#endif
+
+ }
+ if (user->registered == 3)
+ {
+ /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
+ FOREACH_MOD OnUserRegister(user);
+ ConnectUser(user);
+ }
+ if (user->registered == 7)
+ {
+ FOREACH_MOD OnUserPostNick(user,oldnick);
+ }
+}
+
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
new file mode 100644
index 000000000..52c954d4e
--- /dev/null
+++ b/src/cmd_notice.cpp
@@ -0,0 +1,155 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_notice.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_notice::Handle (char **parameters, int pcnt, userrec *user)
+{
+ userrec *dest;
+ chanrec *chan;
+
+ user->idle_lastmsg = TIME;
+
+ /*if (ServerInstance->Parser->LoopCall(handle_notice,parameters,pcnt,user,0,pcnt-2,0))
+ return;*/
+ if (parameters[0][0] == '$')
+ {
+ // notice to server mask
+ char* servermask = parameters[0];
+ servermask++;
+ if (match(Config->ServerName,servermask))
+ {
+ NoticeAll(user, true, "%s",parameters[1]);
+ }
+ return;
+ }
+ else if (parameters[0][0] == '#')
+ {
+ chan = FindChan(parameters[0]);
+ if (chan)
+ {
+ if ((chan->binarymodes & CM_NOEXTERNAL) && (!has_channel(user,chan)))
+ {
+ WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name);
+ return;
+ }
+ if ((chan->binarymodes & CM_MODERATED) && (cstatus(user,chan)<STATUS_VOICE))
+ {
+ WriteServ(user->fd,"404 %s %s :Cannot send to channel (+m)", user->nick, chan->name);
+ return;
+ }
+
+ int MOD_RESULT = 0;
+
+ std::string temp = parameters[1];
+ FOREACH_RESULT(OnUserPreNotice(user,chan,TYPE_CHANNEL,temp));
+ if (MOD_RESULT) {
+ return;
+ }
+ parameters[1] = (char*)temp.c_str();
+
+ if (temp == "")
+ {
+ WriteServ(user->fd,"412 %s No text to send", user->nick);
+ return;
+ }
+
+ ChanExceptSender(chan, user, "NOTICE %s :%s", chan->name, parameters[1]);
+
+ FOREACH_MOD OnUserNotice(user,chan,TYPE_CHANNEL,parameters[1]);
+ }
+ else
+ {
+ /* no such nick/channel */
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
+ return;
+ }
+
+ dest = Find(parameters[0]);
+ if (dest)
+ {
+ int MOD_RESULT = 0;
+
+ std::string temp = parameters[1];
+ FOREACH_RESULT(OnUserPreNotice(user,dest,TYPE_USER,temp));
+ if (MOD_RESULT) {
+ return;
+ }
+ parameters[1] = (char*)temp.c_str();
+
+ if (dest->fd > -1)
+ {
+ // direct write, same server
+ WriteTo(user, dest, "NOTICE %s :%s", dest->nick, parameters[1]);
+ }
+
+ FOREACH_MOD OnUserNotice(user,dest,TYPE_USER,parameters[1]);
+ }
+ else
+ {
+ /* no such nick/channel */
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
+}
+
+
diff --git a/src/cmd_oper.cpp b/src/cmd_oper.cpp
new file mode 100644
index 000000000..f5610c485
--- /dev/null
+++ b/src/cmd_oper.cpp
@@ -0,0 +1,140 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_oper.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_oper::Handle (char **parameters, int pcnt, userrec *user)
+{
+ char LoginName[MAXBUF];
+ char Password[MAXBUF];
+ char OperType[MAXBUF];
+ char TypeName[MAXBUF];
+ char HostName[MAXBUF];
+ char TheHost[MAXBUF];
+ int j;
+ bool found = false;
+ bool fail2 = false;
+
+ snprintf(TheHost,MAXBUF,"%s@%s",user->ident,user->host);
+
+ for (int i = 0; i < Config->ConfValueEnum("oper",&Config->config_f); i++)
+ {
+ Config->ConfValue("oper","name",i,LoginName,&Config->config_f);
+ Config->ConfValue("oper","password",i,Password,&Config->config_f);
+ Config->ConfValue("oper","type",i,OperType,&Config->config_f);
+ Config->ConfValue("oper","host",i,HostName,&Config->config_f);
+ if ((!strcmp(LoginName,parameters[0])) && (!operstrcmp(Password,parameters[1])) && (match(TheHost,HostName)))
+ {
+ fail2 = true;
+ for (j =0; j < Config->ConfValueEnum("type",&Config->config_f); j++)
+ {
+ Config->ConfValue("type","name",j,TypeName,&Config->config_f);
+
+ if (!strcmp(TypeName,OperType))
+ {
+ /* found this oper's opertype */
+ Config->ConfValue("type","host",j,HostName,&Config->config_f);
+ if (*HostName)
+ ChangeDisplayedHost(user,HostName);
+ strlcpy(user->oper,TypeName,NICKMAX);
+ found = true;
+ fail2 = false;
+ break;
+ }
+ }
+ }
+ if (found)
+ break;
+ }
+ if (found)
+ {
+ /* correct oper credentials */
+ WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType);
+ WriteServ(user->fd,"381 %s :You are now an IRC operator of type %s",user->nick,OperType);
+ if (!strchr(user->modes,'o'))
+ {
+ strcat(user->modes,"o");
+ WriteServ(user->fd,"MODE %s :+o",user->nick);
+ FOREACH_MOD OnOper(user,OperType);
+ log(DEFAULT,"OPER: %s!%s@%s opered as type: %s",user->nick,user->ident,user->host,OperType);
+ AddOper(user);
+ }
+ }
+ else
+ {
+ if (!fail2)
+ {
+ WriteServ(user->fd,"491 %s :Invalid oper credentials",user->nick);
+ WriteOpers("*** WARNING! Failed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host);
+ log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: user, host or password did not match.",user->nick,user->ident,user->host);
+ }
+ else
+ {
+ WriteServ(user->fd,"491 %s :Your oper block does not have a valid opertype associated with it",user->nick);
+ WriteOpers("*** CONFIGURATION ERROR! Oper block mismatch for OperType %s",OperType);
+ log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: credentials valid, but oper type nonexistent.",user->nick,user->ident,user->host);
+ }
+ }
+ return;
+}
+
+
diff --git a/src/cmd_part.cpp b/src/cmd_part.cpp
new file mode 100644
index 000000000..23daecb76
--- /dev/null
+++ b/src/cmd_part.cpp
@@ -0,0 +1,81 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_part.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_part::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (pcnt > 1)
+ {
+ /*if (ServerInstance->Parser->LoopCall(handle_part,parameters,pcnt,user,0,pcnt-2,0))
+ return;*/
+ del_channel(user,parameters[0],parameters[1],false);
+ }
+ else
+ {
+ /*if (ServerInstance->Parser->LoopCall(handle_part,parameters,pcnt,user,0,pcnt-1,0))
+ return;*/
+ del_channel(user,parameters[0],NULL,false);
+ }
+}
+
+
diff --git a/src/cmd_pass.cpp b/src/cmd_pass.cpp
new file mode 100644
index 000000000..5b640fb76
--- /dev/null
+++ b/src/cmd_pass.cpp
@@ -0,0 +1,80 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_pass.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_pass::Handle (char **parameters, int pcnt, userrec *user)
+{
+ // Check to make sure they havnt registered -- Fix by FCS
+ if (user->registered == 7)
+ {
+ WriteServ(user->fd,"462 %s :You may not reregister",user->nick);
+ return;
+ }
+ strlcpy(user->password,parameters[0],MAXBUF);
+ if (!strcasecmp(parameters[0],Passwd(user)))
+ {
+ user->haspassed = true;
+ }
+}
+
+
diff --git a/src/cmd_ping.cpp b/src/cmd_ping.cpp
new file mode 100644
index 000000000..5447efbfc
--- /dev/null
+++ b/src/cmd_ping.cpp
@@ -0,0 +1,70 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_ping.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_ping::Handle (char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"PONG %s :%s",Config->ServerName,parameters[0]);
+}
+
+
diff --git a/src/cmd_pong.cpp b/src/cmd_pong.cpp
new file mode 100644
index 000000000..b77c42f10
--- /dev/null
+++ b/src/cmd_pong.cpp
@@ -0,0 +1,71 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_pong.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_pong::Handle (char **parameters, int pcnt, userrec *user)
+{
+ // set the user as alive so they survive to next ping
+ user->lastping = 1;
+}
+
+
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
new file mode 100644
index 000000000..9b5c1348c
--- /dev/null
+++ b/src/cmd_privmsg.cpp
@@ -0,0 +1,160 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_privmsg.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_privmsg::Handle (char **parameters, int pcnt, userrec *user)
+{
+ userrec *dest;
+ chanrec *chan;
+
+ user->idle_lastmsg = TIME;
+
+ /*if (ServerInstance->Parser->LoopCall(handle_privmsg,parameters,pcnt,user,0,pcnt-2,0))
+ return;*/
+ if (parameters[0][0] == '$')
+ {
+ // notice to server mask
+ char* servermask = parameters[0];
+ servermask++;
+ if (match(Config->ServerName,servermask))
+ {
+ ServerPrivmsgAll("%s",parameters[1]);
+ }
+ return;
+ }
+ else if (parameters[0][0] == '#')
+ {
+ chan = FindChan(parameters[0]);
+ if (chan)
+ {
+ if ((chan->binarymodes & CM_NOEXTERNAL) && (!has_channel(user,chan)))
+ {
+ WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name);
+ return;
+ }
+ if ((chan->binarymodes & CM_MODERATED) && (cstatus(user,chan)<STATUS_VOICE))
+ {
+ WriteServ(user->fd,"404 %s %s :Cannot send to channel (+m)", user->nick, chan->name);
+ return;
+ }
+
+ int MOD_RESULT = 0;
+
+ std::string temp = parameters[1];
+ FOREACH_RESULT(OnUserPreMessage(user,chan,TYPE_CHANNEL,temp));
+ if (MOD_RESULT) {
+ return;
+ }
+ parameters[1] = (char*)temp.c_str();
+
+ if (temp == "")
+ {
+ WriteServ(user->fd,"412 %s No text to send", user->nick);
+ return;
+ }
+
+ ChanExceptSender(chan, user, "PRIVMSG %s :%s", chan->name, parameters[1]);
+ FOREACH_MOD OnUserMessage(user,chan,TYPE_CHANNEL,parameters[1]);
+ }
+ else
+ {
+ /* no such nick/channel */
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
+ return;
+ }
+
+ dest = Find(parameters[0]);
+ if (dest)
+ {
+ if (strcmp(dest->awaymsg,""))
+ {
+ /* auto respond with aweh msg */
+ WriteServ(user->fd,"301 %s %s :%s",user->nick,dest->nick,dest->awaymsg);
+ }
+
+ int MOD_RESULT = 0;
+
+ std::string temp = parameters[1];
+ FOREACH_RESULT(OnUserPreMessage(user,dest,TYPE_USER,temp));
+ if (MOD_RESULT) {
+ return;
+ }
+ parameters[1] = (char*)temp.c_str();
+
+ if (dest->fd > -1)
+ {
+ // direct write, same server
+ WriteTo(user, dest, "PRIVMSG %s :%s", dest->nick, parameters[1]);
+ }
+
+ FOREACH_MOD OnUserMessage(user,dest,TYPE_USER,parameters[1]);
+ }
+ else
+ {
+ /* no such nick/channel */
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
+}
+
+
diff --git a/src/cmd_qline.cpp b/src/cmd_qline.cpp
new file mode 100644
index 000000000..9f3d3c316
--- /dev/null
+++ b/src/cmd_qline.cpp
@@ -0,0 +1,97 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_qline.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_qline::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (pcnt >= 3)
+ {
+ if (nick_matches_everyone(parameters[0],user))
+ return;
+ add_qline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
+ FOREACH_MOD OnAddQLine(duration(parameters[1]), user, parameters[2], parameters[0]);
+ if (!duration(parameters[1]))
+ {
+ WriteOpers("*** %s added permenant Q-line for %s.",user->nick,parameters[0]);
+ }
+ else
+ {
+ WriteOpers("*** %s added timed Q-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+ }
+ apply_lines(APPLY_QLINES);
+ }
+ else
+ {
+ if (del_qline(parameters[0]))
+ {
+ FOREACH_MOD OnDelQLine(user, parameters[0]);
+ WriteOpers("*** %s Removed Q-line on %s.",user->nick,parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"NOTICE %s :*** Q-Line %s not found in list, try /stats q.",user->nick,parameters[0]);
+ }
+ }
+}
+
+
diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp
new file mode 100644
index 000000000..0b7357417
--- /dev/null
+++ b/src/cmd_quit.cpp
@@ -0,0 +1,141 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_quit.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_quit::Handle (char **parameters, int pcnt, userrec *user)
+{
+ user_hash::iterator iter = clientlist.find(user->nick);
+ char* reason;
+
+ if (user->registered == 7)
+ {
+ /* theres more to do here, but for now just close the socket */
+ if (pcnt == 1)
+ {
+ if (parameters[0][0] == ':')
+ {
+ *parameters[0]++;
+ }
+ reason = parameters[0];
+
+ if (strlen(reason)>MAXQUIT)
+ {
+ reason[MAXQUIT-1] = '\0';
+ }
+
+ /* We should only prefix the quit for a local user. Remote users have
+ * already been prefixed, where neccessary, by the upstream server.
+ */
+ if (user->fd > -1)
+ {
+ Write(user->fd,"ERROR :Closing link (%s@%s) [%s%s]",user->ident,user->host,Config->PrefixQuit,parameters[0]);
+ WriteOpers("*** Client exiting: %s!%s@%s [%s%s]",user->nick,user->ident,user->host,Config->PrefixQuit,parameters[0]);
+ WriteCommonExcept(user,"QUIT :%s%s",Config->PrefixQuit,parameters[0]);
+ }
+ else
+ {
+ WriteOpers("*** Client exiting at %s: %s!%s@%s [%s]",user->server,user->nick,user->ident,user->host,parameters[0]);
+ WriteCommonExcept(user,"QUIT :%s",parameters[0]);
+ }
+ FOREACH_MOD OnUserQuit(user,std::string(Config->PrefixQuit)+std::string(parameters[0]));
+
+ }
+ else
+ {
+ Write(user->fd,"ERROR :Closing link (%s@%s) [QUIT]",user->ident,user->host);
+ WriteOpers("*** Client exiting: %s!%s@%s [Client exited]",user->nick,user->ident,user->host);
+ WriteCommonExcept(user,"QUIT :Client exited");
+ FOREACH_MOD OnUserQuit(user,"Client exited");
+
+ }
+ AddWhoWas(user);
+ }
+
+ FOREACH_MOD OnUserDisconnect(user);
+
+ /* push the socket on a stack of sockets due to be closed at the next opportunity */
+ if (user->fd > -1)
+ {
+ ServerInstance->SE->DelFd(user->fd);
+ if (find(local_users.begin(),local_users.end(),user) != local_users.end())
+ {
+ log(DEBUG,"Delete local user");
+ local_users.erase(find(local_users.begin(),local_users.end(),user));
+ }
+ user->CloseSocket();
+ }
+
+ if (iter != clientlist.end())
+ {
+ clientlist.erase(iter);
+ }
+
+ if (user->registered == 7) {
+ purge_empty_chans(user);
+ }
+ if (user->fd > -1)
+ fd_ref_table[user->fd] = NULL;
+ delete user;
+}
+
+
diff --git a/src/cmd_rehash.cpp b/src/cmd_rehash.cpp
new file mode 100644
index 000000000..c18963db5
--- /dev/null
+++ b/src/cmd_rehash.cpp
@@ -0,0 +1,81 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_rehash.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_rehash::Handle (char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"382 %s %s :Rehashing",user->nick,CleanFilename(CONFIG_FILE));
+ std::string parameter = "";
+ if (pcnt)
+ {
+ parameter = parameters[0];
+ }
+ else
+ {
+ WriteOpers("%s is rehashing config file %s",user->nick,CleanFilename(CONFIG_FILE));
+ Config->Read(false,user);
+ }
+ FOREACH_MOD OnRehash(parameter);
+}
+
+
diff --git a/src/cmd_restart.cpp b/src/cmd_restart.cpp
new file mode 100644
index 000000000..48cf6e703
--- /dev/null
+++ b/src/cmd_restart.cpp
@@ -0,0 +1,105 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_restart.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_restart::Handle (char **parameters, int pcnt, userrec *user)
+{
+ char *argv[32];
+ log(DEFAULT,"Restart: %s",user->nick);
+ if (!strcmp(parameters[0],Config->restartpass))
+ {
+ WriteOpers("*** RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host);
+
+ argv[0] = Config->MyExecutable;
+ argv[1] = "-wait";
+ if (Config->nofork)
+ {
+ argv[2] = "-nofork";
+ }
+ else
+ {
+ argv[2] = NULL;
+ }
+ argv[3] = NULL;
+
+ // close ALL file descriptors
+ send_error("Server restarting.");
+ sleep(1);
+ for (int i = 0; i < 65536; i++)
+ {
+ shutdown(i,2);
+ close(i);
+ }
+ sleep(2);
+
+ execv(Config->MyExecutable,argv);
+
+ exit(0);
+ }
+ else
+ {
+ WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);
+ }
+}
+
+
diff --git a/src/cmd_rules.cpp b/src/cmd_rules.cpp
new file mode 100644
index 000000000..d045bf210
--- /dev/null
+++ b/src/cmd_rules.cpp
@@ -0,0 +1,70 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_rules.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_rules::Handle (char **parameters, int pcnt, userrec *user)
+{
+ ShowRULES(user);
+}
+
+
diff --git a/src/cmd_server.cpp b/src/cmd_server.cpp
new file mode 100644
index 000000000..264348ebb
--- /dev/null
+++ b/src/cmd_server.cpp
@@ -0,0 +1,71 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_server.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_server::Handle (char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"666 %s :You cannot identify as a server, you are a USER. IRC Operators informed.",user->nick);
+ WriteOpers("*** WARNING: %s attempted to issue a SERVER command and is registered as a user!",user->nick);
+}
+
+
diff --git a/src/cmd_squit.cpp b/src/cmd_squit.cpp
new file mode 100644
index 000000000..6209081a3
--- /dev/null
+++ b/src/cmd_squit.cpp
@@ -0,0 +1,69 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_squit.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_squit::Handle (char **parameters, int pcnt, userrec *user)
+{
+}
+
+
diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp
new file mode 100644
index 000000000..d45ce68d9
--- /dev/null
+++ b/src/cmd_stats.cpp
@@ -0,0 +1,267 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#ifdef THREADED_DNS
+#include <pthread.h>
+#endif
+#ifndef RUSAGE_SELF
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN -1
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_stats.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_stats::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (pcnt != 1)
+ {
+ return;
+ }
+ if (strlen(parameters[0])>1)
+ {
+ /* make the stats query 1 character long */
+ parameters[0][1] = '\0';
+ }
+
+
+ FOREACH_MOD OnStats(*parameters[0]);
+
+ if (*parameters[0] == 'c')
+ {
+ /* This stats symbol must be handled by a linking module */
+ }
+
+ if (*parameters[0] == 'i')
+ {
+ int idx = 0;
+ for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
+ {
+ WriteServ(user->fd,"215 %s I * * * %d %d %s *",user->nick,MAXCLIENTS,idx,Config->ServerName);
+ idx++;
+ }
+ }
+
+ if (*parameters[0] == 'y')
+ {
+ int idx = 0;
+ for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
+ {
+ WriteServ(user->fd,"218 %s Y %d %d 0 %d %d",user->nick,idx,120,i->flood,i->registration_timeout);
+ idx++;
+ }
+ }
+
+ if (*parameters[0] == 'U')
+ {
+ char ulined[MAXBUF];
+ for (int i = 0; i < Config->ConfValueEnum("uline",&Config->config_f); i++)
+ {
+ Config->ConfValue("uline","server",i,ulined,&Config->config_f);
+ WriteServ(user->fd,"248 %s U %s",user->nick,ulined);
+ }
+ }
+
+ if (*parameters[0] == 'P')
+ {
+ int idx = 0;
+ for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++)
+ {
+ if (strchr(i->second->modes,'o'))
+ {
+ WriteServ(user->fd,"249 %s :%s (%s@%s) Idle: %d",user->nick,i->second->nick,i->second->ident,i->second->dhost,(TIME - i->second->idle_lastmsg));
+ idx++;
+ }
+ }
+ WriteServ(user->fd,"249 %s :%d OPER(s)",user->nick,idx);
+ }
+
+ if (*parameters[0] == 'k')
+ {
+ stats_k(user);
+ }
+
+ if (*parameters[0] == 'g')
+ {
+ stats_g(user);
+ }
+
+ if (*parameters[0] == 'q')
+ {
+ stats_q(user);
+ }
+
+ if (*parameters[0] == 'Z')
+ {
+ stats_z(user);
+ }
+
+ if (*parameters[0] == 'e')
+ {
+ stats_e(user);
+ }
+
+ /* stats m (list number of times each command has been used, plus bytecount) */
+ if (*parameters[0] == 'm')
+ {
+ for (unsigned int i = 0; i < ServerInstance->Parser->cmdlist.size(); i++)
+ {
+ if (ServerInstance->Parser->cmdlist[i]->use_count)
+ {
+ /* RPL_STATSCOMMANDS */
+ WriteServ(user->fd,"212 %s %s %d %d",user->nick,ServerInstance->Parser->cmdlist[i]->command.c_str(),ServerInstance->Parser->cmdlist[i]->use_count,ServerInstance->Parser->cmdlist[i]->total_bytes);
+ }
+ }
+
+ }
+
+ /* stats z (debug and memory info) */
+ if (*parameters[0] == 'z')
+ {
+ rusage R;
+ WriteServ(user->fd,"249 %s :Users(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,clientlist.size(),clientlist.size()*sizeof(userrec),clientlist.bucket_count());
+ WriteServ(user->fd,"249 %s :Channels(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,chanlist.size(),chanlist.size()*sizeof(chanrec),chanlist.bucket_count());
+ WriteServ(user->fd,"249 %s :Commands(VECTOR) %d (%d bytes)",user->nick,ServerInstance->Parser->cmdlist.size(),ServerInstance->Parser->cmdlist.size()*sizeof(command_t));
+ WriteServ(user->fd,"249 %s :MOTD(VECTOR) %d, RULES(VECTOR) %d",user->nick,Config->MOTD.size(),Config->RULES.size());
+ WriteServ(user->fd,"249 %s :Modules(VECTOR) %d (%d)",user->nick,modules.size(),modules.size()*sizeof(Module));
+ WriteServ(user->fd,"249 %s :ClassFactories(VECTOR) %d (%d)",user->nick,factory.size(),factory.size()*sizeof(ircd_module));
+ if (!getrusage(RUSAGE_SELF,&R))
+ {
+ WriteServ(user->fd,"249 %s :Total allocation: %luK (0x%lx)",user->nick,R.ru_maxrss,R.ru_maxrss);
+ WriteServ(user->fd,"249 %s :Signals: %lu (0x%lx)",user->nick,R.ru_nsignals,R.ru_nsignals);
+ WriteServ(user->fd,"249 %s :Page faults: %lu (0x%lx)",user->nick,R.ru_majflt,R.ru_majflt);
+ WriteServ(user->fd,"249 %s :Swaps: %lu (0x%lx)",user->nick,R.ru_nswap,R.ru_nswap);
+ WriteServ(user->fd,"249 %s :Context Switches: %lu (0x%lx)",user->nick,R.ru_nvcsw+R.ru_nivcsw,R.ru_nvcsw+R.ru_nivcsw);
+ }
+ }
+
+ if (*parameters[0] == 'T')
+ {
+ WriteServ(user->fd,"249 Brain :accepts %d refused %d",ServerInstance->stats->statsAccept,ServerInstance->stats->statsRefused);
+ WriteServ(user->fd,"249 Brain :unknown commands %d",ServerInstance->stats->statsUnknown);
+ WriteServ(user->fd,"249 Brain :nick collisions %d",ServerInstance->stats->statsCollisions);
+ WriteServ(user->fd,"249 Brain :dns requests %d succeeded %d failed %d",ServerInstance->stats->statsDns,ServerInstance->stats->statsDnsGood,ServerInstance->stats->statsDnsBad);
+ WriteServ(user->fd,"249 Brain :connections %d",ServerInstance->stats->statsConnects);
+ WriteServ(user->fd,"249 Brain :bytes sent %dK recv %dK",(ServerInstance->stats->statsSent / 1024),(ServerInstance->stats->statsRecv / 1024));
+ }
+
+ /* stats o */
+ if (*parameters[0] == 'o')
+ {
+ for (int i = 0; i < Config->ConfValueEnum("oper",&Config->config_f); i++)
+ {
+ char LoginName[MAXBUF];
+ char HostName[MAXBUF];
+ char OperType[MAXBUF];
+ Config->ConfValue("oper","name",i,LoginName,&Config->config_f);
+ Config->ConfValue("oper","host",i,HostName,&Config->config_f);
+ Config->ConfValue("oper","type",i,OperType,&Config->config_f);
+ WriteServ(user->fd,"243 %s O %s * %s %s 0",user->nick,HostName,LoginName,OperType);
+ }
+ }
+
+ /* stats l (show user I/O stats) */
+ if (*parameters[0] == 'l')
+ {
+ WriteServ(user->fd,"211 %s :server:port nick bytes_in cmds_in bytes_out cmds_out",user->nick);
+ for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++)
+ {
+ if (isnick(i->second->nick))
+ {
+ WriteServ(user->fd,"211 %s :%s:%d %s %d %d %d %d",user->nick,i->second->server,i->second->port,i->second->nick,i->second->bytes_in,i->second->cmds_in,i->second->bytes_out,i->second->cmds_out);
+ }
+ else
+ {
+ WriteServ(user->fd,"211 %s :%s:%d (unknown@%d) %d %d %d %d",user->nick,i->second->server,i->second->port,i->second->fd,i->second->bytes_in,i->second->cmds_in,i->second->bytes_out,i->second->cmds_out);
+ }
+
+ }
+ }
+
+ /* stats u (show server uptime) */
+ if (*parameters[0] == 'u')
+ {
+ time_t current_time = 0;
+ current_time = TIME;
+ time_t server_uptime = current_time - ServerInstance->startup_time;
+ struct tm* stime;
+ stime = gmtime(&server_uptime);
+ /* i dont know who the hell would have an ircd running for over a year nonstop, but
+ * Craig suggested this, and it seemed a good idea so in it went */
+ if (stime->tm_year > 70)
+ {
+ WriteServ(user->fd,"242 %s :Server up %d years, %d days, %.2d:%.2d:%.2d",user->nick,(stime->tm_year-70),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
+ }
+ else
+ {
+ WriteServ(user->fd,"242 %s :Server up %d days, %.2d:%.2d:%.2d",user->nick,stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
+ }
+ }
+
+ WriteServ(user->fd,"219 %s %s :End of /STATS report",user->nick,parameters[0]);
+ WriteOpers("*** Notice: Stats '%s' requested by %s (%s@%s)",parameters[0],user->nick,user->ident,user->host);
+
+}
+
+
+
diff --git a/src/cmd_summon.cpp b/src/cmd_summon.cpp
new file mode 100644
index 000000000..68b084781
--- /dev/null
+++ b/src/cmd_summon.cpp
@@ -0,0 +1,70 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_summon.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_summon::Handle (char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"445 %s :SUMMON has been disabled (depreciated command)",user->nick);
+}
+
+
diff --git a/src/cmd_time.cpp b/src/cmd_time.cpp
new file mode 100644
index 000000000..8da4a0486
--- /dev/null
+++ b/src/cmd_time.cpp
@@ -0,0 +1,76 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_time.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_time::Handle (char **parameters, int pcnt, userrec *user)
+{
+ time_t rawtime;
+ struct tm * timeinfo;
+
+ time(&rawtime);
+ timeinfo = localtime(&rawtime);
+ WriteServ(user->fd,"391 %s %s :%s",user->nick,Config->ServerName,asctime(timeinfo));
+
+}
+
+
diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp
new file mode 100644
index 000000000..2cb646323
--- /dev/null
+++ b/src/cmd_topic.cpp
@@ -0,0 +1,148 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_topic.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_topic::Handle (char **parameters, int pcnt, userrec *user)
+{
+ chanrec* Ptr;
+
+ if (pcnt == 1)
+ {
+ if (strlen(parameters[0]) <= CHANMAX)
+ {
+ Ptr = FindChan(parameters[0]);
+ if (Ptr)
+ {
+ if (((Ptr) && (!has_channel(user,Ptr))) && (Ptr->binarymodes & CM_SECRET))
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, Ptr->name);
+ return;
+ }
+ if (Ptr->topicset)
+ {
+ WriteServ(user->fd,"332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
+ WriteServ(user->fd,"333 %s %s %s %d", user->nick, Ptr->name, Ptr->setby, Ptr->topicset);
+ }
+ else
+ {
+ WriteServ(user->fd,"331 %s %s :No topic is set.", user->nick, Ptr->name);
+ }
+ }
+ else
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
+ }
+ return;
+ }
+ else if (pcnt>1)
+ {
+ if (strlen(parameters[0]) <= CHANMAX)
+ {
+ Ptr = FindChan(parameters[0]);
+ if (Ptr)
+ {
+ if ((Ptr) && (!has_channel(user,Ptr)))
+ {
+ WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, Ptr->name);
+ return;
+ }
+ if ((Ptr->binarymodes & CM_TOPICLOCK) && (cstatus(user,Ptr)<STATUS_HOP))
+ {
+ WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name);
+ return;
+ }
+
+ char topic[MAXBUF];
+ strlcpy(topic,parameters[1],MAXBUF);
+ if (strlen(topic)>MAXTOPIC)
+ {
+ topic[MAXTOPIC] = '\0';
+ }
+
+ if (user->fd > -1)
+ {
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(OnLocalTopicChange(user,Ptr,topic));
+ if (MOD_RESULT)
+ return;
+ }
+
+ strlcpy(Ptr->topic,topic,MAXTOPIC);
+ strlcpy(Ptr->setby,user->nick,NICKMAX);
+ Ptr->topicset = TIME;
+ WriteChannel(Ptr,user,"TOPIC %s :%s",Ptr->name, Ptr->topic);
+ if (user->fd > -1)
+ {
+ FOREACH_MOD OnPostLocalTopicChange(user,Ptr,topic);
+ }
+ }
+ else
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
+ }
+ }
+}
+
+
diff --git a/src/cmd_trace.cpp b/src/cmd_trace.cpp
new file mode 100644
index 000000000..e757896ae
--- /dev/null
+++ b/src/cmd_trace.cpp
@@ -0,0 +1,90 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_trace.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_trace::Handle (char **parameters, int pcnt, userrec *user)
+{
+ for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++)
+ {
+ if (i->second)
+ {
+ if (isnick(i->second->nick))
+ {
+ if (strchr(i->second->modes,'o'))
+ {
+ WriteServ(user->fd,"205 %s :Oper 0 %s",user->nick,i->second->nick);
+ }
+ else
+ {
+ WriteServ(user->fd,"204 %s :User 0 %s",user->nick,i->second->nick);
+ }
+ }
+ else
+ {
+ WriteServ(user->fd,"203 %s :???? 0 [%s]",user->nick,i->second->host);
+ }
+ }
+ }
+}
+
+
diff --git a/src/cmd_unloadmodule.cpp b/src/cmd_unloadmodule.cpp
new file mode 100644
index 000000000..353933ef4
--- /dev/null
+++ b/src/cmd_unloadmodule.cpp
@@ -0,0 +1,78 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_unloadmodule.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_unloadmodule::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (ServerInstance->UnloadModule(parameters[0]))
+ {
+ WriteOpers("*** MODULE UNLOADED: %s",parameters[0]);
+ WriteServ(user->fd,"973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
+ }
+}
+
+
diff --git a/src/cmd_user.cpp b/src/cmd_user.cpp
new file mode 100644
index 000000000..4e09d60ee
--- /dev/null
+++ b/src/cmd_user.cpp
@@ -0,0 +1,99 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_user.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_user::Handle (char **parameters, int pcnt, userrec *user)
+{
+ log(DEBUG,"Handling USER from cmd_user class!");
+ if (user->registered < 3)
+ {
+ if (isident(parameters[0]) == 0) {
+ // This kinda Sucks, According to the RFC thou, its either this,
+ // or "You have already registered" :p -- Craig
+ WriteServ(user->fd,"461 %s USER :Not enough parameters",user->nick);
+ }
+ else {
+ /* We're not checking ident, but I'm not sure I like the idea of '~' prefixing.. */
+ /* XXX - Should this IDENTMAX + 1 be IDENTMAX - 1? Ok, users.h has it defined as
+ * char ident[IDENTMAX+2]; - WTF?
+ */
+ snprintf(user->ident, IDENTMAX+1, "~%s", parameters[0]);
+ strlcpy(user->fullname,parameters[3],MAXGECOS);
+ user->registered = (user->registered | 1);
+ }
+ }
+ else
+ {
+ WriteServ(user->fd,"462 %s :You may not reregister",user->nick);
+ return;
+ }
+ /* parameters 2 and 3 are local and remote hosts, ignored when sent by client connection */
+ if (user->registered == 3)
+ {
+ /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
+ FOREACH_MOD OnUserRegister(user);
+ ConnectUser(user);
+ }
+}
+
+
diff --git a/src/cmd_userhost.cpp b/src/cmd_userhost.cpp
new file mode 100644
index 000000000..07e2b1255
--- /dev/null
+++ b/src/cmd_userhost.cpp
@@ -0,0 +1,90 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_userhost.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_userhost::Handle (char **parameters, int pcnt, userrec *user)
+{
+ char Return[MAXBUF],junk[MAXBUF];
+ snprintf(Return,MAXBUF,"302 %s :",user->nick);
+ for (int i = 0; i < pcnt; i++)
+ {
+ userrec *u = Find(parameters[i]);
+ if (u)
+ {
+ if (strchr(u->modes,'o'))
+ {
+ snprintf(junk,MAXBUF,"%s*=+%s@%s ",u->nick,u->ident,u->host);
+ strlcat(Return,junk,MAXBUF);
+ }
+ else
+ {
+ snprintf(junk,MAXBUF,"%s=+%s@%s ",u->nick,u->ident,u->host);
+ strlcat(Return,junk,MAXBUF);
+ }
+ }
+ }
+ WriteServ(user->fd,Return);
+}
+
+
+
diff --git a/src/cmd_users.cpp b/src/cmd_users.cpp
new file mode 100644
index 000000000..e7be615f4
--- /dev/null
+++ b/src/cmd_users.cpp
@@ -0,0 +1,70 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_users.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_users::Handle (char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"445 %s :USERS has been disabled (depreciated command)",user->nick);
+}
+
+
diff --git a/src/cmd_version.cpp b/src/cmd_version.cpp
new file mode 100644
index 000000000..29350734e
--- /dev/null
+++ b/src/cmd_version.cpp
@@ -0,0 +1,70 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_version.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_version::Handle (char **parameters, int pcnt, userrec *user)
+{
+ WriteServ(user->fd,"351 %s :%s",user->nick,ServerInstance->GetVersionString().c_str());
+}
+
+
diff --git a/src/cmd_wallops.cpp b/src/cmd_wallops.cpp
new file mode 100644
index 000000000..6cb7e00aa
--- /dev/null
+++ b/src/cmd_wallops.cpp
@@ -0,0 +1,71 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_wallops.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_wallops::Handle (char **parameters, int pcnt, userrec *user)
+{
+ WriteWallOps(user,false,"%s",parameters[0]);
+ FOREACH_MOD OnWallops(user,parameters[0]);
+}
+
+
diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp
new file mode 100644
index 000000000..9c74b29eb
--- /dev/null
+++ b/src/cmd_who.cpp
@@ -0,0 +1,191 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_who.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_who::Handle (char **parameters, int pcnt, userrec *user)
+{
+ chanrec* Ptr = NULL;
+ char tmp[10];
+
+ /* theres more to do here, but for now just close the socket */
+ if (pcnt == 1)
+ {
+ if ((!strcmp(parameters[0],"0")) || (!strcmp(parameters[0],"*")))
+ {
+ if ((user->chans.size()) && (user->chans[0].channel))
+ {
+ int n_list = 0;
+ for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
+ {
+ Ptr = i->second->chans[0].channel;
+ // suggested by phidjit and FCS
+ if ((!common_channels(user,i->second)) && (isnick(i->second->nick)))
+ {
+ // Bug Fix #29
+ strcpy(tmp, "");
+ if (strcmp(i->second->awaymsg, "")) {
+ strlcat(tmp, "G", 9);
+ } else {
+ strlcat(tmp, "H", 9);
+ }
+ if (strchr(i->second->modes,'o')) { strlcat(tmp, "*", 9); }
+ WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, Ptr ? Ptr->name : "*", i->second->ident, i->second->dhost, i->second->server, i->second->nick, tmp, i->second->fullname);
+ n_list++;
+ if (n_list > Config->MaxWhoResults)
+ {
+ WriteServ(user->fd,"523 %s WHO :Command aborted: More results than configured limit",user->nick);
+ break;
+ }
+ }
+ }
+ }
+ if (Ptr)
+ {
+ WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick , parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
+ }
+ return;
+ }
+ if (parameters[0][0] == '#')
+ {
+ Ptr = FindChan(parameters[0]);
+ if (Ptr)
+ {
+ int n_list = 0;
+ for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
+ {
+ if ((has_channel(i->second,Ptr)) && (isnick(i->second->nick)))
+ {
+ // Fix Bug #29 - Part 2..
+ strcpy(tmp, "");
+ if (strcmp(i->second->awaymsg, "")) {
+ strlcat(tmp, "G", 9);
+ } else {
+ strlcat(tmp, "H", 9);
+ }
+ if (strchr(i->second->modes,'o')) { strlcat(tmp, "*", 9); }
+ strlcat(tmp, cmode(i->second, Ptr),5);
+ WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, Ptr->name, i->second->ident, i->second->dhost, i->second->server, i->second->nick, tmp, i->second->fullname);
+ n_list++;
+ if (n_list > Config->MaxWhoResults)
+ {
+ WriteServ(user->fd,"523 %s WHO :Command aborted: More results than configured limit",user->nick);
+ break;
+ }
+
+ }
+ }
+ WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ }
+ }
+ else
+ {
+ userrec* u = Find(parameters[0]);
+ if (u)
+ {
+ // Bug Fix #29 -- Part 29..
+ strcpy(tmp, "");
+ if (strcmp(u->awaymsg, "")) {
+ strlcat(tmp, "G" ,9);
+ } else {
+ strlcat(tmp, "H" ,9);
+ }
+ if (strchr(u->modes,'o')) { strlcat(tmp, "*" ,9); }
+ WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, u->chans.size() ? u->chans[0].channel->name
+ : "*", u->ident, u->dhost, u->server, u->nick, tmp, u->fullname);
+ }
+ WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
+ }
+ }
+ if (pcnt == 2)
+ {
+ if ((!strcmp(parameters[0],"0")) || (!strcmp(parameters[0],"*")) && (!strcmp(parameters[1],"o")))
+ {
+ for (std::vector<userrec*>::iterator i = all_opers.begin(); i != all_opers.end(); i++)
+ {
+ // If i were a rich man.. I wouldn't need to me making these bugfixes..
+ // But i'm a poor bastard with nothing better to do.
+ userrec* oper = *i;
+ strcpy(tmp, "");
+ if (strcmp(oper->awaymsg, "")) {
+ strlcat(tmp, "G" ,9);
+ } else {
+ strlcat(tmp, "H" ,9);
+ }
+ WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() ? oper->chans[0].channel->name
+ : "*", oper->ident, oper->dhost, oper->server, oper->nick, tmp, oper->fullname);
+ }
+ WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
+ return;
+ }
+ }
+}
+
+
diff --git a/src/cmd_whois.cpp b/src/cmd_whois.cpp
new file mode 100644
index 000000000..09ef9c67a
--- /dev/null
+++ b/src/cmd_whois.cpp
@@ -0,0 +1,82 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_whois.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_whois::Handle (char **parameters, int pcnt, userrec *user)
+{
+ userrec *dest;
+ /*if (ServerInstance->Parser->LoopCall(handle_whois,parameters,pcnt,user,0,pcnt-1,0))
+ return;*/
+ dest = Find(parameters[0]);
+ if (dest)
+ {
+ do_whois(user,dest,0,0,parameters[0]);
+ }
+ else
+ {
+ /* no such nick/channel */
+ WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
+ WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, parameters[0]);
+ }
+}
+
diff --git a/src/cmd_whowas.cpp b/src/cmd_whowas.cpp
new file mode 100644
index 000000000..40f1488a0
--- /dev/null
+++ b/src/cmd_whowas.cpp
@@ -0,0 +1,91 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_whowas.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_whowas::Handle (char **parameters, int pcnt, userrec* user)
+{
+ whowas_hash::iterator i = whowas.find(parameters[0]);
+
+ if (i == whowas.end())
+ {
+ WriteServ(user->fd,"406 %s %s :There was no such nickname",user->nick,parameters[0]);
+ WriteServ(user->fd,"369 %s %s :End of WHOWAS",user->nick,parameters[0]);
+ }
+ else
+ {
+ time_t rawtime = i->second->signon;
+ tm *timeinfo;
+ char b[MAXBUF];
+
+ timeinfo = localtime(&rawtime);
+ strlcpy(b,asctime(timeinfo),MAXBUF);
+ b[strlen(b)-1] = '\0';
+
+ WriteServ(user->fd,"314 %s %s %s %s * :%s",user->nick,i->second->nick,i->second->ident,i->second->dhost,i->second->fullname);
+ WriteServ(user->fd,"312 %s %s %s :%s",user->nick,i->second->nick,i->second->server,b);
+ WriteServ(user->fd,"369 %s %s :End of WHOWAS",user->nick,parameters[0]);
+ }
+
+}
+
+
diff --git a/src/cmd_zline.cpp b/src/cmd_zline.cpp
new file mode 100644
index 000000000..cf3b9b411
--- /dev/null
+++ b/src/cmd_zline.cpp
@@ -0,0 +1,102 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * E-mail:
+ * <brain.net>
+ * <Craig.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include <time.h>
+#include <string>
+#ifdef GCC3
+#include <ext/hash_map>
+#else
+#include <hash_map>
+#endif
+#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 "message.h"
+#include "commands.h"
+#include "mode.h"
+#include "xline.h"
+#include "inspstring.h"
+#include "dnsqueue.h"
+#include "helperfuncs.h"
+#include "hashcomp.h"
+#include "socketengine.h"
+#include "typedefs.h"
+#include "command_parse.h"
+#include "cmd_zline.h"
+
+extern ServerConfig* Config;
+extern InspIRCd* ServerInstance;
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
+extern time_t TIME;
+extern user_hash clientlist;
+extern chan_hash chanlist;
+extern whowas_hash whowas;
+extern std::vector<userrec*> all_opers;
+extern std::vector<userrec*> local_users;
+extern userrec* fd_ref_table[65536];
+
+void cmd_zline::Handle (char **parameters, int pcnt, userrec *user)
+{
+ if (pcnt >= 3)
+ {
+ if (strchr(parameters[0],'@'))
+ {
+ WriteServ(user->fd,"NOTICE %s :*** You cannot include a username in a zline, a zline must ban only an IP mask",user->nick);
+ return;
+ }
+ if (ip_matches_everyone(parameters[0],user))
+ return;
+ add_zline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
+ FOREACH_MOD OnAddZLine(duration(parameters[1]), user, parameters[2], parameters[0]);
+ if (!duration(parameters[1]))
+ {
+ WriteOpers("*** %s added permenant Z-line for %s.",user->nick,parameters[0]);
+ }
+ else
+ {
+ WriteOpers("*** %s added timed Z-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
+ }
+ apply_lines(APPLY_ZLINES);
+ }
+ else
+ {
+ if (del_zline(parameters[0]))
+ {
+ FOREACH_MOD OnDelZLine(user, parameters[0]);
+ WriteOpers("*** %s Removed Z-line on %s.",user->nick,parameters[0]);
+ }
+ else
+ {
+ WriteServ(user->fd,"NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick,parameters[0]);
+ }
+ }
+}
+
+
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index c2e4fc975..02414039d 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -103,7 +103,7 @@ extern chan_hash chanlist;
* before the actual list as well. This code is used by many functions which
* can function as "one to list" (see the RFC) */
-int CommandParser::LoopCall(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins)
+int CommandParser::LoopCall(command_t* fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins)
{
char plist[MAXBUF];
char *param;
@@ -230,17 +230,17 @@ int CommandParser::LoopCall(handlerfunc fn, char **parameters, int pcnt, userrec
if (pars[1])
{
// pars[1] already set up and containing key from blog2[j]
- fn(pars,2,u);
+ fn->Handle(pars,2,u);
}
else
{
pars[1] = parameters[1];
- fn(pars,2,u);
+ fn->Handle(pars,2,u);
}
}
else
{
- fn(pars,pcnt-(end-start),u);
+ fn->Handle(pars,pcnt-(end-start),u);
}
}
@@ -251,27 +251,24 @@ bool CommandParser::IsValidCommand(std::string &commandname, int pcnt, userrec *
{
for (unsigned int i = 0; i < cmdlist.size(); i++)
{
- if (!strcasecmp(cmdlist[i].command,commandname.c_str()))
+ if (cmdlist[i]->command == commandname)
{
- if (cmdlist[i].handler_function)
+ if ((pcnt>=cmdlist[i]->min_params) && (cmdlist[i]->source != "<core>"))
{
- if ((pcnt>=cmdlist[i].min_params) && (strcasecmp(cmdlist[i].source,"<core>")))
+ if ((strchr(user->modes,cmdlist[i]->flags_needed)) || (!cmdlist[i]->flags_needed))
{
- if ((strchr(user->modes,cmdlist[i].flags_needed)) || (!cmdlist[i].flags_needed))
+ if (cmdlist[i]->flags_needed)
{
- if (cmdlist[i].flags_needed)
+ if ((user->HasPermission(commandname)) || (is_uline(user->server)))
{
- if ((user->HasPermission(commandname)) || (is_uline(user->server)))
- {
- return true;
- }
- else
- {
- return false;
- }
+ return true;
+ }
+ else
+ {
+ return false;
}
- return true;
}
+ return true;
}
}
}
@@ -285,26 +282,23 @@ void CommandParser::CallHandler(std::string &commandname,char **parameters, int
{
for (unsigned int i = 0; i < cmdlist.size(); i++)
{
- if (!strcasecmp(cmdlist[i].command,commandname.c_str()))
+ if (cmdlist[i]->command == commandname)
{
- if (cmdlist[i].handler_function)
+ if (pcnt>=cmdlist[i]->min_params)
{
- if (pcnt>=cmdlist[i].min_params)
+ if ((strchr(user->modes,cmdlist[i]->flags_needed)) || (!cmdlist[i]->flags_needed))
{
- if ((strchr(user->modes,cmdlist[i].flags_needed)) || (!cmdlist[i].flags_needed))
+ if (cmdlist[i]->flags_needed)
{
- if (cmdlist[i].flags_needed)
+ if ((user->HasPermission(commandname)) || (is_uline(user->server)))
{
- if ((user->HasPermission(commandname)) || (is_uline(user->server)))
- {
- cmdlist[i].handler_function(parameters,pcnt,user);
- }
- }
- else
- {
- cmdlist[i].handler_function(parameters,pcnt,user);
+ cmdlist[i]->Handle(parameters,pcnt,user);
}
}
+ else
+ {
+ cmdlist[i]->Handle(parameters,pcnt,user);
+ }
}
}
}
@@ -508,9 +502,7 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd)
std::string xcommand = command;
for (unsigned int i = 0; i != cmdlist.size(); i++)
{
- if (cmdlist[i].command[0])
- {
- if (strlen(command)>=(strlen(cmdlist[i].command))) if (!strncmp(command, cmdlist[i].command,MAXCOMMAND))
+ if ((xcommand.length() >= cmdlist[i]->command.length()) && (xcommand == cmdlist[i]->command))
{
if (parameters)
{
@@ -534,20 +526,20 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd)
{
/* activity resets the ping pending timer */
user->nping = TIME + user->pingmax;
- if ((items) < cmdlist[i].min_params)
+ if ((items) < cmdlist[i]->min_params)
{
log(DEBUG,"not enough parameters: %s %s",user->nick,command);
WriteServ(user->fd,"461 %s %s :Not enough parameters",user->nick,command);
return;
}
- if ((!strchr(user->modes,cmdlist[i].flags_needed)) && (cmdlist[i].flags_needed))
+ if ((!strchr(user->modes,cmdlist[i]->flags_needed)) && (cmdlist[i]->flags_needed))
{
log(DEBUG,"permission denied: %s %s",user->nick,command);
WriteServ(user->fd,"481 %s :Permission Denied- You do not have the required operator privilages",user->nick);
cmd_found = 1;
return;
}
- if ((cmdlist[i].flags_needed) && (!user->HasPermission(xcommand)))
+ if ((cmdlist[i]->flags_needed) && (!user->HasPermission(xcommand)))
{
log(DEBUG,"permission denied: %s %s",user->nick,command);
WriteServ(user->fd,"481 %s :Permission Denied- Oper type %s does not have access to command %s",user->nick,user->oper,command);
@@ -582,14 +574,11 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd)
}
if ((user->registered == 7) || (!strncmp(command,"USER",4)) || (!strncmp(command,"NICK",4)) || (!strncmp(command,"PASS",4)))
{
- if (cmdlist[i].handler_function)
- {
-
/* ikky /stats counters */
if (temp)
{
- cmdlist[i].use_count++;
- cmdlist[i].total_bytes+=strlen(temp);
+ cmdlist[i]->use_count++;
+ cmdlist[i]->total_bytes+=strlen(temp);
}
int MOD_RESULT = 0;
@@ -602,8 +591,7 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd)
* command handler call, as the handler
* may free the user structure! */
- cmdlist[i].handler_function(command_p,items,user);
- }
+ cmdlist[i]->Handle(command_p,items,user);
return;
}
else
@@ -614,8 +602,6 @@ void CommandParser::ProcessCommand(userrec *user, char* cmd)
}
cmd_found = 1;
}
-
- }
}
if ((!cmd_found) && (user))
{
@@ -630,11 +616,12 @@ bool CommandParser::RemoveCommands(const char* source)
while (go_again)
{
go_again = false;
- for (std::deque<command_t>::iterator i = cmdlist.begin(); i != cmdlist.end(); i++)
+ for (std::deque<command_t*>::iterator i = cmdlist.begin(); i != cmdlist.end(); i++)
{
- if (!strcmp(i->source,source))
+ command_t* x = (command_t*)*i;
+ if (x->source == std::string(source))
{
- log(DEBUG,"removecommands(%s) Removing dependent command: %s",i->source,i->command);
+ log(DEBUG,"removecommands(%s) Removing dependent command: %s",x->source.c_str(),x->command.c_str());
cmdlist.erase(i);
go_again = true;
break;
@@ -697,19 +684,11 @@ void CommandParser::ProcessBuffer(const char* cmdbuf,userrec *user)
}
}
-bool CommandParser::CreateCommand(char* cmd, handlerfunc f, char flags, int minparams,char* source)
+bool CommandParser::CreateCommand(command_t *f)
{
- 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);
+ cmdlist.push_back(f);
+ log(DEBUG,"Added command %s (%lu parameters)",f->command.c_str(),(unsigned long)f->min_params);
return true;
}
@@ -720,58 +699,58 @@ CommandParser::CommandParser()
void CommandParser::SetupCommandTable()
{
- this->CreateCommand("USER",handle_user,0,4,"<core>");
- this->CreateCommand("NICK",handle_nick,0,1,"<core>");
- this->CreateCommand("QUIT",handle_quit,0,0,"<core>");
- this->CreateCommand("VERSION",handle_version,0,0,"<core>");
- this->CreateCommand("PING",handle_ping,0,1,"<core>");
- this->CreateCommand("PONG",handle_pong,0,1,"<core>");
- this->CreateCommand("ADMIN",handle_admin,0,0,"<core>");
- this->CreateCommand("PRIVMSG",handle_privmsg,0,2,"<core>");
- this->CreateCommand("INFO",handle_info,0,0,"<core>");
- this->CreateCommand("TIME",handle_time,0,0,"<core>");
- this->CreateCommand("WHOIS",handle_whois,0,1,"<core>");
- this->CreateCommand("WALLOPS",handle_wallops,'o',1,"<core>");
- this->CreateCommand("NOTICE",handle_notice,0,2,"<core>");
- this->CreateCommand("JOIN",handle_join,0,1,"<core>");
- this->CreateCommand("NAMES",handle_names,0,0,"<core>");
- this->CreateCommand("PART",handle_part,0,1,"<core>");
- this->CreateCommand("KICK",handle_kick,0,2,"<core>");
- this->CreateCommand("MODE",handle_mode,0,1,"<core>");
- this->CreateCommand("TOPIC",handle_topic,0,1,"<core>");
- this->CreateCommand("WHO",handle_who,0,1,"<core>");
- this->CreateCommand("MOTD",handle_motd,0,0,"<core>");
- this->CreateCommand("RULES",handle_rules,0,0,"<core>");
- this->CreateCommand("OPER",handle_oper,0,2,"<core>");
- this->CreateCommand("LIST",handle_list,0,0,"<core>");
- this->CreateCommand("DIE",handle_die,'o',1,"<core>");
- this->CreateCommand("RESTART",handle_restart,'o',1,"<core>");
- this->CreateCommand("KILL",handle_kill,'o',2,"<core>");
- this->CreateCommand("REHASH",handle_rehash,'o',0,"<core>");
- this->CreateCommand("LUSERS",handle_lusers,0,0,"<core>");
- this->CreateCommand("STATS",handle_stats,0,1,"<core>");
- this->CreateCommand("USERHOST",handle_userhost,0,1,"<core>");
- this->CreateCommand("AWAY",handle_away,0,0,"<core>");
- this->CreateCommand("ISON",handle_ison,0,0,"<core>");
- this->CreateCommand("SUMMON",handle_summon,0,0,"<core>");
- this->CreateCommand("USERS",handle_users,0,0,"<core>");
- this->CreateCommand("INVITE",handle_invite,0,0,"<core>");
- this->CreateCommand("PASS",handle_pass,0,1,"<core>");
- this->CreateCommand("TRACE",handle_trace,'o',0,"<core>");
- this->CreateCommand("WHOWAS",handle_whowas,0,1,"<core>");
- this->CreateCommand("CONNECT",handle_connect,'o',1,"<core>");
- this->CreateCommand("SQUIT",handle_squit,'o',0,"<core>");
- this->CreateCommand("MODULES",handle_modules,0,0,"<core>");
- this->CreateCommand("LINKS",handle_links,0,0,"<core>");
- this->CreateCommand("MAP",handle_map,0,0,"<core>");
- this->CreateCommand("KLINE",handle_kline,'o',1,"<core>");
- this->CreateCommand("GLINE",handle_gline,'o',1,"<core>");
- this->CreateCommand("ZLINE",handle_zline,'o',1,"<core>");
- this->CreateCommand("QLINE",handle_qline,'o',1,"<core>");
- this->CreateCommand("ELINE",handle_eline,'o',1,"<core>");
- this->CreateCommand("LOADMODULE",handle_loadmodule,'o',1,"<core>");
- this->CreateCommand("UNLOADMODULE",handle_unloadmodule,'o',1,"<core>");
- this->CreateCommand("SERVER",handle_server,0,0,"<core>");
- this->CreateCommand("COMMANDS",handle_commands,0,0,"<core>");
+ this->CreateCommand(new cmd_user);
+ this->CreateCommand(new cmd_nick);
+ this->CreateCommand(new cmd_quit);
+ this->CreateCommand(new cmd_version);
+ this->CreateCommand(new cmd_ping);
+ this->CreateCommand(new cmd_pong);
+ this->CreateCommand(new cmd_admin);
+ this->CreateCommand(new cmd_privmsg);
+ this->CreateCommand(new cmd_info);
+ this->CreateCommand(new cmd_time);
+ this->CreateCommand(new cmd_whois);
+ this->CreateCommand(new cmd_wallops);
+ this->CreateCommand(new cmd_notice);
+ this->CreateCommand(new cmd_join);
+ this->CreateCommand(new cmd_names);
+ this->CreateCommand(new cmd_part);
+ this->CreateCommand(new cmd_kick);
+ this->CreateCommand(new cmd_mode);
+ this->CreateCommand(new cmd_topic);
+ this->CreateCommand(new cmd_who);
+ this->CreateCommand(new cmd_motd);
+ this->CreateCommand(new cmd_rules);
+ this->CreateCommand(new cmd_oper);
+ this->CreateCommand(new cmd_list);
+ this->CreateCommand(new cmd_die);
+ this->CreateCommand(new cmd_restart);
+ this->CreateCommand(new cmd_kill);
+ this->CreateCommand(new cmd_rehash);
+ this->CreateCommand(new cmd_lusers);
+ this->CreateCommand(new cmd_stats);
+ this->CreateCommand(new cmd_userhost);
+ this->CreateCommand(new cmd_away);
+ this->CreateCommand(new cmd_ison);
+ this->CreateCommand(new cmd_summon);
+ this->CreateCommand(new cmd_users);
+ this->CreateCommand(new cmd_invite);
+ this->CreateCommand(new cmd_pass);
+ this->CreateCommand(new cmd_trace);
+ this->CreateCommand(new cmd_whowas);
+ this->CreateCommand(new cmd_connect);
+ this->CreateCommand(new cmd_squit);
+ this->CreateCommand(new cmd_modules);
+ this->CreateCommand(new cmd_links);
+ this->CreateCommand(new cmd_map);
+ this->CreateCommand(new cmd_kline);
+ this->CreateCommand(new cmd_gline);
+ this->CreateCommand(new cmd_zline);
+ this->CreateCommand(new cmd_qline);
+ this->CreateCommand(new cmd_eline);
+ this->CreateCommand(new cmd_loadmodule);
+ this->CreateCommand(new cmd_unloadmodule);
+ this->CreateCommand(new cmd_server);
+ this->CreateCommand(new cmd_commands);
}
diff --git a/src/commands.cpp b/src/commands.cpp
index e6c578b84..ccdb40858 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -97,683 +97,6 @@ char* CleanFilename(char* name)
return (p != name ? ++p : p);
}
-void handle_join(char **parameters, int pcnt, userrec *user)
-{
- chanrec* Ptr;
-
- if (ServerInstance->Parser->LoopCall(handle_join,parameters,pcnt,user,0,0,1))
- return;
- if (parameters[0][0] == '#')
- {
- Ptr = add_channel(user,parameters[0],parameters[1],false);
- }
-}
-
-
-void handle_part(char **parameters, int pcnt, userrec *user)
-{
- if (pcnt > 1)
- {
- if (ServerInstance->Parser->LoopCall(handle_part,parameters,pcnt,user,0,pcnt-2,0))
- return;
- del_channel(user,parameters[0],parameters[1],false);
- }
- else
- {
- if (ServerInstance->Parser->LoopCall(handle_part,parameters,pcnt,user,0,pcnt-1,0))
- return;
- del_channel(user,parameters[0],NULL,false);
- }
-}
-
-void handle_commands(char **parameters, int pcnt, userrec *user)
-{
- for (unsigned int i = 0; i < ServerInstance->Parser->cmdlist.size(); i++)
- {
- WriteServ(user->fd,"902 %s :%s %s %d",user->nick,ServerInstance->Parser->cmdlist[i].command,ServerInstance->Parser->cmdlist[i].source,ServerInstance->Parser->cmdlist[i].min_params);
- }
- WriteServ(user->fd,"903 %s :End of COMMANDS list",user->nick);
-}
-
-void handle_kick(char **parameters, int pcnt, userrec *user)
-{
- chanrec* Ptr = FindChan(parameters[0]);
- userrec* u = Find(parameters[1]);
-
- if ((!u) || (!Ptr))
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- return;
- }
-
- if ((!has_channel(user,Ptr)) && (!is_uline(user->server)))
- {
- WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, parameters[0]);
- return;
- }
-
- char reason[MAXBUF];
-
- if (pcnt > 2)
- {
- strlcpy(reason,parameters[2],MAXBUF);
- if (strlen(reason)>MAXKICK)
- {
- reason[MAXKICK-1] = '\0';
- }
-
- kick_channel(user,u,Ptr,reason);
- }
- else
- {
- strlcpy(reason,user->nick,MAXBUF);
- kick_channel(user,u,Ptr,reason);
- }
-
-}
-
-void handle_loadmodule(char **parameters, int pcnt, userrec *user)
-{
- if (ServerInstance->LoadModule(parameters[0]))
- {
- WriteOpers("*** NEW MODULE: %s",parameters[0]);
- WriteServ(user->fd,"975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
- }
- else
- {
- WriteServ(user->fd,"974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
- }
-}
-
-void handle_unloadmodule(char **parameters, int pcnt, userrec *user)
-{
- if (ServerInstance->UnloadModule(parameters[0]))
- {
- WriteOpers("*** MODULE UNLOADED: %s",parameters[0]);
- WriteServ(user->fd,"973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
- }
- else
- {
- WriteServ(user->fd,"972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
- }
-}
-
-void handle_die(char **parameters, int pcnt, userrec *user)
-{
- log(DEBUG,"die: %s",user->nick);
- if (!strcmp(parameters[0],Config->diepass))
- {
- WriteOpers("*** DIE command from %s!%s@%s, terminating...",user->nick,user->ident,user->host);
- sleep(Config->DieDelay);
- Exit(ERROR);
- }
- else
- {
- WriteOpers("*** Failed DIE Command from %s!%s@%s.",user->nick,user->ident,user->host);
- }
-}
-
-void handle_restart(char **parameters, int pcnt, userrec *user)
-{
- char *argv[32];
- log(DEFAULT,"Restart: %s",user->nick);
- if (!strcmp(parameters[0],Config->restartpass))
- {
- WriteOpers("*** RESTART command from %s!%s@%s, restarting server.",user->nick,user->ident,user->host);
-
- argv[0] = Config->MyExecutable;
- argv[1] = "-wait";
- if (Config->nofork)
- {
- argv[2] = "-nofork";
- }
- else
- {
- argv[2] = NULL;
- }
- argv[3] = NULL;
-
- // close ALL file descriptors
- send_error("Server restarting.");
- sleep(1);
- for (int i = 0; i < 65536; i++)
- {
- shutdown(i,2);
- close(i);
- }
- sleep(2);
-
- execv(Config->MyExecutable,argv);
-
- exit(0);
- }
- else
- {
- WriteOpers("*** Failed RESTART Command from %s!%s@%s.",user->nick,user->ident,user->host);
- }
-}
-
-void handle_kill(char **parameters, int pcnt, userrec *user)
-{
- userrec *u = Find(parameters[0]);
- char killreason[MAXBUF];
-
- log(DEBUG,"kill: %s %s",parameters[0],parameters[1]);
- if (u)
- {
- log(DEBUG,"into kill mechanism");
- int MOD_RESULT = 0;
- FOREACH_RESULT(OnKill(user,u,parameters[1]));
- if (MOD_RESULT) {
- log(DEBUG,"A module prevented the kill with result %d",MOD_RESULT);
- return;
- }
-
- if (u->fd < 0)
- {
- // remote kill
- WriteOpers("*** Remote kill by %s: %s!%s@%s (%s)",user->nick,u->nick,u->ident,u->host,parameters[1]);
- snprintf(killreason,MAXBUF,"[%s] Killed (%s (%s))",Config->ServerName,user->nick,parameters[1]);
- WriteCommonExcept(u,"QUIT :%s",killreason);
-
- FOREACH_MOD OnRemoteKill(user,u,killreason);
-
- user_hash::iterator iter = clientlist.find(u->nick);
- if (iter != clientlist.end())
- {
- log(DEBUG,"deleting user hash value %d",iter->second);
- clientlist.erase(iter);
- }
- if (u->registered == 7)
- {
- purge_empty_chans(u);
- }
- if (u->fd > -1)
- fd_ref_table[u->fd] = NULL;
- delete u;
- }
- else
- {
- // local kill
- log(DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, Config->ServerName,user->dhost,user->nick,parameters[1]);
- WriteTo(user, u, "KILL %s :%s!%s!%s (%s)", u->nick, Config->ServerName,user->dhost,user->nick,parameters[1]);
- WriteOpers("*** Local Kill by %s: %s!%s@%s (%s)",user->nick,u->nick,u->ident,u->host,parameters[1]);
- snprintf(killreason,MAXBUF,"Killed (%s (%s))",user->nick,parameters[1]);
- kill_link(u,killreason);
- }
- }
- else
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
-}
-
-void handle_summon(char **parameters, int pcnt, userrec *user)
-{
- WriteServ(user->fd,"445 %s :SUMMON has been disabled (depreciated command)",user->nick);
-}
-
-void handle_users(char **parameters, int pcnt, userrec *user)
-{
- WriteServ(user->fd,"445 %s :USERS has been disabled (depreciated command)",user->nick);
-}
-
-void handle_pass(char **parameters, int pcnt, userrec *user)
-{
- // Check to make sure they havnt registered -- Fix by FCS
- if (user->registered == 7)
- {
- WriteServ(user->fd,"462 %s :You may not reregister",user->nick);
- return;
- }
- strlcpy(user->password,parameters[0],MAXBUF);
- if (!strcasecmp(parameters[0],Passwd(user)))
- {
- user->haspassed = true;
- }
-}
-
-void handle_invite(char **parameters, int pcnt, userrec *user)
-{
- if (pcnt == 2)
- {
- userrec* u = Find(parameters[0]);
- chanrec* c = FindChan(parameters[1]);
-
- if ((!c) || (!u))
- {
- if (!c)
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[1]);
- }
- else
- {
- if (c->binarymodes & CM_INVITEONLY)
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
- }
-
- return;
- }
-
- if (c->binarymodes & CM_INVITEONLY)
- {
- if (cstatus(user,c) < STATUS_HOP)
- {
- WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
- return;
- }
- }
- if (has_channel(u,c))
- {
- WriteServ(user->fd,"443 %s %s %s :Is already on channel %s",user->nick,u->nick,c->name,c->name);
- return;
- }
- if (!has_channel(user,c))
- {
- WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, c->name);
- return;
- }
-
- int MOD_RESULT = 0;
- FOREACH_RESULT(OnUserPreInvite(user,u,c));
- if (MOD_RESULT == 1) {
- return;
- }
-
- irc::string xname(c->name);
- u->InviteTo(xname);
- WriteFrom(u->fd,user,"INVITE %s :%s",u->nick,c->name);
- WriteServ(user->fd,"341 %s %s %s",user->nick,u->nick,c->name);
- FOREACH_MOD OnUserInvite(user,u,c);
- }
- else
- {
- // pinched from ircu - invite with not enough parameters shows channels
- // youve been invited to but haven't joined yet.
- InvitedList* il = user->GetInviteList();
- for (InvitedList::iterator i = il->begin(); i != il->end(); i++)
- {
- WriteServ(user->fd,"346 %s :%s",user->nick,i->channel.c_str());
- }
- WriteServ(user->fd,"347 %s :End of INVITE list",user->nick);
- }
-}
-
-void handle_topic(char **parameters, int pcnt, userrec *user)
-{
- chanrec* Ptr;
-
- if (pcnt == 1)
- {
- if (strlen(parameters[0]) <= CHANMAX)
- {
- Ptr = FindChan(parameters[0]);
- if (Ptr)
- {
- if (((Ptr) && (!has_channel(user,Ptr))) && (Ptr->binarymodes & CM_SECRET))
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, Ptr->name);
- return;
- }
- if (Ptr->topicset)
- {
- WriteServ(user->fd,"332 %s %s :%s", user->nick, Ptr->name, Ptr->topic);
- WriteServ(user->fd,"333 %s %s %s %d", user->nick, Ptr->name, Ptr->setby, Ptr->topicset);
- }
- else
- {
- WriteServ(user->fd,"331 %s %s :No topic is set.", user->nick, Ptr->name);
- }
- }
- else
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
- }
- return;
- }
- else if (pcnt>1)
- {
- if (strlen(parameters[0]) <= CHANMAX)
- {
- Ptr = FindChan(parameters[0]);
- if (Ptr)
- {
- if ((Ptr) && (!has_channel(user,Ptr)))
- {
- WriteServ(user->fd,"442 %s %s :You're not on that channel!",user->nick, Ptr->name);
- return;
- }
- if ((Ptr->binarymodes & CM_TOPICLOCK) && (cstatus(user,Ptr)<STATUS_HOP))
- {
- WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name);
- return;
- }
-
- char topic[MAXBUF];
- strlcpy(topic,parameters[1],MAXBUF);
- if (strlen(topic)>MAXTOPIC)
- {
- topic[MAXTOPIC] = '\0';
- }
-
- if (user->fd > -1)
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(OnLocalTopicChange(user,Ptr,topic));
- if (MOD_RESULT)
- return;
- }
-
- strlcpy(Ptr->topic,topic,MAXTOPIC);
- strlcpy(Ptr->setby,user->nick,NICKMAX);
- Ptr->topicset = TIME;
- WriteChannel(Ptr,user,"TOPIC %s :%s",Ptr->name, Ptr->topic);
- if (user->fd > -1)
- {
- FOREACH_MOD OnPostLocalTopicChange(user,Ptr,topic);
- }
- }
- else
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
- }
- }
-}
-
-void handle_names(char **parameters, int pcnt, userrec *user)
-{
- chanrec* c;
-
- if (!pcnt)
- {
- WriteServ(user->fd,"366 %s * :End of /NAMES list.",user->nick);
- return;
- }
-
- if (ServerInstance->Parser->LoopCall(handle_names,parameters,pcnt,user,0,pcnt-1,0))
- return;
- c = FindChan(parameters[0]);
- if (c)
- {
- if (((c) && (!has_channel(user,c))) && (c->binarymodes & CM_SECRET))
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, c->name);
- return;
- }
- userlist(user,c);
- WriteServ(user->fd,"366 %s %s :End of /NAMES list.", user->nick, c->name);
- }
- else
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
-}
-
-void handle_privmsg(char **parameters, int pcnt, userrec *user)
-{
- userrec *dest;
- chanrec *chan;
-
- user->idle_lastmsg = TIME;
-
- if (ServerInstance->Parser->LoopCall(handle_privmsg,parameters,pcnt,user,0,pcnt-2,0))
- return;
- if (parameters[0][0] == '$')
- {
- // notice to server mask
- char* servermask = parameters[0];
- servermask++;
- if (match(Config->ServerName,servermask))
- {
- ServerPrivmsgAll("%s",parameters[1]);
- }
- return;
- }
- else if (parameters[0][0] == '#')
- {
- chan = FindChan(parameters[0]);
- if (chan)
- {
- if ((chan->binarymodes & CM_NOEXTERNAL) && (!has_channel(user,chan)))
- {
- WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name);
- return;
- }
- if ((chan->binarymodes & CM_MODERATED) && (cstatus(user,chan)<STATUS_VOICE))
- {
- WriteServ(user->fd,"404 %s %s :Cannot send to channel (+m)", user->nick, chan->name);
- return;
- }
-
- int MOD_RESULT = 0;
-
- std::string temp = parameters[1];
- FOREACH_RESULT(OnUserPreMessage(user,chan,TYPE_CHANNEL,temp));
- if (MOD_RESULT) {
- return;
- }
- parameters[1] = (char*)temp.c_str();
-
- if (temp == "")
- {
- WriteServ(user->fd,"412 %s No text to send", user->nick);
- return;
- }
-
- ChanExceptSender(chan, user, "PRIVMSG %s :%s", chan->name, parameters[1]);
- FOREACH_MOD OnUserMessage(user,chan,TYPE_CHANNEL,parameters[1]);
- }
- else
- {
- /* no such nick/channel */
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
- return;
- }
-
- dest = Find(parameters[0]);
- if (dest)
- {
- if (strcmp(dest->awaymsg,""))
- {
- /* auto respond with aweh msg */
- WriteServ(user->fd,"301 %s %s :%s",user->nick,dest->nick,dest->awaymsg);
- }
-
- int MOD_RESULT = 0;
-
- std::string temp = parameters[1];
- FOREACH_RESULT(OnUserPreMessage(user,dest,TYPE_USER,temp));
- if (MOD_RESULT) {
- return;
- }
- parameters[1] = (char*)temp.c_str();
-
- if (dest->fd > -1)
- {
- // direct write, same server
- WriteTo(user, dest, "PRIVMSG %s :%s", dest->nick, parameters[1]);
- }
-
- FOREACH_MOD OnUserMessage(user,dest,TYPE_USER,parameters[1]);
- }
- else
- {
- /* no such nick/channel */
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
-}
-
-void handle_notice(char **parameters, int pcnt, userrec *user)
-{
- userrec *dest;
- chanrec *chan;
-
- user->idle_lastmsg = TIME;
-
- if (ServerInstance->Parser->LoopCall(handle_notice,parameters,pcnt,user,0,pcnt-2,0))
- return;
- if (parameters[0][0] == '$')
- {
- // notice to server mask
- char* servermask = parameters[0];
- servermask++;
- if (match(Config->ServerName,servermask))
- {
- NoticeAll(user, true, "%s",parameters[1]);
- }
- return;
- }
- else if (parameters[0][0] == '#')
- {
- chan = FindChan(parameters[0]);
- if (chan)
- {
- if ((chan->binarymodes & CM_NOEXTERNAL) && (!has_channel(user,chan)))
- {
- WriteServ(user->fd,"404 %s %s :Cannot send to channel (no external messages)", user->nick, chan->name);
- return;
- }
- if ((chan->binarymodes & CM_MODERATED) && (cstatus(user,chan)<STATUS_VOICE))
- {
- WriteServ(user->fd,"404 %s %s :Cannot send to channel (+m)", user->nick, chan->name);
- return;
- }
-
- int MOD_RESULT = 0;
-
- std::string temp = parameters[1];
- FOREACH_RESULT(OnUserPreNotice(user,chan,TYPE_CHANNEL,temp));
- if (MOD_RESULT) {
- return;
- }
- parameters[1] = (char*)temp.c_str();
-
- if (temp == "")
- {
- WriteServ(user->fd,"412 %s No text to send", user->nick);
- return;
- }
-
- ChanExceptSender(chan, user, "NOTICE %s :%s", chan->name, parameters[1]);
-
- FOREACH_MOD OnUserNotice(user,chan,TYPE_CHANNEL,parameters[1]);
- }
- else
- {
- /* no such nick/channel */
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
- return;
- }
-
- dest = Find(parameters[0]);
- if (dest)
- {
- int MOD_RESULT = 0;
-
- std::string temp = parameters[1];
- FOREACH_RESULT(OnUserPreNotice(user,dest,TYPE_USER,temp));
- if (MOD_RESULT) {
- return;
- }
- parameters[1] = (char*)temp.c_str();
-
- if (dest->fd > -1)
- {
- // direct write, same server
- WriteTo(user, dest, "NOTICE %s :%s", dest->nick, parameters[1]);
- }
-
- FOREACH_MOD OnUserNotice(user,dest,TYPE_USER,parameters[1]);
- }
- else
- {
- /* no such nick/channel */
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
-}
-
-void handle_server(char **parameters, int pcnt, userrec *user)
-{
- WriteServ(user->fd,"666 %s :You cannot identify as a server, you are a USER. IRC Operators informed.",user->nick);
- WriteOpers("*** WARNING: %s attempted to issue a SERVER command and is registered as a user!",user->nick);
-}
-
-void handle_info(char **parameters, int pcnt, userrec *user)
-{
- WriteServ(user->fd,"371 %s :. o O (The Inspire Internet Relay Chat Server) O o .",user->nick);
- WriteServ(user->fd,"371 %s : ",user->nick);
- WriteServ(user->fd,"371 %s :Core developers: Craig Edwards (Brain)",user->nick);
- WriteServ(user->fd,"371 %s : Craig McLure",user->nick);
- WriteServ(user->fd,"371 %s : ",user->nick);
- WriteServ(user->fd,"371 %s :Contributors: typobox43",user->nick);
- WriteServ(user->fd,"371 %s : w00t",user->nick);
- WriteServ(user->fd,"371 %s : Om",user->nick);
- WriteServ(user->fd,"371 %s : Jazza",user->nick);
- WriteServ(user->fd,"371 %s : ",user->nick);
- WriteServ(user->fd,"371 %s :Testers: CC",user->nick);
- WriteServ(user->fd,"371 %s : Om",user->nick);
- WriteServ(user->fd,"371 %s : Piggles",user->nick);
- WriteServ(user->fd,"371 %s : Foamy",user->nick);
- WriteServ(user->fd,"371 %s : Hart",user->nick);
- WriteServ(user->fd,"371 %s : RageD",user->nick);
- WriteServ(user->fd,"371 %s : [ed]",user->nick);
- WriteServ(user->fd,"371 %s : Azhrarn",user->nick);
- WriteServ(user->fd,"371 %s : nenolod",user->nick);
- WriteServ(user->fd,"371 %s : luigiman",user->nick);
- WriteServ(user->fd,"371 %s : Chu",user->nick);
- WriteServ(user->fd,"371 %s : aquanight",user->nick);
- WriteServ(user->fd,"371 %s : xptek",user->nick);
- WriteServ(user->fd,"371 %s : Grantlinks",user->nick);
- WriteServ(user->fd,"371 %s : Rob",user->nick);
- WriteServ(user->fd,"371 %s : angelic",user->nick);
- WriteServ(user->fd,"371 %s : Jason",user->nick);
- WriteServ(user->fd,"371 %s : ThaPrince",user->nick);
- WriteServ(user->fd,"371 %s : ",user->nick);
- WriteServ(user->fd,"371 %s :Thanks to irc-junkie and searchirc",user->nick);
- WriteServ(user->fd,"371 %s :for the nice comments and the help",user->nick);
- WriteServ(user->fd,"371 %s :you gave us in attracting users to",user->nick);
- WriteServ(user->fd,"371 %s :this software.",user->nick);
- WriteServ(user->fd,"371 %s : ",user->nick);
- WriteServ(user->fd,"371 %s :Best experienced with: An IRC client.",user->nick);
- FOREACH_MOD OnInfo(user);
- WriteServ(user->fd,"374 %s :End of /INFO list",user->nick);
-}
-
-void handle_time(char **parameters, int pcnt, userrec *user)
-{
- time_t rawtime;
- struct tm * timeinfo;
-
- time(&rawtime);
- timeinfo = localtime(&rawtime);
- WriteServ(user->fd,"391 %s %s :%s",user->nick,Config->ServerName,asctime(timeinfo));
-
-}
-
-void handle_whois(char **parameters, int pcnt, userrec *user)
-{
- userrec *dest;
- if (ServerInstance->Parser->LoopCall(handle_whois,parameters,pcnt,user,0,pcnt-1,0))
- return;
- dest = Find(parameters[0]);
- if (dest)
- {
- do_whois(user,dest,0,0,parameters[0]);
- }
- else
- {
- /* no such nick/channel */
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, parameters[0]);
- }
-}
-
void split_chlist(userrec* user, userrec* dest, std::string &cl)
{
std::stringstream channels(cl);
@@ -856,674 +179,6 @@ void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long i
}
}
-void handle_quit(char **parameters, int pcnt, userrec *user)
-{
- user_hash::iterator iter = clientlist.find(user->nick);
- char* reason;
-
- if (user->registered == 7)
- {
- /* theres more to do here, but for now just close the socket */
- if (pcnt == 1)
- {
- if (parameters[0][0] == ':')
- {
- *parameters[0]++;
- }
- reason = parameters[0];
-
- if (strlen(reason)>MAXQUIT)
- {
- reason[MAXQUIT-1] = '\0';
- }
-
- /* We should only prefix the quit for a local user. Remote users have
- * already been prefixed, where neccessary, by the upstream server.
- */
- if (user->fd > -1)
- {
- Write(user->fd,"ERROR :Closing link (%s@%s) [%s%s]",user->ident,user->host,Config->PrefixQuit,parameters[0]);
- WriteOpers("*** Client exiting: %s!%s@%s [%s%s]",user->nick,user->ident,user->host,Config->PrefixQuit,parameters[0]);
- WriteCommonExcept(user,"QUIT :%s%s",Config->PrefixQuit,parameters[0]);
- }
- else
- {
- WriteOpers("*** Client exiting at %s: %s!%s@%s [%s]",user->server,user->nick,user->ident,user->host,parameters[0]);
- WriteCommonExcept(user,"QUIT :%s",parameters[0]);
- }
- FOREACH_MOD OnUserQuit(user,std::string(Config->PrefixQuit)+std::string(parameters[0]));
-
- }
- else
- {
- Write(user->fd,"ERROR :Closing link (%s@%s) [QUIT]",user->ident,user->host);
- WriteOpers("*** Client exiting: %s!%s@%s [Client exited]",user->nick,user->ident,user->host);
- WriteCommonExcept(user,"QUIT :Client exited");
- FOREACH_MOD OnUserQuit(user,"Client exited");
-
- }
- AddWhoWas(user);
- }
-
- FOREACH_MOD OnUserDisconnect(user);
-
- /* push the socket on a stack of sockets due to be closed at the next opportunity */
- if (user->fd > -1)
- {
- ServerInstance->SE->DelFd(user->fd);
- if (find(local_users.begin(),local_users.end(),user) != local_users.end())
- {
- log(DEBUG,"Delete local user");
- local_users.erase(find(local_users.begin(),local_users.end(),user));
- }
- user->CloseSocket();
- }
-
- if (iter != clientlist.end())
- {
- clientlist.erase(iter);
- }
-
- if (user->registered == 7) {
- purge_empty_chans(user);
- }
- if (user->fd > -1)
- fd_ref_table[user->fd] = NULL;
- delete user;
-}
-
-void handle_who(char **parameters, int pcnt, userrec *user)
-{
- chanrec* Ptr = NULL;
- char tmp[10];
-
- /* theres more to do here, but for now just close the socket */
- if (pcnt == 1)
- {
- if ((!strcmp(parameters[0],"0")) || (!strcmp(parameters[0],"*")))
- {
- if ((user->chans.size()) && (user->chans[0].channel))
- {
- int n_list = 0;
- for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
- {
- Ptr = i->second->chans[0].channel;
- // suggested by phidjit and FCS
- if ((!common_channels(user,i->second)) && (isnick(i->second->nick)))
- {
- // Bug Fix #29
- strcpy(tmp, "");
- if (strcmp(i->second->awaymsg, "")) {
- strlcat(tmp, "G", 9);
- } else {
- strlcat(tmp, "H", 9);
- }
- if (strchr(i->second->modes,'o')) { strlcat(tmp, "*", 9); }
- WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, Ptr ? Ptr->name : "*", i->second->ident, i->second->dhost, i->second->server, i->second->nick, tmp, i->second->fullname);
- n_list++;
- if (n_list > Config->MaxWhoResults)
- {
- WriteServ(user->fd,"523 %s WHO :Command aborted: More results than configured limit",user->nick);
- break;
- }
- }
- }
- }
- if (Ptr)
- {
- WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick , parameters[0]);
- }
- else
- {
- WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
- }
- return;
- }
- if (parameters[0][0] == '#')
- {
- Ptr = FindChan(parameters[0]);
- if (Ptr)
- {
- int n_list = 0;
- for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++)
- {
- if ((has_channel(i->second,Ptr)) && (isnick(i->second->nick)))
- {
- // Fix Bug #29 - Part 2..
- strcpy(tmp, "");
- if (strcmp(i->second->awaymsg, "")) {
- strlcat(tmp, "G", 9);
- } else {
- strlcat(tmp, "H", 9);
- }
- if (strchr(i->second->modes,'o')) { strlcat(tmp, "*", 9); }
- strlcat(tmp, cmode(i->second, Ptr),5);
- WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, Ptr->name, i->second->ident, i->second->dhost, i->second->server, i->second->nick, tmp, i->second->fullname);
- n_list++;
- if (n_list > Config->MaxWhoResults)
- {
- WriteServ(user->fd,"523 %s WHO :Command aborted: More results than configured limit",user->nick);
- break;
- }
-
- }
- }
- WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
- }
- else
- {
- WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
- }
- }
- else
- {
- userrec* u = Find(parameters[0]);
- if (u)
- {
- // Bug Fix #29 -- Part 29..
- strcpy(tmp, "");
- if (strcmp(u->awaymsg, "")) {
- strlcat(tmp, "G" ,9);
- } else {
- strlcat(tmp, "H" ,9);
- }
- if (strchr(u->modes,'o')) { strlcat(tmp, "*" ,9); }
- WriteServ(user->fd,"352 %s %s %s %s %s %s %s :0 %s",user->nick, u->chans.size() ? u->chans[0].channel->name
- : "*", u->ident, u->dhost, u->server, u->nick, tmp, u->fullname);
- }
- WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
- }
- }
- if (pcnt == 2)
- {
- if ((!strcmp(parameters[0],"0")) || (!strcmp(parameters[0],"*")) && (!strcmp(parameters[1],"o")))
- {
- for (std::vector<userrec*>::iterator i = all_opers.begin(); i != all_opers.end(); i++)
- {
- // If i were a rich man.. I wouldn't need to me making these bugfixes..
- // But i'm a poor bastard with nothing better to do.
- userrec* oper = *i;
- strcpy(tmp, "");
- if (strcmp(oper->awaymsg, "")) {
- strlcat(tmp, "G" ,9);
- } else {
- strlcat(tmp, "H" ,9);
- }
- WriteServ(user->fd,"352 %s %s %s %s %s %s %s* :0 %s", user->nick, oper->chans.size() ? oper->chans[0].channel->name
- : "*", oper->ident, oper->dhost, oper->server, oper->nick, tmp, oper->fullname);
- }
- WriteServ(user->fd,"315 %s %s :End of /WHO list.",user->nick, parameters[0]);
- return;
- }
- }
-}
-
-void handle_wallops(char **parameters, int pcnt, userrec *user)
-{
- WriteWallOps(user,false,"%s",parameters[0]);
- FOREACH_MOD OnWallops(user,parameters[0]);
-}
-
-void handle_list(char **parameters, int pcnt, userrec *user)
-{
- WriteServ(user->fd,"321 %s Channel :Users Name",user->nick);
- for (chan_hash::const_iterator i = chanlist.begin(); i != chanlist.end(); i++)
- {
- // if the channel is not private/secret, OR the user is on the channel anyway
- if (((!(i->second->binarymodes & CM_PRIVATE)) && (!(i->second->binarymodes & CM_SECRET))) || (has_channel(user,i->second)))
- {
- WriteServ(user->fd,"322 %s %s %d :[+%s] %s",user->nick,i->second->name,usercount_i(i->second),chanmodes(i->second),i->second->topic);
- }
- }
- WriteServ(user->fd,"323 %s :End of channel list.",user->nick);
-}
-
-
-void handle_rehash(char **parameters, int pcnt, userrec *user)
-{
- WriteServ(user->fd,"382 %s %s :Rehashing",user->nick,CleanFilename(CONFIG_FILE));
- std::string parameter = "";
- if (pcnt)
- {
- parameter = parameters[0];
- }
- else
- {
- WriteOpers("%s is rehashing config file %s",user->nick,CleanFilename(CONFIG_FILE));
- Config->Read(false,user);
- }
- FOREACH_MOD OnRehash(parameter);
-}
-
-void handle_lusers(char **parameters, int pcnt, userrec *user)
-{
- // this lusers command shows one server at all times because
- // a protocol module must override it to show those stats.
- WriteServ(user->fd,"251 %s :There are %d users and %d invisible on 1 server",user->nick,usercnt()-usercount_invisible(),usercount_invisible());
- WriteServ(user->fd,"252 %s %d :operator(s) online",user->nick,usercount_opers());
- WriteServ(user->fd,"253 %s %d :unknown connections",user->nick,usercount_unknown());
- WriteServ(user->fd,"254 %s %d :channels formed",user->nick,chancount());
- WriteServ(user->fd,"254 %s :I have %d clients and 0 servers",user->nick,local_count());
-}
-
-void handle_admin(char **parameters, int pcnt, userrec *user)
-{
- WriteServ(user->fd,"256 %s :Administrative info for %s",user->nick,Config->ServerName);
- WriteServ(user->fd,"257 %s :Name - %s",user->nick,Config->AdminName);
- WriteServ(user->fd,"258 %s :Nickname - %s",user->nick,Config->AdminNick);
- WriteServ(user->fd,"258 %s :E-Mail - %s",user->nick,Config->AdminEmail);
-}
-
-void handle_ping(char **parameters, int pcnt, userrec *user)
-{
- WriteServ(user->fd,"PONG %s :%s",Config->ServerName,parameters[0]);
-}
-
-void handle_pong(char **parameters, int pcnt, userrec *user)
-{
- // set the user as alive so they survive to next ping
- user->lastping = 1;
-}
-
-void handle_motd(char **parameters, int pcnt, userrec *user)
-{
- ShowMOTD(user);
-}
-
-void handle_rules(char **parameters, int pcnt, userrec *user)
-{
- ShowRULES(user);
-}
-
-void handle_user(char **parameters, int pcnt, userrec *user)
-{
- if (user->registered < 3)
- {
- if (isident(parameters[0]) == 0) {
- // This kinda Sucks, According to the RFC thou, its either this,
- // or "You have already registered" :p -- Craig
- WriteServ(user->fd,"461 %s USER :Not enough parameters",user->nick);
- }
- else {
- /* We're not checking ident, but I'm not sure I like the idea of '~' prefixing.. */
- /* XXX - Should this IDENTMAX + 1 be IDENTMAX - 1? Ok, users.h has it defined as
- * char ident[IDENTMAX+2]; - WTF?
- */
- snprintf(user->ident, IDENTMAX+1, "~%s", parameters[0]);
- strlcpy(user->fullname,parameters[3],MAXGECOS);
- user->registered = (user->registered | 1);
- }
- }
- else
- {
- WriteServ(user->fd,"462 %s :You may not reregister",user->nick);
- return;
- }
- /* parameters 2 and 3 are local and remote hosts, ignored when sent by client connection */
- if (user->registered == 3)
- {
- /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
- FOREACH_MOD OnUserRegister(user);
- ConnectUser(user);
- }
-}
-
-void handle_userhost(char **parameters, int pcnt, userrec *user)
-{
- char Return[MAXBUF],junk[MAXBUF];
- snprintf(Return,MAXBUF,"302 %s :",user->nick);
- for (int i = 0; i < pcnt; i++)
- {
- userrec *u = Find(parameters[i]);
- if (u)
- {
- if (strchr(u->modes,'o'))
- {
- snprintf(junk,MAXBUF,"%s*=+%s@%s ",u->nick,u->ident,u->host);
- strlcat(Return,junk,MAXBUF);
- }
- else
- {
- snprintf(junk,MAXBUF,"%s=+%s@%s ",u->nick,u->ident,u->host);
- strlcat(Return,junk,MAXBUF);
- }
- }
- }
- WriteServ(user->fd,Return);
-}
-
-
-void handle_ison(char **parameters, int pcnt, userrec *user)
-{
- char Return[MAXBUF];
- snprintf(Return,MAXBUF,"303 %s :",user->nick);
- for (int i = 0; i < pcnt; i++)
- {
- userrec *u = Find(parameters[i]);
- if (u)
- {
- strlcat(Return,u->nick,MAXBUF);
- strlcat(Return," ",MAXBUF);
- }
- }
- WriteServ(user->fd,Return);
-}
-
-
-void handle_away(char **parameters, int pcnt, userrec *user)
-{
- if (pcnt)
- {
- strlcpy(user->awaymsg,parameters[0],MAXAWAY);
- WriteServ(user->fd,"306 %s :You have been marked as being away",user->nick);
- }
- else
- {
- strlcpy(user->awaymsg,"",MAXAWAY);
- WriteServ(user->fd,"305 %s :You are no longer marked as being away",user->nick);
- }
-}
-
-void handle_whowas(char **parameters, int pcnt, userrec* user)
-{
- whowas_hash::iterator i = whowas.find(parameters[0]);
-
- if (i == whowas.end())
- {
- WriteServ(user->fd,"406 %s %s :There was no such nickname",user->nick,parameters[0]);
- WriteServ(user->fd,"369 %s %s :End of WHOWAS",user->nick,parameters[0]);
- }
- else
- {
- time_t rawtime = i->second->signon;
- tm *timeinfo;
- char b[MAXBUF];
-
- timeinfo = localtime(&rawtime);
- strlcpy(b,asctime(timeinfo),MAXBUF);
- b[strlen(b)-1] = '\0';
-
- WriteServ(user->fd,"314 %s %s %s %s * :%s",user->nick,i->second->nick,i->second->ident,i->second->dhost,i->second->fullname);
- WriteServ(user->fd,"312 %s %s %s :%s",user->nick,i->second->nick,i->second->server,b);
- WriteServ(user->fd,"369 %s %s :End of WHOWAS",user->nick,parameters[0]);
- }
-
-}
-
-void handle_trace(char **parameters, int pcnt, userrec *user)
-{
- for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++)
- {
- if (i->second)
- {
- if (isnick(i->second->nick))
- {
- if (strchr(i->second->modes,'o'))
- {
- WriteServ(user->fd,"205 %s :Oper 0 %s",user->nick,i->second->nick);
- }
- else
- {
- WriteServ(user->fd,"204 %s :User 0 %s",user->nick,i->second->nick);
- }
- }
- else
- {
- WriteServ(user->fd,"203 %s :???? 0 [%s]",user->nick,i->second->host);
- }
- }
- }
-}
-
-void handle_modules(char **parameters, int pcnt, userrec *user)
-{
- for (unsigned int i = 0; i < Config->module_names.size(); i++)
- {
- Version V = modules[i]->GetVersion();
- char modulename[MAXBUF];
- char flagstate[MAXBUF];
- strcpy(flagstate,"");
- if (V.Flags & VF_STATIC)
- strlcat(flagstate,", static",MAXBUF);
- if (V.Flags & VF_VENDOR)
- strlcat(flagstate,", vendor",MAXBUF);
- if (V.Flags & VF_COMMON)
- strlcat(flagstate,", common",MAXBUF);
- if (V.Flags & VF_SERVICEPROVIDER)
- strlcat(flagstate,", service provider",MAXBUF);
- if (!flagstate[0])
- strcpy(flagstate," <no flags>");
- strlcpy(modulename,Config->module_names[i].c_str(),256);
- if (strchr(user->modes,'o'))
- {
- WriteServ(user->fd,"900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,modules[i],V.Major,V.Minor,V.Revision,V.Build,CleanFilename(modulename),flagstate+2);
- }
- else
- {
- WriteServ(user->fd,"900 %s :%s",user->nick,CleanFilename(modulename));
- }
- }
- WriteServ(user->fd,"901 %s :End of MODULES list",user->nick);
-}
-
-void handle_stats(char **parameters, int pcnt, userrec *user)
-{
- if (pcnt != 1)
- {
- return;
- }
- if (strlen(parameters[0])>1)
- {
- /* make the stats query 1 character long */
- parameters[0][1] = '\0';
- }
-
-
- FOREACH_MOD OnStats(*parameters[0]);
-
- if (*parameters[0] == 'c')
- {
- /* This stats symbol must be handled by a linking module */
- }
-
- if (*parameters[0] == 'i')
- {
- int idx = 0;
- for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
- {
- WriteServ(user->fd,"215 %s I * * * %d %d %s *",user->nick,MAXCLIENTS,idx,Config->ServerName);
- idx++;
- }
- }
-
- if (*parameters[0] == 'y')
- {
- int idx = 0;
- for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
- {
- WriteServ(user->fd,"218 %s Y %d %d 0 %d %d",user->nick,idx,120,i->flood,i->registration_timeout);
- idx++;
- }
- }
-
- if (*parameters[0] == 'U')
- {
- char ulined[MAXBUF];
- for (int i = 0; i < Config->ConfValueEnum("uline",&Config->config_f); i++)
- {
- Config->ConfValue("uline","server",i,ulined,&Config->config_f);
- WriteServ(user->fd,"248 %s U %s",user->nick,ulined);
- }
- }
-
- if (*parameters[0] == 'P')
- {
- int idx = 0;
- for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++)
- {
- if (strchr(i->second->modes,'o'))
- {
- WriteServ(user->fd,"249 %s :%s (%s@%s) Idle: %d",user->nick,i->second->nick,i->second->ident,i->second->dhost,(TIME - i->second->idle_lastmsg));
- idx++;
- }
- }
- WriteServ(user->fd,"249 %s :%d OPER(s)",user->nick,idx);
- }
-
- if (*parameters[0] == 'k')
- {
- stats_k(user);
- }
-
- if (*parameters[0] == 'g')
- {
- stats_g(user);
- }
-
- if (*parameters[0] == 'q')
- {
- stats_q(user);
- }
-
- if (*parameters[0] == 'Z')
- {
- stats_z(user);
- }
-
- if (*parameters[0] == 'e')
- {
- stats_e(user);
- }
-
- /* stats m (list number of times each command has been used, plus bytecount) */
- if (*parameters[0] == 'm')
- {
- for (unsigned int i = 0; i < ServerInstance->Parser->cmdlist.size(); i++)
- {
- if (ServerInstance->Parser->cmdlist[i].handler_function)
- {
- if (ServerInstance->Parser->cmdlist[i].use_count)
- {
- /* RPL_STATSCOMMANDS */
- WriteServ(user->fd,"212 %s %s %d %d",user->nick,ServerInstance->Parser->cmdlist[i].command,ServerInstance->Parser->cmdlist[i].use_count,ServerInstance->Parser->cmdlist[i].total_bytes);
- }
- }
- }
-
- }
-
- /* stats z (debug and memory info) */
- if (*parameters[0] == 'z')
- {
- rusage R;
- WriteServ(user->fd,"249 %s :Users(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,clientlist.size(),clientlist.size()*sizeof(userrec),clientlist.bucket_count());
- WriteServ(user->fd,"249 %s :Channels(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,chanlist.size(),chanlist.size()*sizeof(chanrec),chanlist.bucket_count());
- WriteServ(user->fd,"249 %s :Commands(VECTOR) %d (%d bytes)",user->nick,ServerInstance->Parser->cmdlist.size(),ServerInstance->Parser->cmdlist.size()*sizeof(command_t));
- WriteServ(user->fd,"249 %s :MOTD(VECTOR) %d, RULES(VECTOR) %d",user->nick,Config->MOTD.size(),Config->RULES.size());
- WriteServ(user->fd,"249 %s :Modules(VECTOR) %d (%d)",user->nick,modules.size(),modules.size()*sizeof(Module));
- WriteServ(user->fd,"249 %s :ClassFactories(VECTOR) %d (%d)",user->nick,factory.size(),factory.size()*sizeof(ircd_module));
- if (!getrusage(RUSAGE_SELF,&R))
- {
- WriteServ(user->fd,"249 %s :Total allocation: %luK (0x%lx)",user->nick,R.ru_maxrss,R.ru_maxrss);
- WriteServ(user->fd,"249 %s :Signals: %lu (0x%lx)",user->nick,R.ru_nsignals,R.ru_nsignals);
- WriteServ(user->fd,"249 %s :Page faults: %lu (0x%lx)",user->nick,R.ru_majflt,R.ru_majflt);
- WriteServ(user->fd,"249 %s :Swaps: %lu (0x%lx)",user->nick,R.ru_nswap,R.ru_nswap);
- WriteServ(user->fd,"249 %s :Context Switches: %lu (0x%lx)",user->nick,R.ru_nvcsw+R.ru_nivcsw,R.ru_nvcsw+R.ru_nivcsw);
- }
- }
-
- if (*parameters[0] == 'T')
- {
- WriteServ(user->fd,"249 Brain :accepts %d refused %d",ServerInstance->stats->statsAccept,ServerInstance->stats->statsRefused);
- WriteServ(user->fd,"249 Brain :unknown commands %d",ServerInstance->stats->statsUnknown);
- WriteServ(user->fd,"249 Brain :nick collisions %d",ServerInstance->stats->statsCollisions);
- WriteServ(user->fd,"249 Brain :dns requests %d succeeded %d failed %d",ServerInstance->stats->statsDns,ServerInstance->stats->statsDnsGood,ServerInstance->stats->statsDnsBad);
- WriteServ(user->fd,"249 Brain :connections %d",ServerInstance->stats->statsConnects);
- WriteServ(user->fd,"249 Brain :bytes sent %dK recv %dK",(ServerInstance->stats->statsSent / 1024),(ServerInstance->stats->statsRecv / 1024));
- }
-
- /* stats o */
- if (*parameters[0] == 'o')
- {
- for (int i = 0; i < Config->ConfValueEnum("oper",&Config->config_f); i++)
- {
- char LoginName[MAXBUF];
- char HostName[MAXBUF];
- char OperType[MAXBUF];
- Config->ConfValue("oper","name",i,LoginName,&Config->config_f);
- Config->ConfValue("oper","host",i,HostName,&Config->config_f);
- Config->ConfValue("oper","type",i,OperType,&Config->config_f);
- WriteServ(user->fd,"243 %s O %s * %s %s 0",user->nick,HostName,LoginName,OperType);
- }
- }
-
- /* stats l (show user I/O stats) */
- if (*parameters[0] == 'l')
- {
- WriteServ(user->fd,"211 %s :server:port nick bytes_in cmds_in bytes_out cmds_out",user->nick);
- for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++)
- {
- if (isnick(i->second->nick))
- {
- WriteServ(user->fd,"211 %s :%s:%d %s %d %d %d %d",user->nick,i->second->server,i->second->port,i->second->nick,i->second->bytes_in,i->second->cmds_in,i->second->bytes_out,i->second->cmds_out);
- }
- else
- {
- WriteServ(user->fd,"211 %s :%s:%d (unknown@%d) %d %d %d %d",user->nick,i->second->server,i->second->port,i->second->fd,i->second->bytes_in,i->second->cmds_in,i->second->bytes_out,i->second->cmds_out);
- }
-
- }
- }
-
- /* stats u (show server uptime) */
- if (*parameters[0] == 'u')
- {
- time_t current_time = 0;
- current_time = TIME;
- time_t server_uptime = current_time - ServerInstance->startup_time;
- struct tm* stime;
- stime = gmtime(&server_uptime);
- /* i dont know who the hell would have an ircd running for over a year nonstop, but
- * Craig suggested this, and it seemed a good idea so in it went */
- if (stime->tm_year > 70)
- {
- WriteServ(user->fd,"242 %s :Server up %d years, %d days, %.2d:%.2d:%.2d",user->nick,(stime->tm_year-70),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
- }
- else
- {
- WriteServ(user->fd,"242 %s :Server up %d days, %.2d:%.2d:%.2d",user->nick,stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
- }
- }
-
- WriteServ(user->fd,"219 %s %s :End of /STATS report",user->nick,parameters[0]);
- WriteOpers("*** Notice: Stats '%s' requested by %s (%s@%s)",parameters[0],user->nick,user->ident,user->host);
-
-}
-
-
-void handle_connect(char **parameters, int pcnt, userrec *user)
-{
-}
-
-void handle_squit(char **parameters, int pcnt, userrec *user)
-{
-}
-
-void handle_links(char **parameters, int pcnt, userrec *user)
-{
- WriteServ(user->fd,"364 %s %s %s :0 %s",user->nick,Config->ServerName,Config->ServerName,Config->ServerDesc);
- WriteServ(user->fd,"365 %s * :End of /LINKS list.",user->nick);
-}
-
-void handle_map(char **parameters, int pcnt, userrec *user)
-{
- // as with /LUSERS this does nothing without a linking
- // module to override its behaviour and display something
- // better.
- WriteServ(user->fd,"006 %s :%s",user->nick,Config->ServerName);
- WriteServ(user->fd,"007 %s :End of /MAP",user->nick);
-}
-
bool is_uline(const char* server)
{
char ServName[MAXBUF];
@@ -1543,6 +198,7 @@ bool is_uline(const char* server)
}
return false;
}
+
int operstrcmp(char* data,char* input)
{
int MOD_RESULT = 0;
@@ -1556,200 +212,6 @@ int operstrcmp(char* data,char* input)
return strcmp(data,input);
}
-void handle_oper(char **parameters, int pcnt, userrec *user)
-{
- char LoginName[MAXBUF];
- char Password[MAXBUF];
- char OperType[MAXBUF];
- char TypeName[MAXBUF];
- char HostName[MAXBUF];
- char TheHost[MAXBUF];
- int j;
- bool found = false;
- bool fail2 = false;
-
- snprintf(TheHost,MAXBUF,"%s@%s",user->ident,user->host);
-
- for (int i = 0; i < Config->ConfValueEnum("oper",&Config->config_f); i++)
- {
- Config->ConfValue("oper","name",i,LoginName,&Config->config_f);
- Config->ConfValue("oper","password",i,Password,&Config->config_f);
- Config->ConfValue("oper","type",i,OperType,&Config->config_f);
- Config->ConfValue("oper","host",i,HostName,&Config->config_f);
- if ((!strcmp(LoginName,parameters[0])) && (!operstrcmp(Password,parameters[1])) && (match(TheHost,HostName)))
- {
- fail2 = true;
- for (j =0; j < Config->ConfValueEnum("type",&Config->config_f); j++)
- {
- Config->ConfValue("type","name",j,TypeName,&Config->config_f);
-
- if (!strcmp(TypeName,OperType))
- {
- /* found this oper's opertype */
- Config->ConfValue("type","host",j,HostName,&Config->config_f);
- if (*HostName)
- ChangeDisplayedHost(user,HostName);
- strlcpy(user->oper,TypeName,NICKMAX);
- found = true;
- fail2 = false;
- break;
- }
- }
- }
- if (found)
- break;
- }
- if (found)
- {
- /* correct oper credentials */
- WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType);
- WriteServ(user->fd,"381 %s :You are now an IRC operator of type %s",user->nick,OperType);
- if (!strchr(user->modes,'o'))
- {
- strcat(user->modes,"o");
- WriteServ(user->fd,"MODE %s :+o",user->nick);
- FOREACH_MOD OnOper(user,OperType);
- log(DEFAULT,"OPER: %s!%s@%s opered as type: %s",user->nick,user->ident,user->host,OperType);
- AddOper(user);
- }
- }
- else
- {
- if (!fail2)
- {
- WriteServ(user->fd,"491 %s :Invalid oper credentials",user->nick);
- WriteOpers("*** WARNING! Failed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host);
- log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: user, host or password did not match.",user->nick,user->ident,user->host);
- }
- else
- {
- WriteServ(user->fd,"491 %s :Your oper block does not have a valid opertype associated with it",user->nick);
- WriteOpers("*** CONFIGURATION ERROR! Oper block mismatch for OperType %s",OperType);
- log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: credentials valid, but oper type nonexistent.",user->nick,user->ident,user->host);
- }
- }
- return;
-}
-
-void handle_nick(char **parameters, int pcnt, userrec *user)
-{
- if (pcnt < 1)
- {
- log(DEBUG,"not enough params for handle_nick");
- return;
- }
- if (!parameters[0])
- {
- log(DEBUG,"invalid parameter passed to handle_nick");
- return;
- }
- if (!parameters[0][0])
- {
- log(DEBUG,"zero length new nick passed to handle_nick");
- return;
- }
- if (!user)
- {
- log(DEBUG,"invalid user passed to handle_nick");
- return;
- }
- if (!user->nick)
- {
- log(DEBUG,"invalid old nick passed to handle_nick");
- return;
- }
- if (!strcasecmp(user->nick,parameters[0]))
- {
- log(DEBUG,"old nick is new nick, skipping");
- return;
- }
- else
- {
- if (strlen(parameters[0]) > 1)
- {
- if (parameters[0][0] == ':')
- {
- *parameters[0]++;
- }
- }
- if (matches_qline(parameters[0]))
- {
- WriteOpers("*** Q-Lined nickname %s from %s!%s@%s: %s",parameters[0],user->nick,user->ident,user->host,matches_qline(parameters[0]));
- WriteServ(user->fd,"432 %s %s :Invalid nickname: %s",user->nick,parameters[0],matches_qline(parameters[0]));
- return;
- }
- if ((Find(parameters[0])) && (Find(parameters[0]) != user))
- {
- WriteServ(user->fd,"433 %s %s :Nickname is already in use.",user->nick,parameters[0]);
- return;
- }
- }
- if (isnick(parameters[0]) == 0)
- {
- WriteServ(user->fd,"432 %s %s :Erroneous Nickname",user->nick,parameters[0]);
- return;
- }
-
- if (user->registered == 7)
- {
- int MOD_RESULT = 0;
- FOREACH_RESULT(OnUserPreNick(user,parameters[0]));
- if (MOD_RESULT) {
- // if a module returns true, the nick change is silently forbidden.
- return;
- }
-
- WriteCommon(user,"NICK %s",parameters[0]);
-
- }
-
- char oldnick[NICKMAX];
- strlcpy(oldnick,user->nick,NICKMAX);
-
- /* change the nick of the user in the users_hash */
- user = ReHashNick(user->nick, parameters[0]);
- /* actually change the nick within the record */
- if (!user) return;
- if (!user->nick) return;
-
- strlcpy(user->nick, parameters[0],NICKMAX);
-
- log(DEBUG,"new nick set: %s",user->nick);
-
- if (user->registered < 3)
- {
- user->registered = (user->registered | 2);
- // dont attempt to look up the dns until they pick a nick... because otherwise their pointer WILL change
- // and unless we're lucky we'll get a duff one later on.
- //user->dns_done = (!lookup_dns(user->nick));
- //if (user->dns_done)
- // log(DEBUG,"Aborting dns lookup of %s because dns server experienced a failure.",user->nick);
-
-#ifdef THREADED_DNS
- // initialize their dns lookup thread
- if (pthread_create(&user->dnsthread, NULL, dns_task, (void *)user) != 0)
- {
- log(DEBUG,"Failed to create DNS lookup thread for user %s",user->nick);
- }
-#else
- user->dns_done = (!lookup_dns(user->nick));
- if (user->dns_done)
- log(DEBUG,"Aborting dns lookup of %s because dns server experienced a failure.",user->nick);
-#endif
-
- }
- if (user->registered == 3)
- {
- /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
- FOREACH_MOD OnUserRegister(user);
- ConnectUser(user);
- }
- if (user->registered == 7)
- {
- FOREACH_MOD OnUserPostNick(user,oldnick);
- }
-}
-
long duration(const char* str)
{
char n_field[MAXBUF];
@@ -1890,174 +352,3 @@ bool nick_matches_everyone(std::string nick, userrec* user)
}
return false;
}
-
-void handle_kline(char **parameters, int pcnt, userrec *user)
-{
- if (pcnt >= 3)
- {
- if (host_matches_everyone(parameters[0],user))
- return;
- add_kline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
- FOREACH_MOD OnAddKLine(duration(parameters[1]), user, parameters[2], parameters[0]);
- if (!duration(parameters[1]))
- {
- WriteOpers("*** %s added permenant K-line for %s.",user->nick,parameters[0]);
- }
- else
- {
- WriteOpers("*** %s added timed K-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
- }
- apply_lines(APPLY_KLINES);
- }
- else
- {
- if (del_kline(parameters[0]))
- {
- FOREACH_MOD OnDelKLine(user, parameters[0]);
- WriteOpers("*** %s Removed K-line on %s.",user->nick,parameters[0]);
- }
- else
- {
- WriteServ(user->fd,"NOTICE %s :*** K-Line %s not found in list, try /stats k.",user->nick,parameters[0]);
- }
- }
-}
-
-void handle_eline(char **parameters, int pcnt, userrec *user)
-{
- if (pcnt >= 3)
- {
- if (host_matches_everyone(parameters[0],user))
- return;
- add_eline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
- FOREACH_MOD OnAddELine(duration(parameters[1]), user, parameters[2], parameters[0]);
- if (!duration(parameters[1]))
- {
- WriteOpers("*** %s added permenant E-line for %s.",user->nick,parameters[0]);
- }
- else
- {
- WriteOpers("*** %s added timed E-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
- }
- }
- else
- {
- if (del_eline(parameters[0]))
- {
- FOREACH_MOD OnDelELine(user, parameters[0]);
- WriteOpers("*** %s Removed E-line on %s.",user->nick,parameters[0]);
- }
- else
- {
- WriteServ(user->fd,"NOTICE %s :*** E-Line %s not found in list, try /stats e.",user->nick,parameters[0]);
- }
- }
- // no need to apply the lines for an eline
-}
-
-void handle_gline(char **parameters, int pcnt, userrec *user)
-{
- if (pcnt >= 3)
- {
- if (host_matches_everyone(parameters[0],user))
- return;
- add_gline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
- FOREACH_MOD OnAddGLine(duration(parameters[1]), user, parameters[2], parameters[0]);
- if (!duration(parameters[1]))
- {
- WriteOpers("*** %s added permenant G-line for %s.",user->nick,parameters[0]);
- }
- else
- {
- WriteOpers("*** %s added timed G-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
- }
- apply_lines(APPLY_GLINES);
- }
- else
- {
- if (del_gline(parameters[0]))
- {
- FOREACH_MOD OnDelGLine(user, parameters[0]);
- WriteOpers("*** %s Removed G-line on %s.",user->nick,parameters[0]);
- }
- else
- {
- WriteServ(user->fd,"NOTICE %s :*** G-Line %s not found in list, try /stats g.",user->nick,parameters[0]);
- }
- }
-}
-
-void handle_zline(char **parameters, int pcnt, userrec *user)
-{
- if (pcnt >= 3)
- {
- if (strchr(parameters[0],'@'))
- {
- WriteServ(user->fd,"NOTICE %s :*** You cannot include a username in a zline, a zline must ban only an IP mask",user->nick);
- return;
- }
- if (ip_matches_everyone(parameters[0],user))
- return;
- add_zline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
- FOREACH_MOD OnAddZLine(duration(parameters[1]), user, parameters[2], parameters[0]);
- if (!duration(parameters[1]))
- {
- WriteOpers("*** %s added permenant Z-line for %s.",user->nick,parameters[0]);
- }
- else
- {
- WriteOpers("*** %s added timed Z-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
- }
- apply_lines(APPLY_ZLINES);
- }
- else
- {
- if (del_zline(parameters[0]))
- {
- FOREACH_MOD OnDelZLine(user, parameters[0]);
- WriteOpers("*** %s Removed Z-line on %s.",user->nick,parameters[0]);
- }
- else
- {
- WriteServ(user->fd,"NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick,parameters[0]);
- }
- }
-}
-
-void handle_qline(char **parameters, int pcnt, userrec *user)
-{
- if (pcnt >= 3)
- {
- if (nick_matches_everyone(parameters[0],user))
- return;
- add_qline(duration(parameters[1]),user->nick,parameters[2],parameters[0]);
- FOREACH_MOD OnAddQLine(duration(parameters[1]), user, parameters[2], parameters[0]);
- if (!duration(parameters[1]))
- {
- WriteOpers("*** %s added permenant Q-line for %s.",user->nick,parameters[0]);
- }
- else
- {
- WriteOpers("*** %s added timed Q-line for %s, expires in %d seconds.",user->nick,parameters[0],duration(parameters[1]));
- }
- apply_lines(APPLY_QLINES);
- }
- else
- {
- if (del_qline(parameters[0]))
- {
- FOREACH_MOD OnDelQLine(user, parameters[0]);
- WriteOpers("*** %s Removed Q-line on %s.",user->nick,parameters[0]);
- }
- else
- {
- WriteServ(user->fd,"NOTICE %s :*** Q-Line %s not found in list, try /stats q.",user->nick,parameters[0]);
- }
- }
-}
-
-void handle_version(char **parameters, int pcnt, userrec *user)
-{
- WriteServ(user->fd,"351 %s :%s",user->nick,ServerInstance->GetVersionString().c_str());
-}
-
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 176455961..4055f2a38 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -37,7 +37,6 @@ using namespace std;
#include <sstream>
#include <vector>
#include <deque>
-#include <sched.h>
#ifdef THREADED_DNS
#include <pthread.h>
#endif
@@ -58,7 +57,6 @@ using namespace std;
#include "socketengine.h"
#include "userprocess.h"
#include "socket.h"
-#include "dns.h"
#include "typedefs.h"
#include "command_parse.h"
diff --git a/src/mode.cpp b/src/mode.cpp
index d1fc5b93a..7d401d7e3 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -1241,7 +1241,7 @@ bool ModeParser::ProcessModuleUmode(char umode, userrec* source, void* dest, boo
}
}
-void handle_mode(char **parameters, int pcnt, userrec *user)
+void cmd_mode::Handle (char **parameters, int pcnt, userrec *user)
{
chanrec* Ptr;
userrec* dest;
diff --git a/src/modules.cpp b/src/modules.cpp
index d3043a63e..71f8f672e 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -414,9 +414,9 @@ void Server::Log(int level, std::string s)
log(level,"%s",s.c_str());
}
-void Server::AddCommand(char* cmd, handlerfunc f, char flags, int minparams, char* source)
+void Server::AddCommand(command_t *f)
{
- ServerInstance->Parser->CreateCommand(cmd,f,flags,minparams,source);
+ ServerInstance->Parser->CreateCommand(f);
}
void Server::SendMode(char **parameters, int pcnt, userrec *user)
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp
index 6a5845e72..be8154013 100644
--- a/src/modules/m_chghost.cpp
+++ b/src/modules/m_chghost.cpp
@@ -25,40 +25,53 @@ using namespace std;
/* $ModDesc: Provides support for the CHGHOST command */
Server *Srv;
-
-void handle_chghost(char **parameters, int pcnt, userrec *user)
+
+
+class cmd_chghost : public command_t
{
- for (unsigned int x = 0; x < strlen(parameters[1]); x++)
+ public:
+ cmd_chghost () : command_t("CHGHOST",'o',2)
+ {
+ this->source = "m_chghost.so";
+ }
+
+ void Handle(char **parameters, int pcnt, userrec *user)
{
- if (((tolower(parameters[1][x]) < 'a') || (tolower(parameters[1][x]) > 'z')) && (parameters[1][x] != '.'))
+ for (unsigned int x = 0; x < strlen(parameters[1]); x++)
{
- if (((parameters[1][x] < '0') || (parameters[1][x]> '9')) && (parameters[1][x] != '-'))
+ if (((tolower(parameters[1][x]) < 'a') || (tolower(parameters[1][x]) > 'z')) && (parameters[1][x] != '.'))
{
- Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
- return;
+ if (((parameters[1][x] < '0') || (parameters[1][x]> '9')) && (parameters[1][x] != '-'))
+ {
+ Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
+ return;
+ }
}
- }
- } userrec* dest = Srv->FindNick(std::string(parameters[0]));
- if (dest)
- {
- Srv->ChangeHost(dest,parameters[1]);
- if (!Srv->IsUlined(user->server))
+ }
+ userrec* dest = Srv->FindNick(std::string(parameters[0]));
+ if (dest)
{
- // fix by brain - ulines set hosts silently
- Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1]));
+ Srv->ChangeHost(dest,parameters[1]);
+ if (!Srv->IsUlined(user->server))
+ {
+ // fix by brain - ulines set hosts silently
+ Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1]));
+ }
}
}
-}
+};
class ModuleChgHost : public Module
{
+ cmd_chghost* mycommand;
public:
ModuleChgHost(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddCommand("CHGHOST",handle_chghost,'o',2,"m_chghost.so");
+ mycommand = new cmd_chghost();
+ Srv->AddCommand(mycommand);
}
virtual ~ModuleChgHost()
@@ -67,7 +80,7 @@ class ModuleChgHost : public Module
virtual Version GetVersion()
{
- return Version(1,0,0,1,VF_VENDOR);
+ return Version(1,2,0,1,VF_VENDOR);
}
};
diff --git a/src/modules/m_globops.cpp b/src/modules/m_globops.cpp
index 48b406dcb..301290363 100644
--- a/src/modules/m_globops.cpp
+++ b/src/modules/m_globops.cpp
@@ -27,20 +27,30 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
Server *Srv;
-
-void handle_globops(char **parameters, int pcnt, userrec *user)
+
+class cmd_globops : public command_t
{
- std::string line = "*** GLOBOPS - From " + std::string(user->nick) + ": ";
- for (int i = 0; i < pcnt; i++)
+ public:
+ cmd_globops () : command_t("GLOBOPS",'o',1)
{
- line = line + std::string(parameters[i]) + " ";
+ this->source = "m_globops.so";
}
- Srv->SendToModeMask("og",WM_AND,line);
-}
+
+ void Handle (char **parameters, int pcnt, userrec *user)
+ {
+ std::string line = "*** GLOBOPS - From " + std::string(user->nick) + ": ";
+ for (int i = 0; i < pcnt; i++)
+ {
+ line = line + std::string(parameters[i]) + " ";
+ }
+ Srv->SendToModeMask("og",WM_AND,line);
+ }
+};
class ModuleGlobops : public Module
{
+ cmd_globops* mycommand;
public:
ModuleGlobops(Server* Me)
: Module::Module(Me)
@@ -53,7 +63,11 @@ class ModuleGlobops : public Module
printf("Could not claim usermode +g for this module!");
return;
}
- else Srv->AddCommand("GLOBOPS",handle_globops,'o',1,"m_globops.so");
+ else
+ {
+ mycommand = new cmd_globops();
+ Srv->AddCommand(mycommand);
+ }
}
virtual ~ModuleGlobops()
diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp
index 2a0a0e62b..1aeb69b12 100644
--- a/src/modules/m_helpop.cpp
+++ b/src/modules/m_helpop.cpp
@@ -30,67 +30,76 @@ void handle_helpop(char**, int, userrec*);
bool do_helpop(char**, int, userrec*);
void sendtohelpop(userrec*, int, char**);
-
/* $ModDesc: /helpop Command, Works like Unreal helpop */
-void handle_helpop(char **parameters, int pcnt, userrec *user)
+class cmd_helpop : public command_t
{
- char a[MAXBUF];
- std::string output = " ";
-
- if (!helpop)
- return;
+ public:
+ cmd_helpop () : command_t("HELPOP",0,0)
+ {
+ this->source = "m_helpop.so";
+ }
- if (pcnt < 1)
+ void Handle (char **parameters, int pcnt, userrec *user)
{
- do_helpop(NULL,pcnt,user);
- return;
- }
+ char a[MAXBUF];
+ std::string output = " ";
- if (parameters[0][0] == '!')
- {
- // Force send to all +h users
- sendtohelpop(user, pcnt, parameters);
- }
- else if (parameters[0][0] == '?')
- {
- // Force to the helpop system with no forward if not found.
- if (do_helpop(parameters, pcnt, user) == false)
+ if (!helpop)
+ return;
+
+ if (pcnt < 1)
{
- // Not handled by the Database, Tell the user, and bail.
- for (int i = 1; output != ""; i++)
- {
- snprintf(a,MAXBUF,"line%d",i);
- output = helpop->ReadValue("nohelp", std::string(a), 0);
+ do_helpop(NULL,pcnt,user);
+ return;
+ }
- if(output != "")
+ if (parameters[0][0] == '!')
+ {
+ // Force send to all +h users
+ sendtohelpop(user, pcnt, parameters);
+ }
+ else if (parameters[0][0] == '?')
+ {
+ // Force to the helpop system with no forward if not found.
+ if (do_helpop(parameters, pcnt, user) == false)
+ {
+ // Not handled by the Database, Tell the user, and bail.
+ for (int i = 1; output != ""; i++)
{
- Srv->SendTo(NULL,user,"290 "+std::string(user->nick)+" :"+output);
+ snprintf(a,MAXBUF,"line%d",i);
+ output = helpop->ReadValue("nohelp", std::string(a), 0);
+
+ if(output != "")
+ {
+ Srv->SendTo(NULL,user,"290 "+std::string(user->nick)+" :"+output);
+ }
}
}
}
- }
- else
- {
- // Check with the helpop database, if not found send to +h
- if (do_helpop(parameters, pcnt, user) == false)
+ else
{
- // Not handled by the Database, Tell the user, and forward.
- for (int i = 1; output != ""; i++)
- {
- snprintf(a,MAXBUF,"line%d",i);
- /* "nohelpo" for opers "nohelp" for users */
- output = helpop->ReadValue("nohelpo", std::string(a), 0);
- if (output != "")
- {
- Srv->SendTo(NULL,user,"290 "+std::string(user->nick)+" :"+output);
- }
- }
- // Forward.
- sendtohelpop(user, pcnt, parameters);
+ // Check with the helpop database, if not found send to +h
+ if (do_helpop(parameters, pcnt, user) == false)
+ {
+ // Not handled by the Database, Tell the user, and forward.
+ for (int i = 1; output != ""; i++)
+ {
+ snprintf(a,MAXBUF,"line%d",i);
+ /* "nohelpo" for opers "nohelp" for users */
+ output = helpop->ReadValue("nohelpo", std::string(a), 0);
+ if (output != "")
+ {
+ Srv->SendTo(NULL,user,"290 "+std::string(user->nick)+" :"+output);
+ }
+ }
+ // Forward.
+ sendtohelpop(user, pcnt, parameters);
+ }
}
}
-}
+};
+
bool do_helpop(char **parameters, int pcnt, userrec *src)
{
@@ -156,6 +165,7 @@ class ModuleHelpop : public Module
private:
ConfigReader *conf;
std::string h_file;
+ cmd_helpop* mycommand;
public:
ModuleHelpop(Server* Me)
@@ -170,7 +180,8 @@ class ModuleHelpop : public Module
return;
}
- Srv->AddCommand("HELPOP",handle_helpop,0,0,"m_helpop.so");
+ mycommand = new cmd_helpop();
+ Srv->AddCommand(mycommand);
}
virtual void ReadConfig()
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index 08ce7ece4..7948dc0db 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -26,47 +26,56 @@ using namespace std;
/* $ModDesc: Provides support for /KNOCK and mode +K */
Server *Srv;
-
-void handle_knock(char **parameters, int pcnt, userrec *user)
-{
- chanrec* c = Srv->FindChannel(parameters[0]);
- std::string line = "";
-
- for (int i = 1; i < pcnt - 1; i++)
- {
- line = line + std::string(parameters[i]) + " ";
- }
- line = line + std::string(parameters[pcnt-1]);
- if (c->IsCustomModeSet('K'))
- {
- WriteServ(user->fd,"480 %s :Can't KNOCK on %s, +K is set.",user->nick, c->name);
- return;
- }
- if (c->binarymodes & CM_INVITEONLY)
+class cmd_knock : public command_t
+{
+ public:
+ cmd_knock () : command_t("KNOCK", 0, 2)
{
- WriteChannelWithServ((char*)Srv->GetServerName().c_str(),c,"NOTICE %s :User %s is KNOCKing on %s (%s)",c->name,user->nick,c->name,line.c_str());
- WriteServ(user->fd,"NOTICE %s :KNOCKing on %s",user->nick,c->name);
- return;
+ this->source = "m_knock.so";
}
- else
+
+ void Handle (char **parameters, int pcnt, userrec *user)
{
- WriteServ(user->fd,"480 %s :Can't KNOCK on %s, channel is not invite only so knocking is pointless!",user->nick, c->name);
- return;
- }
-}
+ chanrec* c = Srv->FindChannel(parameters[0]);
+ std::string line = "";
+ for (int i = 1; i < pcnt - 1; i++)
+ {
+ line = line + std::string(parameters[i]) + " ";
+ }
+ line = line + std::string(parameters[pcnt-1]);
+
+ if (c->IsCustomModeSet('K'))
+ {
+ WriteServ(user->fd,"480 %s :Can't KNOCK on %s, +K is set.",user->nick, c->name);
+ return;
+ }
+ if (c->binarymodes & CM_INVITEONLY)
+ {
+ WriteChannelWithServ((char*)Srv->GetServerName().c_str(),c,"NOTICE %s :User %s is KNOCKing on %s (%s)",c->name,user->nick,c->name,line.c_str());
+ WriteServ(user->fd,"NOTICE %s :KNOCKing on %s",user->nick,c->name);
+ return;
+ }
+ else
+ {
+ WriteServ(user->fd,"480 %s :Can't KNOCK on %s, channel is not invite only so knocking is pointless!",user->nick, c->name);
+ return;
+ }
+ }
+};
class ModuleKnock : public Module
{
+ cmd_knock* mycommand;
public:
ModuleKnock(Server* Me)
: Module::Module(Me)
{
Srv = Me;
-
Srv->AddExtendedMode('K',MT_CHANNEL,false,0,0);
- Srv->AddCommand("KNOCK",handle_knock,0,2,"m_knock.so");
+ mycommand = new cmd_knock();
+ Srv->AddCommand(mycommand);
}
virtual void On005Numeric(std::string &output)
diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp
index efdfcca4d..37e9d49bd 100644
--- a/src/modules/m_nicklock.cpp
+++ b/src/modules/m_nicklock.cpp
@@ -27,64 +27,86 @@ using namespace std;
/* $ModDesc: Provides the NICKLOCK command, allows an oper to chage a users nick and lock them to it until they quit */
Server *Srv;
-
-void handle_nicklock(char **parameters, int pcnt, userrec *user)
+
+class cmd_nicklock : public command_t
{
- userrec* source = Srv->FindNick(std::string(parameters[0]));
- irc::string server;
- irc::string me;
+ public:
+ cmd_nicklock () : command_t("NICKLOCK", 'o', 2)
+ {
+ this->source = "m_nicklock.so";
+ }
- if (source)
+ void Handle(char **parameters, int pcnt, userrec *user)
{
- if (source->GetExt("nick_locked"))
- {
- WriteServ(user->fd,"946 %s %s :This user's nickname is already locked.",user->nick,source->nick);
- return;
- }
- if (Srv->IsNick(std::string(parameters[1])))
- {
- server = user->server;
- me = Srv->GetServerName().c_str();
+ userrec* source = Srv->FindNick(std::string(parameters[0]));
+ irc::string server;
+ irc::string me;
- if (server == me)
+ if (source)
+ {
+ if (source->GetExt("nick_locked"))
{
- // give them a lock flag
- Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
- Srv->ChangeUserNick(source,std::string(parameters[1]));
- // only attempt to set their lockflag after we know the change succeeded
- source = Srv->FindNick(std::string(parameters[1]));
- if (source)
- source->Extend("nick_locked", "ON");
+ WriteServ(user->fd,"946 %s %s :This user's nickname is already locked.",user->nick,source->nick);
+ return;
}
- else
+ if (Srv->IsNick(std::string(parameters[1])))
{
- WriteServ(user->fd,"947 %s %s :Can't lock the nickname of a non-local user",user->nick,source->nick);
+ server = user->server;
+ me = Srv->GetServerName().c_str();
+
+ if (server == me)
+ {
+ // give them a lock flag
+ Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
+ Srv->ChangeUserNick(source,std::string(parameters[1]));
+ // only attempt to set their lockflag after we know the change succeeded
+ source = Srv->FindNick(std::string(parameters[1]));
+ if (source)
+ source->Extend("nick_locked", "ON");
+ }
+ else
+ {
+ WriteServ(user->fd,"947 %s %s :Can't lock the nickname of a non-local user",user->nick,source->nick);
+ }
}
}
}
-}
+};
-void handle_nickunlock(char **parameters, int pcnt, userrec *user)
+class cmd_nickunlock : public command_t
{
- userrec* source = Srv->FindNick(std::string(parameters[0]));
- if (source)
+ public:
+ cmd_nickunlock () : command_t("NICKUNLOCK", 'o', 1)
{
- source->Shrink("nick_locked");
- WriteServ(user->fd,"945 %s %s :Nickname now unlocked.",user->nick,source->nick);
- Srv->SendOpers(std::string(user->nick)+" used NICKUNLOCK on "+std::string(parameters[0]));
+ this->source = "m_nickunlock.so";
}
-}
+
+ void Handle (char **parameters, int pcnt, userrec *user)
+ {
+ userrec* source = Srv->FindNick(std::string(parameters[0]));
+ if (source)
+ {
+ source->Shrink("nick_locked");
+ WriteServ(user->fd,"945 %s %s :Nickname now unlocked.",user->nick,source->nick);
+ Srv->SendOpers(std::string(user->nick)+" used NICKUNLOCK on "+std::string(parameters[0]));
+ }
+ }
+};
class ModuleNickLock : public Module
{
+ cmd_nicklock* cmd1;
+ cmd_nickunlock* cmd2;
public:
ModuleNickLock(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddCommand("NICKLOCK",handle_nicklock,'o',2,"m_nicklock.so");
- Srv->AddCommand("NICKUNLOCK",handle_nickunlock,'o',1,"m_nicklock.so");
+ cmd1 = new cmd_nicklock();
+ cmd2 = new cmd_nickunlock();
+ Srv->AddCommand(cmd1);
+ Srv->AddCommand(cmd2);
}
virtual ~ModuleNickLock()
diff --git a/src/modules/m_opermd5.cpp b/src/modules/m_opermd5.cpp
index 6ce0cab2f..44b029082 100644
--- a/src/modules/m_opermd5.cpp
+++ b/src/modules/m_opermd5.cpp
@@ -261,22 +261,33 @@ void GenHash(const char* src, char* dest)
strcpy(dest,hash);
}
-void handle_mkpasswd(char **parameters, int pcnt, userrec *user)
+class cmd_mkpasswd : public command_t
{
- char buffer[MAXBUF];
- GenHash(parameters[0],buffer);
- WriteServ(user->fd,"NOTICE %s :MD5 hashed password for %s is %s",user->nick,parameters[0],buffer);
-}
+ public:
+ cmd_mkpasswd () : command_t("MKPASSWD", 'o', 1)
+ {
+ this->source = "m_opermd5.so";
+ }
+
+ void Handle (char **parameters, int pcnt, userrec *user)
+ {
+ char buffer[MAXBUF];
+ GenHash(parameters[0],buffer);
+ WriteServ(user->fd,"NOTICE %s :MD5 hashed password for %s is %s",user->nick,parameters[0],buffer);
+ }
+};
class ModuleOperMD5 : public Module
{
+ cmd_mkpasswd* mycommand;
public:
ModuleOperMD5(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddCommand("MKPASSWD",handle_mkpasswd,'o',1,"m_opermd5.so");
+ mycommand = new cmd_mkpasswd();
+ Srv->AddCommand(mycommand);
}
virtual ~ModuleOperMD5()
diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp
index a2a3c0312..7fd19122b 100644
--- a/src/modules/m_opermotd.cpp
+++ b/src/modules/m_opermotd.cpp
@@ -13,8 +13,6 @@ using namespace std;
FileReader* opermotd;
Server* Srv;
-void do_opermotd(char** parameters, int pcnt, userrec* user);
-
void LoadOperMOTD()
{
ConfigReader* conf = new ConfigReader;
@@ -45,20 +43,30 @@ void ShowOperMOTD(userrec* user)
}
-void do_opermotd(char** parameters, int pcnt, userrec* user)
+class cmd_opermotd : public command_t
{
- ShowOperMOTD(user);
-}
+ public:
+ cmd_opermotd () : command_t("OPERMOTD", 'o', 0)
+ {
+ this->source = "m_opermotd.so";
+ }
+
+ void Handle (char** parameters, int pcnt, userrec* user)
+ {
+ ShowOperMOTD(user);
+ }
+};
class ModuleOpermotd : public Module
{
+ cmd_opermotd* mycommand;
public:
ModuleOpermotd(Server* Me)
: Module::Module(Me)
{
Srv = Me;
-
- Srv->AddCommand("OPERMOTD",do_opermotd,'o',0,"m_opermotd.so");
+ mycommand = new cmd_opermotd();
+ Srv->AddCommand(mycommand);
opermotd = new FileReader();
LoadOperMOTD();
}
diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp
index 6a640f318..264a3ba0f 100644
--- a/src/modules/m_park.cpp
+++ b/src/modules/m_park.cpp
@@ -51,129 +51,159 @@ long ConcurrentParks;
long ParkMaxMsgs;
parkedinfo pi;
-void handle_park(char **parameters, int pcnt, userrec *user)
+class cmd_park : public command_t
{
- /** Parking. easy stuff.
- *
- * We duplicate and switch the users file descriptor, so that they can remain forever as a 'ghost'
- * We then disconnect the real user leaving a controlled ghost in their place :)
- */
- int othersessions = 0;
- if (pinfo.size())
- for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
- if (j->host == std::string(user->host))
- othersessions++;
- if (othersessions >= ConcurrentParks)
+ public:
+ cmd_park () : command_t("PARK", 0, 0)
{
- Srv->SendServ(user->fd,"927 "+std::string(user->nick)+" :You are already parked up to the maximum number of allowed times.");
+ this->source = "m_park.so";
}
- else
+
+ void Handle (char **parameters, int pcnt, userrec *user)
{
- awaylog* aw;
- char msg[MAXBUF];
- unsigned long key = abs(random() * 12345);
- snprintf(msg,MAXBUF,"You are now parked. To unpark use /UNPARK %s %lu",user->nick,key);
- Srv->UserToPseudo(user,std::string(msg));
- aw = new awaylog;
- user->Extend("park_awaylog",(char*)aw);
- user->Extend("park_key",(char*)key);
- pi.nick = user->nick;
- pi.host = user->host;
- pi.parktime = time(NULL);
- pinfo.push_back(pi);
+ /** Parking. easy stuff.
+ *
+ * We duplicate and switch the users file descriptor, so that they can remain forever as a 'ghost'
+ * We then disconnect the real user leaving a controlled ghost in their place :)
+ */
+ int othersessions = 0;
+ if (pinfo.size())
+ for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
+ if (j->host == std::string(user->host))
+ othersessions++;
+ if (othersessions >= ConcurrentParks)
+ {
+ Srv->SendServ(user->fd,"927 "+std::string(user->nick)+" :You are already parked up to the maximum number of allowed times.");
+ }
+ else
+ {
+ awaylog* aw;
+ char msg[MAXBUF];
+ unsigned long key = abs(random() * 12345);
+ snprintf(msg,MAXBUF,"You are now parked. To unpark use /UNPARK %s %lu",user->nick,key);
+ Srv->UserToPseudo(user,std::string(msg));
+ aw = new awaylog;
+ user->Extend("park_awaylog",(char*)aw);
+ user->Extend("park_key",(char*)key);
+ pi.nick = user->nick;
+ pi.host = user->host;
+ pi.parktime = time(NULL);
+ pinfo.push_back(pi);
+ }
}
-}
-void handle_parkstats(char **parameters, int pcnt, userrec *user)
-{
- char status[MAXBUF];
- snprintf(status,MAXBUF,"NOTICE %s :There are a total of %lu parked clients on this server, with a maximum of %lu parked sessions allowed per user.",user->nick,(unsigned long)pinfo.size(),(unsigned long)ConcurrentParks);
- Srv->SendServ(user->fd,status);
-}
+};
-void handle_unpark(char **parameters, int pcnt, userrec *user)
+class cmd_parkstats : public command_t
{
- /** Unparking. complicated stuff.
- *
- * Unparking is done in several steps:
- *
- * (1) Check if the user is parked
- * (2) Check the key of the user against the one provided
- * (3) Part the user who issued the command from all of their channels so as not to confuse clients
- * (4) Remove all the users UMODEs
- * (5) Duplicate and switch file descriptors on the two users, and disconnect the dead one
- * (6) Force a nickchange onto the user who issued the command forcing them to change to the parked nick
- * (7) Force join the user into all the channels the parked nick is currently in (send them localized join and namelist)
- * (8) Send the user the umodes of their new 'persona'
- * (9) Spool any awaylog messages to the user
- *
- * And there you have it, easy huh (NOT)...
- */
- userrec* unpark = Srv->FindNick(std::string(parameters[0]));
- if (!unpark)
+ public:
+ cmd_parkstats () : command_t("PARKSTATS", 'o', 0)
{
- WriteServ(user->fd,"942 %s %s :Invalid user specified.",user->nick, parameters[0]);
- return;
+ this->source = "m_park.so";
}
- awaylog* awy = (awaylog*)unpark->GetExt("park_awaylog");
- long key = (long)unpark->GetExt("park_key");
- if (!awy)
+
+ void Handle (char **parameters, int pcnt, userrec *user)
{
- WriteServ(user->fd,"943 %s %s :This user is not parked.",user->nick, unpark->nick);
- return;
+ char status[MAXBUF];
+ snprintf(status,MAXBUF,"NOTICE %s :There are a total of %lu parked clients on this server, with a maximum of %lu parked sessions allowed per user.",user->nick,(unsigned long)pinfo.size(),(unsigned long)ConcurrentParks);
+ Srv->SendServ(user->fd,status);
}
- if (key == atoi(parameters[1]))
+};
+
+class cmd_unpark : public command_t
+{
+ public:
+ cmd_unpark () : command_t("UNPARK", 0, 2)
{
- // first part the user from all chans theyre on, so things dont get messy
- for (int i = 0; i < user->chans.size(); i++)
- {
- if (user->chans[i].channel != NULL)
- {
- if (user->chans[i].channel->name)
- {
- Srv->PartUserFromChannel(user,user->chans[i].channel->name,"Unparking");
- }
- }
+ this->source = "m_park.so";
+ }
+
+ void Handle (char **parameters, int pcnt, userrec *user)
+ {
+ /** Unparking. complicated stuff.
+ *
+ * Unparking is done in several steps:
+ *
+ * (1) Check if the user is parked
+ * (2) Check the key of the user against the one provided
+ * (3) Part the user who issued the command from all of their channels so as not to confuse clients
+ * (4) Remove all the users UMODEs
+ * (5) Duplicate and switch file descriptors on the two users, and disconnect the dead one
+ * (6) Force a nickchange onto the user who issued the command forcing them to change to the parked nick
+ * (7) Force join the user into all the channels the parked nick is currently in (send them localized join and namelist)
+ * (8) Send the user the umodes of their new 'persona'
+ * (9) Spool any awaylog messages to the user
+ *
+ * And there you have it, easy huh (NOT)...
+ */
+ userrec* unpark = Srv->FindNick(std::string(parameters[0]));
+ if (!unpark)
+ {
+ WriteServ(user->fd,"942 %s %s :Invalid user specified.",user->nick, parameters[0]);
+ return;
}
- // remove all their old modes
- WriteServ(user->fd,"MODE %s -%s",user->nick,user->modes);
- // now, map them to the parked user, while nobody can see :p
- Srv->PseudoToUser(user,unpark,"Unparked to "+std::string(parameters[0]));
- // set all their new modes
- WriteServ(unpark->fd,"MODE %s +%s",unpark->nick,unpark->modes);
- // spool their away log to them
- WriteServ(unpark->fd,"NOTICE %s :*** You are now unparked. You have successfully taken back the nickname and privilages of %s.",unpark->nick,unpark->nick);
- for (awaylog::iterator i = awy->begin(); i != awy->end(); i++)
+ awaylog* awy = (awaylog*)unpark->GetExt("park_awaylog");
+ long key = (long)unpark->GetExt("park_key");
+ if (!awy)
{
- char timebuf[MAXBUF];
- tm *timeinfo = localtime(&i->tm);
- strlcpy(timebuf,asctime(timeinfo),MAXBUF);
- timebuf[strlen(timebuf)-1] = '\0';
- WriteServ(unpark->fd,"NOTICE %s :From %s at %s: \2%s\2",unpark->nick,i->from.c_str(),timebuf,i->text.c_str());
+ WriteServ(user->fd,"943 %s %s :This user is not parked.",user->nick, unpark->nick);
+ return;
}
- delete awy;
- unpark->Shrink("park_awaylog");
- unpark->Shrink("park_key");
- for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
+ if (key == atoi(parameters[1]))
{
- if (j->nick == std::string(unpark->nick))
+ // first part the user from all chans theyre on, so things dont get messy
+ for (int i = 0; i < user->chans.size(); i++)
+ {
+ if (user->chans[i].channel != NULL)
+ {
+ if (user->chans[i].channel->name)
+ {
+ Srv->PartUserFromChannel(user,user->chans[i].channel->name,"Unparking");
+ }
+ }
+ }
+ // remove all their old modes
+ WriteServ(user->fd,"MODE %s -%s",user->nick,user->modes);
+ // now, map them to the parked user, while nobody can see :p
+ Srv->PseudoToUser(user,unpark,"Unparked to "+std::string(parameters[0]));
+ // set all their new modes
+ WriteServ(unpark->fd,"MODE %s +%s",unpark->nick,unpark->modes);
+ // spool their away log to them
+ WriteServ(unpark->fd,"NOTICE %s :*** You are now unparked. You have successfully taken back the nickname and privilages of %s.",unpark->nick,unpark->nick);
+ for (awaylog::iterator i = awy->begin(); i != awy->end(); i++)
{
- pinfo.erase(j);
- break;
+ char timebuf[MAXBUF];
+ tm *timeinfo = localtime(&i->tm);
+ strlcpy(timebuf,asctime(timeinfo),MAXBUF);
+ timebuf[strlen(timebuf)-1] = '\0';
+ WriteServ(unpark->fd,"NOTICE %s :From %s at %s: \2%s\2",unpark->nick,i->from.c_str(),timebuf,i->text.c_str());
+ }
+ delete awy;
+ unpark->Shrink("park_awaylog");
+ unpark->Shrink("park_key");
+ for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
+ {
+ if (j->nick == std::string(unpark->nick))
+ {
+ pinfo.erase(j);
+ break;
+ }
}
}
+ else
+ {
+ Srv->SendServ(user->fd,"928 "+std::string(user->nick)+" :Incorrect park key.");
+ }
}
- else
- {
- Srv->SendServ(user->fd,"928 "+std::string(user->nick)+" :Incorrect park key.");
- }
-}
-
+};
class ModulePark : public Module
{
protected:
ConfigReader* Conf;
+ cmd_park* cmd1;
+ cmd_unpark* cmd2;
+ cmd_parkstats* cmd3;
public:
virtual void ReadSettings()
{
@@ -190,11 +220,14 @@ class ModulePark : public Module
Srv = Me;
pinfo.clear();
this->ReadSettings();
- Srv->AddCommand("PARK",handle_park,0,0,"m_park.so");
- Srv->AddCommand("UNPARK",handle_unpark,0,2,"m_park.so");
- Srv->AddCommand("PARKSTATS",handle_parkstats,'o',0,"m_park.so");
+ cmd1 = new cmd_park();
+ cmd2 = new cmd_unpark();
+ cmd3 = new cmd_parkstats();
+ Srv->AddCommand(cmd1);
+ Srv->AddCommand(cmd2);
+ Srv->AddCommand(cmd3);
}
-
+
virtual ~ModulePark()
{
}
diff --git a/src/modules/m_randquote.cpp b/src/modules/m_randquote.cpp
index f75d3f1aa..73bf9b3b1 100644
--- a/src/modules/m_randquote.cpp
+++ b/src/modules/m_randquote.cpp
@@ -33,33 +33,40 @@ std::string suffix = "";
/* $ModDesc: Provides random Quotes on Connect. */
-void handle_randquote(char** parameters, int pcntl, userrec *user)
+class cmd_randquote : public command_t
{
- std::string str;
- int fsize;
- char buf[MAXBUF];
- if (q_file == "" || quotes->Exists())
+ public:
+ cmd_randquote () : command_t("RANDQUOTE", 0, 0)
{
- fsize = quotes->FileSize();
- str = quotes->GetLine(rand() % fsize);
- sprintf(buf,"NOTICE %s :%s%s%s",user->nick,prefix.c_str(),str.c_str(),suffix.c_str());
- Srv->SendServ(user->fd, buf);
+ this->source = "m_randquote.so";
}
- else
+
+ void Handle (char** parameters, int pcntl, userrec *user)
{
- sprintf(buf, "NOTICE %s :Your administrator specified an invalid quotes file, please bug them about this.", user->nick);
- Srv->SendServ(user->fd, buf);
+ std::string str;
+ int fsize;
+ char buf[MAXBUF];
+ if (q_file == "" || quotes->Exists())
+ {
+ fsize = quotes->FileSize();
+ str = quotes->GetLine(rand() % fsize);
+ sprintf(buf,"NOTICE %s :%s%s%s",user->nick,prefix.c_str(),str.c_str(),suffix.c_str());
+ Srv->SendServ(user->fd, buf);
+ }
+ else
+ {
+ sprintf(buf, "NOTICE %s :Your administrator specified an invalid quotes file, please bug them about this.", user->nick);
+ Srv->SendServ(user->fd, buf);
+ }
+ return;
}
- return;
-}
-
-
+};
class ModuleRandQuote : public Module
{
private:
-
+ cmd_randquote* mycommand;
ConfigReader *conf;
public:
ModuleRandQuote(Server* Me)
@@ -74,6 +81,8 @@ class ModuleRandQuote : public Module
prefix = conf->ReadValue("randquote","prefix",0);
suffix = conf->ReadValue("randquote","suffix",0);
+ mycommand = NULL;
+
if (q_file == "")
{
log(DEFAULT,"m_randquote: Quotefile not specified - Please check your config.");
@@ -86,8 +95,12 @@ class ModuleRandQuote : public Module
log(DEFAULT,"m_randquote: QuoteFile not Found!! Please check your config - module will not function.");
return;
}
- /* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
- else Srv->AddCommand("QUOTE",handle_randquote,0,0,"m_randquote.so");
+ else
+ {
+ /* Hidden Command -- Mode clients assume /quote sends raw data to an IRCd >:D */
+ mycommand = new cmd_randquote();
+ Srv->AddCommand(mycommand);
+ }
}
virtual ~ModuleRandQuote()
@@ -103,11 +116,8 @@ class ModuleRandQuote : public Module
virtual void OnUserConnect(userrec* user)
{
- // Make a fake pointer to be passed to handle_randquote()
- // Dont try this at home kiddies :D
- /* Or do things a slightly nicer way, and pass NULL */
- //char *rar = "RAR";
- handle_randquote(NULL, 0, user);
+ if (mycommand)
+ mycommand->Handle(NULL, 0, user);
}
};
diff --git a/src/users.cpp b/src/users.cpp
index b293e1298..18ec1c318 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -798,7 +798,8 @@ void force_nickchange(userrec* user,const char* newnick)
{
char* pars[1];
pars[0] = nick;
- handle_nick(pars,1,user);
+ std::string cmd = "NICK";
+ ServerInstance->Parser->CallHandler(cmd,pars,1,user);
}
}
}