+- Started on commands.so making, works good atm -on req of codemastr,

+  both as m_module.so and commands.so :) - long live dynamiclinking
This commit is contained in:
stskeeps 2001-03-11 13:08:53 +00:00
parent c84da7d03c
commit 110f099802
5 changed files with 109 additions and 7 deletions

View file

@ -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)
(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

View file

@ -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

92
src/l_commands.c Normal file
View file

@ -0,0 +1,92 @@
/*
* Unreal Internet Relay Chat Daemon - src/l_commands.c
* (C) 2000 Carsten Munk (Techie/Stskeeps) <stskeeps@tspre.org>
*
* 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 <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#endif
#include <fcntl.h>
#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();
}

View file

@ -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");

View file

@ -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 */