summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-09-03 00:09:38 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-09-03 00:09:38 +0000
commit1b7c615062a7b203c7fc3ce4c56e16eb671f7c15 (patch)
treee5b6369422834d66285e987cfb152d87d5b56943
parentf5a50a0b6d89ff786c288453d58b7d8f01006954 (diff)
Auto loading of commands as shared objects via dlsym (very lightweight interface, just expects a command_t* pointer)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5118 e03df62e-2008-0410-955e-edbf42e46eb7
-rwxr-xr-xconfigure9
-rw-r--r--include/command_parse.h5
-rw-r--r--include/commands/cmd_nick.h2
-rw-r--r--include/commands/cmd_pass.h2
-rw-r--r--include/commands/cmd_user.h2
-rw-r--r--include/ctables.h10
-rw-r--r--src/cmd_admin.cpp7
-rw-r--r--src/cmd_away.cpp7
-rw-r--r--src/cmd_commands.cpp7
-rw-r--r--src/cmd_connect.cpp7
-rw-r--r--src/cmd_die.cpp7
-rw-r--r--src/cmd_eline.cpp7
-rw-r--r--src/cmd_gline.cpp7
-rw-r--r--src/cmd_info.cpp7
-rw-r--r--src/cmd_invite.cpp7
-rw-r--r--src/cmd_ison.cpp7
-rw-r--r--src/cmd_join.cpp7
-rw-r--r--src/cmd_kick.cpp7
-rw-r--r--src/cmd_kill.cpp7
-rw-r--r--src/cmd_kline.cpp7
-rw-r--r--src/cmd_links.cpp7
-rw-r--r--src/cmd_list.cpp7
-rw-r--r--src/cmd_loadmodule.cpp7
-rw-r--r--src/cmd_lusers.cpp7
-rw-r--r--src/cmd_map.cpp7
-rw-r--r--src/cmd_modules.cpp7
-rw-r--r--src/cmd_motd.cpp7
-rw-r--r--src/cmd_names.cpp7
-rw-r--r--src/cmd_nick.cpp7
-rw-r--r--src/cmd_notice.cpp7
-rw-r--r--src/cmd_oper.cpp7
-rw-r--r--src/cmd_part.cpp7
-rw-r--r--src/cmd_pass.cpp7
-rw-r--r--src/cmd_ping.cpp7
-rw-r--r--src/cmd_pong.cpp7
-rw-r--r--src/cmd_privmsg.cpp7
-rw-r--r--src/cmd_qline.cpp7
-rw-r--r--src/cmd_quit.cpp7
-rw-r--r--src/cmd_rehash.cpp7
-rw-r--r--src/cmd_restart.cpp7
-rw-r--r--src/cmd_rules.cpp7
-rw-r--r--src/cmd_server.cpp7
-rw-r--r--src/cmd_squit.cpp7
-rw-r--r--src/cmd_stats.cpp7
-rw-r--r--src/cmd_summon.cpp7
-rw-r--r--src/cmd_time.cpp7
-rw-r--r--src/cmd_topic.cpp7
-rw-r--r--src/cmd_trace.cpp7
-rw-r--r--src/cmd_unloadmodule.cpp7
-rw-r--r--src/cmd_user.cpp7
-rw-r--r--src/cmd_userhost.cpp7
-rw-r--r--src/cmd_users.cpp7
-rw-r--r--src/cmd_version.cpp7
-rw-r--r--src/cmd_wallops.cpp7
-rw-r--r--src/cmd_who.cpp7
-rw-r--r--src/cmd_whois.cpp7
-rw-r--r--src/cmd_whowas.cpp7
-rw-r--r--src/cmd_zline.cpp7
-rw-r--r--src/command_parse.cpp184
59 files changed, 434 insertions, 144 deletions
diff --git a/configure b/configure
index 6017ae379..0d35e6729 100755
--- a/configure
+++ b/configure
@@ -1013,6 +1013,7 @@ sub writefiles {
#define MAXGECOS $config{MAX_GECOS}
#define MAXAWAY $config{MAX_AWAY}
#define OPTIMISATION $config{OPTIMITEMP}
+#define LIBRARYDIR "$config{LIBRARY_DIR}"
#define SYSTEM "$incos"
#define MAXBUF 514
EOF
@@ -1573,8 +1574,8 @@ RELCPPFILES = \$(shell /bin/ls -l modes/ | grep '\\.cpp' | sed 's/^.* /modes\\//
all: libIRCDtimer.so libIRCDaes.so libIRCDcull_list.so libIRCDuserprocess.so libIRCDsocketengine.so libIRCDsocket.so libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so $cmdobjs libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDcommand_parse.so libIRCDsnomasks.so inspircd
-inspircd: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h ../include/socket.h libIRCDtimer.so libIRCDaes.so libIRCDcull_list.so libIRCDuserprocess.so libIRCDsocketengine.so libIRCDsocket.so libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so $cmdobjs libIRCDsnomasks.so libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDcommand_parse.so $cmdobjs
- \$(CC) -I../include $extra -Wl,--rpath -Wl,/usr/local/lib -Wl,--rpath -Wl,$config{LIBRARY_DIR} \$(FLAGS) -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDhash.so libIRCDsocket.so libIRCDsocketengine.so libIRCDuserprocess.so libIRCDcull_list.so libIRCDcommand_parse.so libIRCDaes.so libIRCDtimer.so libIRCDsnomasks.so $cmdobjs
+inspircd: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h ../include/socket.h libIRCDtimer.so libIRCDaes.so libIRCDcull_list.so libIRCDuserprocess.so libIRCDsocketengine.so libIRCDsocket.so libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so $cmdobjs libIRCDsnomasks.so libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDcommand_parse.so
+ \$(CC) -I../include $extra -Wl,--rpath -Wl,/usr/local/lib -Wl,--rpath -Wl,$config{LIBRARY_DIR} \$(FLAGS) -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDconfigreader.so libIRCDinspsocket.so libIRCDcommands.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDhelper.so libIRCDhash.so libIRCDsocket.so libIRCDsocketengine.so libIRCDuserprocess.so libIRCDcull_list.so libIRCDcommand_parse.so libIRCDaes.so libIRCDtimer.so libIRCDsnomasks.so
libIRCDsocketengine.so: $se.cpp socketengine.cpp ../include/base.h ../include/hashcomp.h ../include/globals.h ../include/inspircd_config.h ../include/$se.h
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socketengine.cpp $se.cpp
@@ -1633,9 +1634,9 @@ libIRCDconfigreader.so: configreader.cpp ../include/base.h ../include/configread
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c configreader.cpp
\$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDconfigreader.so configreader.o
-libIRCDcommands.so: commands.cpp ../include/base.h ../include/commands.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h $cmdobjs
+libIRCDcommands.so: commands.cpp ../include/base.h ../include/commands.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c commands.cpp
- \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDcommands.so commands.o $cmdobjs
+ \$(CC) -Wl,--rpath -Wl,$config{LIBRARY_DIR} -shared -o libIRCDcommands.so commands.o
libIRCDdynamic.so: dynamic.cpp ../include/base.h ../include/dynamic.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c dynamic.cpp
diff --git a/include/command_parse.h b/include/command_parse.h
index 908add7dd..d4c64dab4 100644
--- a/include/command_parse.h
+++ b/include/command_parse.h
@@ -52,11 +52,16 @@ class CommandParser : public classbase
/** Insert the default RFC1459 commands into the command hash.
*/
void SetupCommandTable();
+
+ void FindSym(void** v, void* h);
+
public:
/** Command list, a hash_map of command names to command_t*
*/
command_table cmdlist;
+ void LoadCommand(const char* name);
+
/** Default constructor.
* @param Instance The creator of this class
*/
diff --git a/include/commands/cmd_nick.h b/include/commands/cmd_nick.h
index 1924ce1e8..f63a6195c 100644
--- a/include/commands/cmd_nick.h
+++ b/include/commands/cmd_nick.h
@@ -25,7 +25,7 @@
class cmd_nick : public command_t
{
public:
- cmd_nick (InspIRCd* Instance) : command_t(Instance,"NICK",0,1) { syntax = "<newnick>"; }
+ cmd_nick (InspIRCd* Instance) : command_t(Instance,"NICK",0,1,true) { syntax = "<newnick>"; }
void Handle(const char** parameters, int pcnt, userrec *user);
};
diff --git a/include/commands/cmd_pass.h b/include/commands/cmd_pass.h
index 6cc48d423..922f12c02 100644
--- a/include/commands/cmd_pass.h
+++ b/include/commands/cmd_pass.h
@@ -28,7 +28,7 @@
class cmd_pass : public command_t
{
public:
- cmd_pass (InspIRCd* Instance) : command_t(Instance,"PASS",0,1) { syntax = "<password>"; }
+ cmd_pass (InspIRCd* Instance) : command_t(Instance,"PASS",0,1,true) { syntax = "<password>"; }
void Handle(const char** parameters, int pcnt, userrec *user);
};
diff --git a/include/commands/cmd_user.h b/include/commands/cmd_user.h
index 919078193..ac8a1a6c4 100644
--- a/include/commands/cmd_user.h
+++ b/include/commands/cmd_user.h
@@ -25,7 +25,7 @@
class cmd_user : public command_t
{
public:
- cmd_user (InspIRCd* Instance) : command_t(Instance,"USER",0,4) { syntax = "<username> <localhost> <remotehost> <GECOS>"; }
+ cmd_user (InspIRCd* Instance) : command_t(Instance,"USER",0,4,true) { syntax = "<username> <localhost> <remotehost> <GECOS>"; }
void Handle(const char** parameters, int pcnt, userrec *user);
};
diff --git a/include/ctables.h b/include/ctables.h
index c997cf68a..870efadac 100644
--- a/include/ctables.h
+++ b/include/ctables.h
@@ -55,12 +55,15 @@ class command_t : public Extensible
/** True if the command is disabled to non-opers
*/
bool disabled;
+ /** True if the command can be issued before registering
+ */
+ bool works_before_reg;
/** Syntax string for the command, displayed if non-empty string.
* This takes place of the text in the 'not enough parameters' numeric.
*/
std::string syntax;
- command_t(InspIRCd* Instance, const std::string &cmd, char flags, int minpara) : ServerInstance(Instance), command(cmd), flags_needed(flags), min_params(minpara), disabled(false)
+ command_t(InspIRCd* Instance, const std::string &cmd, char flags, int minpara, int before_reg = false) : ServerInstance(Instance), command(cmd), flags_needed(flags), min_params(minpara), disabled(false), works_before_reg(before_reg)
{
use_count = total_bytes = 0;
source = "<core>";
@@ -79,6 +82,11 @@ class command_t : public Extensible
return disabled;
}
+ bool WorksBeforeReg()
+ {
+ return works_before_reg;
+ }
+
virtual ~command_t() {}
};
diff --git a/src/cmd_admin.cpp b/src/cmd_admin.cpp
index 3db1457e4..86072a5ed 100644
--- a/src/cmd_admin.cpp
+++ b/src/cmd_admin.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_admin.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_admin(Instance);
+}
+
void cmd_admin::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ("256 %s :Administrative info for %s",user->nick,ServerInstance->Config->ServerName);
diff --git a/src/cmd_away.cpp b/src/cmd_away.cpp
index 6746cf5e2..fa944932f 100644
--- a/src/cmd_away.cpp
+++ b/src/cmd_away.cpp
@@ -19,6 +19,13 @@
#include "modules.h"
#include "commands/cmd_away.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_away(Instance);
+}
+
void cmd_away::Handle (const char** parameters, int pcnt, userrec *user)
{
if ((pcnt) && (*parameters[0]))
diff --git a/src/cmd_commands.cpp b/src/cmd_commands.cpp
index bd4f0db65..6ffd0c469 100644
--- a/src/cmd_commands.cpp
+++ b/src/cmd_commands.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_commands.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_commands(Instance);
+}
+
void cmd_commands::Handle (const char** parameters, int pcnt, userrec *user)
{
for (nspace::hash_map<std::string,command_t*>::iterator i = ServerInstance->Parser->cmdlist.begin(); i != ServerInstance->Parser->cmdlist.end(); i++)
diff --git a/src/cmd_connect.cpp b/src/cmd_connect.cpp
index 5e33316a8..cf885c5bb 100644
--- a/src/cmd_connect.cpp
+++ b/src/cmd_connect.cpp
@@ -20,6 +20,13 @@
/*
* This is handled by the server linking module, if necessary. Do not remove this stub.
*/
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_connect(Instance);
+}
+
void cmd_connect::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ( "NOTICE %s :You are a nub. Load a linking module.", user->nick);
diff --git a/src/cmd_die.cpp b/src/cmd_die.cpp
index 353c8ccd6..fc2cc473e 100644
--- a/src/cmd_die.cpp
+++ b/src/cmd_die.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_die.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_die(Instance);
+}
+
void cmd_die::Handle (const char** parameters, int pcnt, userrec *user)
{
if (!strcmp(parameters[0],ServerInstance->Config->diepass))
diff --git a/src/cmd_eline.cpp b/src/cmd_eline.cpp
index be49fe714..971649989 100644
--- a/src/cmd_eline.cpp
+++ b/src/cmd_eline.cpp
@@ -20,6 +20,13 @@
#include "xline.h"
#include "commands/cmd_eline.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_eline(Instance);
+}
+
void cmd_eline::Handle (const char** parameters, int pcnt, userrec *user)
{
if (pcnt >= 3)
diff --git a/src/cmd_gline.cpp b/src/cmd_gline.cpp
index c2921d64d..2d14fff22 100644
--- a/src/cmd_gline.cpp
+++ b/src/cmd_gline.cpp
@@ -20,6 +20,13 @@
#include "xline.h"
#include "commands/cmd_gline.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_gline(Instance);
+}
+
void cmd_gline::Handle (const char** parameters, int pcnt, userrec *user)
{
if (pcnt >= 3)
diff --git a/src/cmd_info.cpp b/src/cmd_info.cpp
index b3253daef..ce6358fd0 100644
--- a/src/cmd_info.cpp
+++ b/src/cmd_info.cpp
@@ -19,6 +19,13 @@
#include "modules.h"
#include "commands/cmd_info.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_info(Instance);
+}
+
void cmd_info::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ( "371 %s :. o O (The Inspire Internet Relay Chat Server) O o .", user->nick);
diff --git a/src/cmd_invite.cpp b/src/cmd_invite.cpp
index 9c5abacde..306823b8b 100644
--- a/src/cmd_invite.cpp
+++ b/src/cmd_invite.cpp
@@ -19,6 +19,13 @@
#include "modules.h"
#include "commands/cmd_invite.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_invite(Instance);
+}
+
void cmd_invite::Handle (const char** parameters, int pcnt, userrec *user)
{
int MOD_RESULT = 0;
diff --git a/src/cmd_ison.cpp b/src/cmd_ison.cpp
index cf60b6f6b..bd5fdac9f 100644
--- a/src/cmd_ison.cpp
+++ b/src/cmd_ison.cpp
@@ -18,6 +18,13 @@
#include "inspircd.h"
#include "commands/cmd_ison.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_ison(Instance);
+}
+
void cmd_ison::Handle (const char** parameters, int pcnt, userrec *user)
{
char retbuf[MAXBUF];
diff --git a/src/cmd_join.cpp b/src/cmd_join.cpp
index 25fb558f1..ee2131482 100644
--- a/src/cmd_join.cpp
+++ b/src/cmd_join.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_join.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_join(Instance);
+}
+
void cmd_join::Handle (const char** parameters, int pcnt, userrec *user)
{
if (pcnt > 1)
diff --git a/src/cmd_kick.cpp b/src/cmd_kick.cpp
index 8c0b83498..fd098c468 100644
--- a/src/cmd_kick.cpp
+++ b/src/cmd_kick.cpp
@@ -18,6 +18,13 @@
#include "inspircd.h"
#include "commands/cmd_kick.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_kick(Instance);
+}
+
void cmd_kick::Handle (const char** parameters, int pcnt, userrec *user)
{
char reason[MAXKICK];
diff --git a/src/cmd_kill.cpp b/src/cmd_kill.cpp
index fa294ad9e..91dbca8bd 100644
--- a/src/cmd_kill.cpp
+++ b/src/cmd_kill.cpp
@@ -19,6 +19,13 @@
#include "modules.h"
#include "commands/cmd_kill.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_kill(Instance);
+}
+
void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
{
userrec *u = ServerInstance->FindNick(parameters[0]);
diff --git a/src/cmd_kline.cpp b/src/cmd_kline.cpp
index eb83cfbf4..105c8c3c2 100644
--- a/src/cmd_kline.cpp
+++ b/src/cmd_kline.cpp
@@ -20,6 +20,13 @@
#include "xline.h"
#include "commands/cmd_kline.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_kline(Instance);
+}
+
void cmd_kline::Handle (const char** parameters, int pcnt, userrec *user)
{
if (pcnt >= 3)
diff --git a/src/cmd_links.cpp b/src/cmd_links.cpp
index d1312fbe0..46c35ca53 100644
--- a/src/cmd_links.cpp
+++ b/src/cmd_links.cpp
@@ -19,6 +19,13 @@
#include "modules.h"
#include "commands/cmd_links.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_links(Instance);
+}
+
void cmd_links::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ("364 %s %s %s :0 %s",user->nick,ServerInstance->Config->ServerName,ServerInstance->Config->ServerName,ServerInstance->Config->ServerDesc);
diff --git a/src/cmd_list.cpp b/src/cmd_list.cpp
index 066c80611..f281ce195 100644
--- a/src/cmd_list.cpp
+++ b/src/cmd_list.cpp
@@ -19,6 +19,13 @@
#include "commands/cmd_list.h"
#include "wildcard.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_list(Instance);
+}
+
void cmd_list::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ("321 %s Channel :Users Name",user->nick);
diff --git a/src/cmd_loadmodule.cpp b/src/cmd_loadmodule.cpp
index b2bf2c72f..2f1dc75d3 100644
--- a/src/cmd_loadmodule.cpp
+++ b/src/cmd_loadmodule.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_loadmodule.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_loadmodule(Instance);
+}
+
void cmd_loadmodule::Handle (const char** parameters, int pcnt, userrec *user)
{
if (ServerInstance->LoadModule(parameters[0]))
diff --git a/src/cmd_lusers.cpp b/src/cmd_lusers.cpp
index 69ec7494f..23b8754e0 100644
--- a/src/cmd_lusers.cpp
+++ b/src/cmd_lusers.cpp
@@ -18,6 +18,13 @@
#include "inspircd.h"
#include "commands/cmd_lusers.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_lusers(Instance);
+}
+
void cmd_lusers::Handle (const char** parameters, int pcnt, userrec *user)
{
// this lusers command shows one server at all times because
diff --git a/src/cmd_map.cpp b/src/cmd_map.cpp
index b8873b6c1..702038aa0 100644
--- a/src/cmd_map.cpp
+++ b/src/cmd_map.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_map.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_map(Instance);
+}
+
void cmd_map::Handle (const char** parameters, int pcnt, userrec *user)
{
// as with /LUSERS this does nothing without a linking
diff --git a/src/cmd_modules.cpp b/src/cmd_modules.cpp
index 8b1f2ac3f..e1a5b6d4b 100644
--- a/src/cmd_modules.cpp
+++ b/src/cmd_modules.cpp
@@ -36,6 +36,13 @@ char* itab[] = {
"OnOperCompare", "OnChannelDelete", "OnPostOper", "OnSyncOtherMetaData", "OnSetAway", "OnCancelAway", "OnNamesList", NULL
};
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_modules(Instance);
+}
+
void cmd_modules::Handle (const char** parameters, int pcnt, userrec *user)
{
for (unsigned int i = 0; i < ServerInstance->Config->module_names.size(); i++)
diff --git a/src/cmd_motd.cpp b/src/cmd_motd.cpp
index 5c47f3541..04542db17 100644
--- a/src/cmd_motd.cpp
+++ b/src/cmd_motd.cpp
@@ -17,6 +17,13 @@
#include "users.h"
#include "commands/cmd_motd.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_motd(Instance);
+}
+
void cmd_motd::Handle (const char** parameters, int pcnt, userrec *user)
{
user->ShowMOTD();
diff --git a/src/cmd_names.cpp b/src/cmd_names.cpp
index ac8e18270..e419c4172 100644
--- a/src/cmd_names.cpp
+++ b/src/cmd_names.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_names.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_names(Instance);
+}
+
void cmd_names::Handle (const char** parameters, int pcnt, userrec *user)
{
chanrec* c;
diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp
index d15c49367..e6e2a98bc 100644
--- a/src/cmd_nick.cpp
+++ b/src/cmd_nick.cpp
@@ -21,6 +21,13 @@
#include "xline.h"
#include "commands/cmd_nick.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_nick(Instance);
+}
+
void cmd_nick::Handle (const char** parameters, int pcnt, userrec *user)
{
char oldnick[NICKMAX];
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index 394346a44..7cd53aa3d 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -20,6 +20,13 @@
#include "wildcard.h"
#include "commands/cmd_notice.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_notice(Instance);
+}
+
void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
{
userrec *dest;
diff --git a/src/cmd_oper.cpp b/src/cmd_oper.cpp
index bf81ee19e..7db6627e9 100644
--- a/src/cmd_oper.cpp
+++ b/src/cmd_oper.cpp
@@ -35,6 +35,13 @@ bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
return false;
}
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_oper(Instance);
+}
+
void cmd_oper::Handle (const char** parameters, int pcnt, userrec *user)
{
char LoginName[MAXBUF];
diff --git a/src/cmd_part.cpp b/src/cmd_part.cpp
index c77dbe5eb..9fd01d058 100644
--- a/src/cmd_part.cpp
+++ b/src/cmd_part.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_part.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_part(Instance);
+}
+
void cmd_part::Handle (const char** parameters, int pcnt, userrec *user)
{
if (ServerInstance->Parser->LoopCall(user, this, parameters, pcnt, 0))
diff --git a/src/cmd_pass.cpp b/src/cmd_pass.cpp
index ed34dbb85..e761f8d42 100644
--- a/src/cmd_pass.cpp
+++ b/src/cmd_pass.cpp
@@ -17,6 +17,13 @@
#include "users.h"
#include "commands/cmd_pass.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_pass(Instance);
+}
+
void cmd_pass::Handle (const char** parameters, int pcnt, userrec *user)
{
// Check to make sure they havnt registered -- Fix by FCS
diff --git a/src/cmd_ping.cpp b/src/cmd_ping.cpp
index 8c8a6a992..9ecec693c 100644
--- a/src/cmd_ping.cpp
+++ b/src/cmd_ping.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_ping.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_ping(Instance);
+}
+
void cmd_ping::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ("PONG %s :%s",ServerInstance->Config->ServerName,parameters[0]);
diff --git a/src/cmd_pong.cpp b/src/cmd_pong.cpp
index 5317ad5b3..9a388c021 100644
--- a/src/cmd_pong.cpp
+++ b/src/cmd_pong.cpp
@@ -17,6 +17,13 @@
#include "users.h"
#include "commands/cmd_pong.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_pong(Instance);
+}
+
void cmd_pong::Handle (const char** parameters, int pcnt, userrec *user)
{
// set the user as alive so they survive to next ping
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
index 5078c8a4a..e387b6ae3 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -21,6 +21,13 @@
#include "wildcard.h"
#include "commands/cmd_privmsg.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_privmsg(Instance);
+}
+
void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user)
{
userrec *dest;
diff --git a/src/cmd_qline.cpp b/src/cmd_qline.cpp
index e1bec6ddc..68e315822 100644
--- a/src/cmd_qline.cpp
+++ b/src/cmd_qline.cpp
@@ -20,6 +20,13 @@
#include "xline.h"
#include "commands/cmd_qline.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_qline(Instance);
+}
+
void cmd_qline::Handle (const char** parameters, int pcnt, userrec *user)
{
if (pcnt >= 3)
diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp
index 37d6147c4..102d9adc5 100644
--- a/src/cmd_quit.cpp
+++ b/src/cmd_quit.cpp
@@ -20,6 +20,13 @@
#include "modules.h"
#include "commands/cmd_quit.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_quit(Instance);
+}
+
void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
{
user_hash::iterator iter = ServerInstance->clientlist.find(user->nick);
diff --git a/src/cmd_rehash.cpp b/src/cmd_rehash.cpp
index f7017da4e..c4ee2f94f 100644
--- a/src/cmd_rehash.cpp
+++ b/src/cmd_rehash.cpp
@@ -19,6 +19,13 @@
#include "modules.h"
#include "commands/cmd_rehash.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_rehash(Instance);
+}
+
void cmd_rehash::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ("382 %s %s :Rehashing",user->nick,ServerConfig::CleanFilename(CONFIG_FILE));
diff --git a/src/cmd_restart.cpp b/src/cmd_restart.cpp
index c159b8b0c..18f8d2fc9 100644
--- a/src/cmd_restart.cpp
+++ b/src/cmd_restart.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_restart.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_restart(Instance);
+}
+
void cmd_restart::Handle (const char** parameters, int pcnt, userrec *user)
{
char *argv[32];
diff --git a/src/cmd_rules.cpp b/src/cmd_rules.cpp
index 38a815837..e08b7c775 100644
--- a/src/cmd_rules.cpp
+++ b/src/cmd_rules.cpp
@@ -17,6 +17,13 @@
#include "users.h"
#include "commands/cmd_rules.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_rules(Instance);
+}
+
void cmd_rules::Handle (const char** parameters, int pcnt, userrec *user)
{
user->ShowRULES();
diff --git a/src/cmd_server.cpp b/src/cmd_server.cpp
index 691780b2f..b1f9a89d8 100644
--- a/src/cmd_server.cpp
+++ b/src/cmd_server.cpp
@@ -18,6 +18,13 @@
#include "inspircd.h"
#include "commands/cmd_server.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_server(Instance);
+}
+
void cmd_server::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ("666 %s :You cannot identify as a server, you are a USER. IRC Operators informed.",user->nick);
diff --git a/src/cmd_squit.cpp b/src/cmd_squit.cpp
index f6d334028..facfcf694 100644
--- a/src/cmd_squit.cpp
+++ b/src/cmd_squit.cpp
@@ -20,6 +20,13 @@
/*
* This is handled by the server linking module, if necessary. Do not remove this stub.
*/
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_squit(Instance);
+}
+
void cmd_squit::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ( "NOTICE %s :You are a nub. Load a linking module.", user->nick);
diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp
index 9335ea09b..44755451d 100644
--- a/src/cmd_stats.cpp
+++ b/src/cmd_stats.cpp
@@ -22,6 +22,13 @@
#include "xline.h"
#include "commands/cmd_stats.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_stats(Instance);
+}
+
void cmd_stats::Handle (const char** parameters, int pcnt, userrec *user)
{
string_list values;
diff --git a/src/cmd_summon.cpp b/src/cmd_summon.cpp
index 4a95d15ca..968d62767 100644
--- a/src/cmd_summon.cpp
+++ b/src/cmd_summon.cpp
@@ -17,6 +17,13 @@
#include "users.h"
#include "commands/cmd_summon.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_summon(Instance);
+}
+
void cmd_summon::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ("445 %s :SUMMON has been disabled (depreciated command)",user->nick);
diff --git a/src/cmd_time.cpp b/src/cmd_time.cpp
index 9fb9cf702..04005a9a7 100644
--- a/src/cmd_time.cpp
+++ b/src/cmd_time.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_time.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_time(Instance);
+}
+
void cmd_time::Handle (const char** parameters, int pcnt, userrec *user)
{
struct tm* timeinfo;
diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp
index 07498a1b3..b97821434 100644
--- a/src/cmd_topic.cpp
+++ b/src/cmd_topic.cpp
@@ -19,6 +19,13 @@
#include "modules.h"
#include "commands/cmd_topic.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_topic(Instance);
+}
+
void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
{
chanrec* Ptr;
diff --git a/src/cmd_trace.cpp b/src/cmd_trace.cpp
index d1bbd0e6f..7332f4631 100644
--- a/src/cmd_trace.cpp
+++ b/src/cmd_trace.cpp
@@ -18,6 +18,13 @@
#include "inspircd.h"
#include "commands/cmd_trace.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_trace(Instance);
+}
+
void cmd_trace::Handle (const char** parameters, int pcnt, userrec *user)
{
for (user_hash::iterator i = ServerInstance->clientlist.begin(); i != ServerInstance->clientlist.end(); i++)
diff --git a/src/cmd_unloadmodule.cpp b/src/cmd_unloadmodule.cpp
index 88600ada9..1bb99014b 100644
--- a/src/cmd_unloadmodule.cpp
+++ b/src/cmd_unloadmodule.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_unloadmodule.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_unloadmodule(Instance);
+}
+
void cmd_unloadmodule::Handle (const char** parameters, int pcnt, userrec *user)
{
if (ServerInstance->UnloadModule(parameters[0]))
diff --git a/src/cmd_user.cpp b/src/cmd_user.cpp
index 12a29f3bd..13e42f043 100644
--- a/src/cmd_user.cpp
+++ b/src/cmd_user.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_user.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_user(Instance);
+}
+
void cmd_user::Handle (const char** parameters, int pcnt, userrec *user)
{
if (user->registered < REG_NICKUSER)
diff --git a/src/cmd_userhost.cpp b/src/cmd_userhost.cpp
index 4c94dcb90..c124b24d3 100644
--- a/src/cmd_userhost.cpp
+++ b/src/cmd_userhost.cpp
@@ -18,6 +18,13 @@
#include "inspircd.h"
#include "commands/cmd_userhost.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_userhost(Instance);
+}
+
void cmd_userhost::Handle (const char** parameters, int pcnt, userrec *user)
{
char Return[MAXBUF],junk[MAXBUF];
diff --git a/src/cmd_users.cpp b/src/cmd_users.cpp
index 50db9e473..43f5c2105 100644
--- a/src/cmd_users.cpp
+++ b/src/cmd_users.cpp
@@ -17,6 +17,13 @@
#include "users.h"
#include "commands/cmd_users.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_users(Instance);
+}
+
void cmd_users::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteServ("445 %s :USERS has been disabled (depreciated command)",user->nick);
diff --git a/src/cmd_version.cpp b/src/cmd_version.cpp
index c050121a4..5e1db8c2e 100644
--- a/src/cmd_version.cpp
+++ b/src/cmd_version.cpp
@@ -19,6 +19,13 @@
#include "users.h"
#include "commands/cmd_version.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_version(Instance);
+}
+
void cmd_version::Handle (const char** parameters, int pcnt, userrec *user)
{
std::stringstream out(ServerInstance->Config->data005);
diff --git a/src/cmd_wallops.cpp b/src/cmd_wallops.cpp
index d47d7ae77..93256ec64 100644
--- a/src/cmd_wallops.cpp
+++ b/src/cmd_wallops.cpp
@@ -18,6 +18,13 @@
#include "modules.h"
#include "commands/cmd_wallops.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_wallops(Instance);
+}
+
void cmd_wallops::Handle (const char** parameters, int pcnt, userrec *user)
{
user->WriteWallOps(std::string(parameters[0]));
diff --git a/src/cmd_who.cpp b/src/cmd_who.cpp
index 5ab54dc02..e48e013ec 100644
--- a/src/cmd_who.cpp
+++ b/src/cmd_who.cpp
@@ -54,6 +54,13 @@ bool whomatch(userrec* user, const char* matchtext, bool opt_realname, bool opt_
return ((realname) || (realhost) || (match(user->dhost, matchtext)) || (match(user->nick, matchtext)) || (match(user->server, matchtext)));
}
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_who(Instance);
+}
+
void cmd_who::Handle (const char** parameters, int pcnt, userrec *user)
{
/*
diff --git a/src/cmd_whois.cpp b/src/cmd_whois.cpp
index 3e8406dd1..a9577f168 100644
--- a/src/cmd_whois.cpp
+++ b/src/cmd_whois.cpp
@@ -91,6 +91,13 @@ void do_whois(InspIRCd* ServerInstance, userrec* user, userrec* dest,unsigned lo
}
}
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_whois(Instance);
+}
+
void cmd_whois::Handle (const char** parameters, int pcnt, userrec *user)
{
userrec *dest;
diff --git a/src/cmd_whowas.cpp b/src/cmd_whowas.cpp
index ba2c6460d..4f0cfdc21 100644
--- a/src/cmd_whowas.cpp
+++ b/src/cmd_whowas.cpp
@@ -18,6 +18,13 @@
#include "users.h"
#include "commands/cmd_whowas.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_whowas(Instance);
+}
+
void cmd_whowas::Handle (const char** parameters, int pcnt, userrec* user)
{
irc::whowas::whowas_users::iterator i = ServerInstance->whowas.find(parameters[0]);
diff --git a/src/cmd_zline.cpp b/src/cmd_zline.cpp
index 0a87a030b..183fec5d5 100644
--- a/src/cmd_zline.cpp
+++ b/src/cmd_zline.cpp
@@ -21,6 +21,13 @@
#include "xline.h"
#include "commands/cmd_zline.h"
+
+
+extern "C" command_t* init_command(InspIRCd* Instance)
+{
+ return new cmd_zline(Instance);
+}
+
void cmd_zline::Handle (const char** parameters, int pcnt, userrec *user)
{
if (pcnt >= 3)
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 7febff972..13ba64169 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -17,6 +17,8 @@
#include "inspircd.h"
#include "configreader.h"
#include <algorithm>
+#include <dirent.h>
+#include <dlfcn.h>
#include "users.h"
#include "modules.h"
#include "wildcard.h"
@@ -25,68 +27,6 @@
#include "userprocess.h"
#include "socket.h"
#include "command_parse.h"
-#define nspace __gnu_cxx
-
-/* XXX Serious WTFness XXX
- *
- * Well, unless someone invents a wildcard or
- * regexp #include, and makes it a standard,
- * we're stuck with this way of including all
- * the commands.
- */
-
-#include "commands/cmd_admin.h"
-#include "commands/cmd_away.h"
-#include "commands/cmd_commands.h"
-#include "commands/cmd_connect.h"
-#include "commands/cmd_die.h"
-#include "commands/cmd_eline.h"
-#include "commands/cmd_gline.h"
-#include "commands/cmd_info.h"
-#include "commands/cmd_invite.h"
-#include "commands/cmd_ison.h"
-#include "commands/cmd_join.h"
-#include "commands/cmd_kick.h"
-#include "commands/cmd_kill.h"
-#include "commands/cmd_kline.h"
-#include "commands/cmd_links.h"
-#include "commands/cmd_list.h"
-#include "commands/cmd_loadmodule.h"
-#include "commands/cmd_lusers.h"
-#include "commands/cmd_map.h"
-#include "commands/cmd_modules.h"
-#include "commands/cmd_motd.h"
-#include "commands/cmd_names.h"
-#include "commands/cmd_nick.h"
-#include "commands/cmd_notice.h"
-#include "commands/cmd_oper.h"
-#include "commands/cmd_part.h"
-#include "commands/cmd_pass.h"
-#include "commands/cmd_ping.h"
-#include "commands/cmd_pong.h"
-#include "commands/cmd_privmsg.h"
-#include "commands/cmd_qline.h"
-#include "commands/cmd_quit.h"
-#include "commands/cmd_rehash.h"
-#include "commands/cmd_restart.h"
-#include "commands/cmd_rules.h"
-#include "commands/cmd_server.h"
-#include "commands/cmd_squit.h"
-#include "commands/cmd_stats.h"
-#include "commands/cmd_summon.h"
-#include "commands/cmd_time.h"
-#include "commands/cmd_topic.h"
-#include "commands/cmd_trace.h"
-#include "commands/cmd_unloadmodule.h"
-#include "commands/cmd_user.h"
-#include "commands/cmd_userhost.h"
-#include "commands/cmd_users.h"
-#include "commands/cmd_version.h"
-#include "commands/cmd_wallops.h"
-#include "commands/cmd_who.h"
-#include "commands/cmd_whois.h"
-#include "commands/cmd_whowas.h"
-#include "commands/cmd_zline.h"
bool InspIRCd::ULine(const char* server)
{
@@ -253,16 +193,6 @@ bool InspIRCd::NickMatchesEveryone(const std::string &nick, userrec* user)
return false;
}
-
-
-
-
-/* Special commands which may occur without registration of the user */
-cmd_user* command_user;
-cmd_nick* command_nick;
-cmd_pass* command_pass;
-
-
/* LoopCall is used to call a command classes handler repeatedly based on the contents of a comma seperated list.
* There are two overriden versions of this method, one of which takes two potential lists and the other takes one.
* We need a version which takes two potential lists for JOIN, because a JOIN may contain two lists of items at once,
@@ -437,7 +367,7 @@ void CommandParser::ProcessCommand(userrec *user, std::string &cmd)
user->WriteServ("304 %s :SYNTAX %s %s", user->nick, cm->second->command.c_str(), cm->second->syntax.c_str());
return;
}
- if ((user->registered == REG_ALL) || (cm->second == command_user) || (cm->second == command_nick) || (cm->second == command_pass))
+ if ((user->registered == REG_ALL) || (cm->second->WorksBeforeReg()))
{
/* ikky /stats counters */
cm->second->use_count++;
@@ -531,70 +461,52 @@ CommandParser::CommandParser(InspIRCd* Instance) : ServerInstance(Instance)
this->SetupCommandTable();
}
+void CommandParser::FindSym(void** v, void* h)
+{
+ *v = dlsym(h, "init_command");
+ const char* err = dlerror();
+ if (err)
+ {
+ printf("ERROR: %s\n",err);
+ exit(0);
+ }
+}
+
+void CommandParser::LoadCommand(const char* name)
+{
+ char filename[MAXBUF];
+ void* h;
+ command_t* (*cmd_factory_func)(InspIRCd*);
+
+ snprintf(filename, MAXBUF, "%s/%s", LIBRARYDIR, name);
+ ServerInstance->Log(DEBUG,"Load command: %s", filename);
+
+ h = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
+
+ if (!h)
+ return;
+
+ this->FindSym((void **)&cmd_factory_func, h);
+
+ command_t* newcommand = cmd_factory_func(ServerInstance);
+
+ this->CreateCommand(newcommand);
+}
+
void CommandParser::SetupCommandTable()
{
- /* These three are special (can occur without
- * full user registration) and so are saved
- * for later use.
- */
- command_user = new cmd_user(ServerInstance);
- command_nick = new cmd_nick(ServerInstance);
- command_pass = new cmd_pass(ServerInstance);
- this->CreateCommand(command_user);
- this->CreateCommand(command_nick);
- this->CreateCommand(command_pass);
-
- /* The rest of these arent special. boo hoo.
- */
- this->CreateCommand(new cmd_quit(ServerInstance));
- this->CreateCommand(new cmd_version(ServerInstance));
- this->CreateCommand(new cmd_ping(ServerInstance));
- this->CreateCommand(new cmd_pong(ServerInstance));
- this->CreateCommand(new cmd_admin(ServerInstance));
- this->CreateCommand(new cmd_privmsg(ServerInstance));
- this->CreateCommand(new cmd_info(ServerInstance));
- this->CreateCommand(new cmd_time(ServerInstance));
- this->CreateCommand(new cmd_whois(ServerInstance));
- this->CreateCommand(new cmd_wallops(ServerInstance));
- this->CreateCommand(new cmd_notice(ServerInstance));
- this->CreateCommand(new cmd_join(ServerInstance));
- this->CreateCommand(new cmd_names(ServerInstance));
- this->CreateCommand(new cmd_part(ServerInstance));
- this->CreateCommand(new cmd_kick(ServerInstance));
- this->CreateCommand(new cmd_mode(ServerInstance));
- this->CreateCommand(new cmd_topic(ServerInstance));
- this->CreateCommand(new cmd_who(ServerInstance));
- this->CreateCommand(new cmd_motd(ServerInstance));
- this->CreateCommand(new cmd_rules(ServerInstance));
- this->CreateCommand(new cmd_oper(ServerInstance));
- this->CreateCommand(new cmd_list(ServerInstance));
- this->CreateCommand(new cmd_die(ServerInstance));
- this->CreateCommand(new cmd_restart(ServerInstance));
- this->CreateCommand(new cmd_kill(ServerInstance));
- this->CreateCommand(new cmd_rehash(ServerInstance));
- this->CreateCommand(new cmd_lusers(ServerInstance));
- this->CreateCommand(new cmd_stats(ServerInstance));
- this->CreateCommand(new cmd_userhost(ServerInstance));
- this->CreateCommand(new cmd_away(ServerInstance));
- this->CreateCommand(new cmd_ison(ServerInstance));
- this->CreateCommand(new cmd_summon(ServerInstance));
- this->CreateCommand(new cmd_users(ServerInstance));
- this->CreateCommand(new cmd_invite(ServerInstance));
- this->CreateCommand(new cmd_trace(ServerInstance));
- this->CreateCommand(new cmd_whowas(ServerInstance));
- this->CreateCommand(new cmd_connect(ServerInstance));
- this->CreateCommand(new cmd_squit(ServerInstance));
- this->CreateCommand(new cmd_modules(ServerInstance));
- this->CreateCommand(new cmd_links(ServerInstance));
- this->CreateCommand(new cmd_map(ServerInstance));
- this->CreateCommand(new cmd_kline(ServerInstance));
- this->CreateCommand(new cmd_gline(ServerInstance));
- this->CreateCommand(new cmd_zline(ServerInstance));
- this->CreateCommand(new cmd_qline(ServerInstance));
- this->CreateCommand(new cmd_eline(ServerInstance));
- this->CreateCommand(new cmd_loadmodule(ServerInstance));
- this->CreateCommand(new cmd_unloadmodule(ServerInstance));
- this->CreateCommand(new cmd_server(ServerInstance));
- this->CreateCommand(new cmd_commands(ServerInstance));
+ DIR* library = opendir(LIBRARYDIR);
+ if (library)
+ {
+ dirent* entry = NULL;
+ while ((entry = readdir(library)))
+ {
+ if (match(entry->d_name, "cmd_*.so"))
+ {
+ this->LoadCommand(entry->d_name);
+ }
+ }
+ closedir(library);
+ }
}