From 110f099802c474d74733eff43bb5b387e6c78c50 Mon Sep 17 00:00:00 2001 From: stskeeps Date: Sun, 11 Mar 2001 13:08:53 +0000 Subject: [PATCH] +- Started on commands.so making, works good atm -on req of codemastr, + both as m_module.so and commands.so :) - long live dynamiclinking --- Changes | 4 ++- src/Makefile | 7 +++- src/l_commands.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ src/m_test.c | 11 +++--- src/modules.c | 2 +- 5 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 src/l_commands.c diff --git a/Changes b/Changes index 7b6f8389e..bb7fa5d2d 100644 --- a/Changes +++ b/Changes @@ -316,4 +316,6 @@ unable to get loaded twice with same name. - Reintroduced "fake lag". Flood algoritm works this way: Make next check for parsing be - (1 + (length of command+parameters / 60) \ No newline at end of file + (1 + (length of command+parameters / 60) +- Started on commands.so making, works good atm -on req of codemastr, + both as m_module.so and commands.so :) - long live dynamiclinking diff --git a/src/Makefile b/src/Makefile index 963070d6e..074f0352f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -31,7 +31,7 @@ OBJS=agent.o aln.o badwords.o bsd.o channel.o cloak.o crule.o dbuf.o \ s_user.o scache.o send.o support.o userload.o version.o webtv.o \ whowas.o zip.o -MODULES=libdummy.so +MODULES=libdummy.so commands.so SRC=$(OBJS:%.o=%.c) @@ -75,6 +75,11 @@ libdummy.so: m_test.c $(INCLUDES) $(CC) $(CFLAGS) -DDYNAMIC_LINKING \ -fPIC -DPIC -shared -o libdummy.so m_test.c +commands.so: l_commands.c m_test.c $(INCLUDES) + $(CC) $(CFLAGS) -fPIC -DPIC -shared -o commands.so l_commands.c m_test.c + + + parse.o: parse.c $(INCLUDES) $(CC) $(CFLAGS) -c parse.c diff --git a/src/l_commands.c b/src/l_commands.c new file mode 100644 index 000000000..6ee6bdfa7 --- /dev/null +++ b/src/l_commands.c @@ -0,0 +1,92 @@ +/* + * Unreal Internet Relay Chat Daemon - src/l_commands.c + * (C) 2000 Carsten Munk (Techie/Stskeeps) + * + * Wrapper for making commands.so + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + */ +#define DYNAMIC_LINKING +#include "config.h" +#include "struct.h" +#include "common.h" +#include "sys.h" +#include "numeric.h" +#include "msg.h" +#include "channel.h" +#include "userload.h" +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#endif +#include +#include "h.h" +#ifdef STRIPBADWORDS +#include "badwords.h" +#endif +#ifdef _WIN32 +#include "version.h" +#endif + +/* Place includes here */ +/* replace this with a common name of your module */ +ModuleInfo l_commands_info + = { + 1, + "commands", /* Name of module */ + "$Id$", /* Version */ + "Wrapper library for m_ commands", /* Short description of module */ + NULL, /* Pointer to our dlopen() return value */ + NULL + }; + +/* + * The purpose of these ifdefs, are that we can "static" link the ircd if we + * want to +*/ + +#ifdef DYNAMIC_LINKING +DLLFUNC void mod_init(void) +#else +void l_commands_init(void) +#endif +{ + /* extern variable to export l_commands_info to temporary + ModuleInfo *modulebuffer; + the module_load() will use this to add to the modules linked + list + */ + module_buffer = &l_commands_info; + /* + * We call our add_Command crap here + */ + modulename_init(); + module_buffer = &l_commands_info; +} + +#ifdef DYNAMIC_LINKING +DLLFUNC void mod_unload(void) +#else +void _l_commands_unload(void) +#endif +{ + modulename_unload(); +} + diff --git a/src/m_test.c b/src/m_test.c index 9b06d3b50..9a815fafa 100644 --- a/src/m_test.c +++ b/src/m_test.c @@ -28,8 +28,11 @@ #endif /* Place includes here */ -/* replace this with a common name of your module */ -#define modulename dummy +/* + * Run a search and replace on modulename to a unique name of your module, + * like dummy + * -link will fail else +*/ #define MSG_DUMMY "DUMMY" #define TOK_DUMMY "DU" @@ -71,13 +74,13 @@ void modulename_init(void) #ifdef DYNAMIC_LINKING DLLFUNC void mod_unload(void) #else -void _modulename_unload(void) +void modulename_unload(void) #endif { if (del_Command(MSG_DUMMY, TOK_DUMMY, m_dummy) < 0) { sendto_realops("Failed to delete commands when unloading %s", - modulename); + modulename_info.name); } /* do etc stuff here */ sendto_ops("Unloaded"); diff --git a/src/modules.c b/src/modules.c index c9ca58fa2..0f68adbdc 100644 --- a/src/modules.c +++ b/src/modules.c @@ -61,7 +61,7 @@ int load_module(char *module) void (*mod_unload) (); int i; module_buffer = NULL; - if (Mod = irc_dlopen(module, RTLD_LAZY)) + if (Mod = irc_dlopen(module, RTLD_NOW)) { /* Succeed loading module */ /* Locate mod_init function */