| View previous topic :: View next topic |
| Author |
Message |
keikoz Voice
Joined: 25 Feb 2006 Posts: 4
|
Posted: Sun Oct 29, 2006 9:19 pm Post subject: Module segfaulting |
|
|
Hi. I'm trying to understand how to build eggdrop modules. It is quite hard... Actually, i dont understand why this code doenst work (i have a segfault launching the bot):
| Code: |
#define MODULE_NAME "testmod"
#define MAKING_TESTMOD
#define TEST_MAJORV 0
#define TEST_MINORV 1
#include "../module.h"
#include "../irc.mod/irc.h"
#undef global
static Function *global = NULL;
static Function *irc_funcs = NULL;
char *testmod_start();
static int print_hi(char *nick, char *host, char *hand,
char *channel, char *text) {
/* dprintf(DP_STDOUT, "He told hello\n");*/
return 0;
}
static cmd_t hi_pub[] = {
{"!hi", "", print_hi, NULL},
{0, 0, 0, 0}
};
static int testmod_expmem () {
return 0;
}
static void testmod_report (int idx, int details) {
if (details) {
int size = testmod_expmem();
dprintf(idx, " Using %d byte%s of memory\n", size, size != 1 ? "s" : "");
}
}
static char *testmod_close () {
rem_builtins(H_pub, hi_pub);
module_undepend(MODULE_NAME);
return NULL;
}
static Function testmod_table[] = {
(Function) testmod_start,
(Function) testmod_close,
(Function) testmod_expmem,
(Function) testmod_report,
};
char *testmod_start(Function *global_funcs) {
global = global_funcs;
module_register(MODULE_NAME, testmod_table, 0, 1);
if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.6.0 or later.";
}
add_builtins(H_pub, hi_pub);
return NULL;
} |
Some help would be really appreciated ...[/code] |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Oct 29, 2006 9:45 pm Post subject: |
|
|
Well, it's because you don't import the function table from the irc-module, which is required to use H_pub bindings...
This should take care of that issue:
| Code: | char *testmod_start(Function *global_funcs) {
global = global_funcs;
module_register(MODULE_NAME, testmod_table, 0, 1);
if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 0))) {
module_undepend(MODULE_NAME);
return "This module requires the irc module to be loaded";
}
if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.6.0 or later.";
}
add_builtins(H_pub, hi_pub);
return NULL;
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
keikoz Voice
Joined: 25 Feb 2006 Posts: 4
|
Posted: Mon Oct 30, 2006 6:17 am Post subject: |
|
|
Ok, it is working.
Thank you very much  |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|