This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

New to the module world. Need help.

Old posts that have not been replied to for several years.
U
UmbraSG
Voice
Posts: 22
Joined: Sun Oct 20, 2002 3:21 am
Location: USA
Contact:

New to the module world. Need help.

Post by UmbraSG »

Okay, I ran into an error once more. I am getting this error ...
  • ../AnimeXtacy.mod/animextacy.c: In function `animextacy_start':
    ../AnimeXtacy.mod/animextacy.c:136: `irc_funcs' undeclared (first use in this fu
    nction)
    ../AnimeXtacy.mod/animextacy.c:136: (Each undeclared identifier is reported only once
    ../AnimeXtacy.mod/animextacy.c:136: for each function it appears in.)
concerning this line ...

Code: Select all

char *animextacy_start(Function *global_funcs)
{
	global = global_funcs;
	Context;
	
	module_register(MODULE_NAME, animextacy_table, 1, 0);
	if( !module_depend(MODULE_NAME, "eggdrop", 106, 0) ) {
		module_undepend(MODULE_NAME);
		return "This module needs eggdrop 1.6.00 or better to run.";
	}
	add_builtins(H_pub, pub_cmds); // this is the hot spot
	return NULL;
}
I have tried to learn as much as I can from the other modules, but I can't seem to establish the link between it all. Woobie is simple, yet doesn't tell me much. The others are very well detailed, but a little too complex for me to extract an exact meaning/pattern of what they are doing. So I am obviously confused. I need this module to respond to !rules, !releases and so forth, so it's not *all* that complex, but I can't seem to get it to compile without errors or warnings out of the ying-yang. TIA!

Kevin P.
M
M0dj0

Post by M0dj0 »

Hi Kevin,

What have you defined

#define MAKING_......

and

#define MODULE_NAME "...."

to ?

In your case I think they must be defined as

#define MAKING_ANIMEXTACY

and

#define MODULE_NAME "animextacy"

This is to get the function tables correct.
U
UmbraSG
Voice
Posts: 22
Joined: Sun Oct 20, 2002 3:21 am
Location: USA
Contact:

Post by UmbraSG »

Hi, thode #defines are already declared as I am following several the examples of the other modules. I still get the funky error.
U
UmbraSG
Voice
Posts: 22
Joined: Sun Oct 20, 2002 3:21 am
Location: USA
Contact:

Post by UmbraSG »

Here is the entire source, so it's quite big. Sorry :(

Code: Select all

#define MODULE_NAME "animextacy"
#define MAKING_ANIMEXTACY

#include "src\mod\module.h"
#include "src\mod\channels.mod\channels.h"
#include "src\mod\modvals.h"
#include "src\mod\irc.mod/irc.h"
#include <stdlib.h>
#include <time.h>

/* general channel rules */
static int pub_rules(char *nick, char *host, char *hand, char *channel, char * text);
/* displays all releases that we have done to date */
static int pub_releases(char *nick, char *host, char *hand, char *channel, char *text);
/* general help */
static int pub_help(char* nick, char *host, char *hand, char *channel, char *text);
/* new releases as of XX */
static int pub_newreleases(char* nick, char *host, char *hand, char *channel, char *text);
/* Serving rules */
static int pub_servrules(char* nick, char *host, char *hand, char *channel, char *text); // server rules

static void notice_user(char *nick, char buffer[], int idx);
static void notice_text(char *nick, char text);
#undef global
static Function *global = NULL;

static int animextacy_expmem()
{
	int size = 0;
	Context;
	return size;
}

/* BEGIN FUNCTION IMPLEMENTATIONS HERE */
FILE* pStream = NULL;
static int pub_rules(char *nick, char *host, char *hand, char *channel, char *text)
{
	/* if the file stream pointer is null, open the file */
	if( pStream ) return 0; 
	pStream = fopen(".\\rules.txt", "r");
	if( !pStream ) return 0;
	
	/* read the strings into a buffer array */
	char nArray[25];
	int i = 0;
	while( !feof( pStream ) )
	{
		char buffer;
		if( !fgets(&buffer, 255, pStream ) ) return 0; // couldn't read a string from the file.
		nArray[i++] = buffer;
	}
	notice_user(nick, nArray, i); // notice the user
	
	/* close the open file  and set pStream to null */
	fclose(pStream);
	pStream = NULL;
}

static int pub_releases(char *nick, char *host, char *hand, char *channel, char *text)
{
	if( !pStream ) return 0;
	
	pStream = fopen(".\\releases.txt", "r");
	if( !pStream ) return 0;
	
	char buffer;
	
	if( !fgets(&buffer, 255, pStream ) ) return 0;
	notice_text(nick, buffer);
	wait(1000);
	
	/* close open file stream & reset pStream to NULL */
	fclose( pStream );
	pStream = NULL;
}

static int pub_help(char* nick, char *host, char *hand, char *channel, char *text)
{
	return 0;	
}

static int pub_newreleases(char* nick, char *host, char *hand, char *channel, char *text)
{
	return 0;
}

static int pub_servrules(char* nick, char *host, char *hand, char *channel, char *text)
{
	return 0;
}
/* END OF FUNCTION IMPLEMENTATIONS HERE */

static void animextacy_report(int idx, int details)
{
	int size = 0;
	Context;
	size = animextacy_expmem();
	if( details ) dprintf(idx, "      0 AnimeXtacy.dll is using [%d] bytes\n", size);
}

static cmd_t pub_cmds[] = 
{
	{"rules",	"",	pub_rules,	NULL},
//	{"help"	"",	pub_help, NULL},
//	{"releases",	"",	pub_releases, 	NULL},
//	{"newreleases", 	"",	pub_newreleases, 	NULL},
//	{"serv_rules",	"",	pub_servrules,	NULL},
	{0}
};

static char *animextacy_close()
{
	table = find_bind_table("pub");
	if (table) rem_builtins(table, pub_cmds);
	module_undepend("animextacy");
	//return "This module cannot be unloaded!";
}

EXPORT_SCOPE char *animextacy_start();

static Function animextacy_table[] = 
{
	(Function) animextacy_start,
	(Function) animextacy_close,
	(Function) animextacy_expmem,
	(Function) animextacy_report,
};

char *animextacy_start(Function *global_funcs)
{
	global = global_funcs;	
	module_register(MODULE_NAME, animextacy_table, 1, 0);
	if( !module_depend(MODULE_NAME, "eggdrop", 106, 0) ) {
		module_undepend(MODULE_NAME);
		return "This module needs eggdrop 1.6.00 or better to run.";
	}
	table = find_bind_table("pub");
	if( table )
	{
		add_builtins(table, pub_cmds); // this is the hot spot
	}
	return NULL;
}

static void notice_text(char *nick, char text)
{
	dprintf(DP_SERVER, "PRIVMSG %s :%s", nick, text);	
}
static void notice_user(char *nick, char buffer[], int idx)
{
	if( !nick ) return ;
	if( !idx ) return;

	int i = 0;
	for( i = 0; i <= idx; i++) 
	{ 
		notice_text(nick, buffer[i]);
	}
}
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

I aint too good when it comes to C, but the directories used in the #include statments are out of whack.
P
Photon
Op
Posts: 170
Joined: Wed Aug 28, 2002 8:00 am
Location: Liverpool, England

Post by Photon »

Yeh .. its your #includes ... code is shared from one mod to another via menas of a function table and #defs. Therefore if your include files are not right then it wont work. Dont know why its not complaining about header file not found tho.

It should be

Code: Select all

#include "../module.h"
#include "../irc.mod/irc.h"
#include "../server.mod/server.h"
#include "../channels.mod/channels.h"

#include "OneOfMyHeaders.h"
I have to admit it took a while to get something running with the first module I wrote, but press on ... the real fun starts when you get bugs and of course have no debugger .. *sigh*
P
Photon
Op
Posts: 170
Joined: Wed Aug 28, 2002 8:00 am
Location: Liverpool, England

Post by Photon »

Oh - one more thing.

You should really be module_depending on all the modules you are using - and noticably you are depending on the irc module already (and possibly server - havent read the code fully)

And on the end of the pub table stick a {0, 0, 0, 0} instead of {0} - its safer.
W
Wcc
Master
Posts: 278
Joined: Sun Oct 28, 2001 8:00 pm
Location: USA
Contact:

Post by Wcc »

You'll also need to replace

Code: Select all

static Function *global = NULL;
with

Code: Select all

static Function *global = NULL, *irc_funcs = NULL;
in order for the irc function table to be imported correctly.

Wcc
U
UmbraSG
Voice
Posts: 22
Joined: Sun Oct 20, 2002 3:21 am
Location: USA
Contact:

Post by UmbraSG »

Ah Cool!! Thank you all. I will give them a try immediately. I got it to run now, however it crashes when I type the !<trigger> like !ax or !rules. Otherwise, it works fine doing nothing =P

Kevin P.
U
UmbraSG
Voice
Posts: 22
Joined: Sun Oct 20, 2002 3:21 am
Location: USA
Contact:

Post by UmbraSG »

Okay, here's the new problem :(

::[ 10:10:46 pm]:: <UmbraSG> !rules
::[ 10:10:47 pm]:: * Quits: Succubus (~MoToKo@kami.click-network.com) (Read error: Connection reset by peer)

I have not a clue what's causing this.
P
Photon
Op
Posts: 170
Joined: Wed Aug 28, 2002 8:00 am
Location: Liverpool, England

Post by Photon »

Ok .. here comes the fun part .. debugging.
  • step 1 - are you dcc'ed into the bot when you run the command? Does it give a segment violation?

    step 2 - have you used Context; and putlog to trace the line where it crashes? If you have your console mode set right, you can view the putlogs as they happen, and the last Context; call (along with a small history of previous calls) will be reported if the bot crashes. Believe me, its easy if the bot crashes - if it goes into an infinate loop, its much moer fun!!

    step 3 - is the bot compiled in debug mode? If so you wall have extensive memory allocation info, and if the bot crashes, it will do a core dump, which you can run a debugger over (more detail in another thread not too far down on this forum)
P
Photon
Op
Posts: 170
Joined: Wed Aug 28, 2002 8:00 am
Location: Liverpool, England

Post by Photon »

oh and btw - in pub_rules, I suspect

Code: Select all

char nArray[25]
should be

Code: Select all

char nArray[255]
as you are freading 255 bytes into it ...

and why are you noticing the user text one char at a time?
U
UmbraSG
Voice
Posts: 22
Joined: Sun Oct 20, 2002 3:21 am
Location: USA
Contact:

Post by UmbraSG »

Answer to #1: No dccing into the bot to type the command. I type it in the room. Yes, I have got a segment violation, but that one is with the compiled form. I have never got the one I compiled to work (dns module won't compile either because of no functional resolvers). It gave me a tcl?.h error ('?' - don't remember the whole name). It told me to report it as a bug since it was a segment violation.

Answer to Question #2: I haven't used Context nor putlog.

Answer to Question #3: I don't think so. How would I go about defining debug mode?
Photon wrote:Ok .. here comes the fun part .. debugging.
  • step 1 - are you dcc'ed into the bot when you run the command? Does it give a segment violation?

    step 2 - have you used Context; and putlog to trace the line where it crashes? If you have your console mode set right, you can view the putlogs as they happen, and the last Context; call (along with a small history of previous calls) will be reported if the bot crashes. Believe me, its easy if the bot crashes - if it goes into an infinate loop, its much moer fun!!

    step 3 - is the bot compiled in debug mode? If so you wall have extensive memory allocation info, and if the bot crashes, it will do a core dump, which you can run a debugger over (more detail in another thread not too far down on this forum)
U
UmbraSG
Voice
Posts: 22
Joined: Sun Oct 20, 2002 3:21 am
Location: USA
Contact:

Post by UmbraSG »

ARGH!! So frutrated! A friend suggested that I do 'make static' which still caused me to have a Segment Violation error on a line that contain 'Context;' Honestly, i have felt like throwing my computer to the floor and stomping on it. woobie works without any problems what-so-ever, but if I had one line to woobie, suddenly the code no longer works.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The reason it shows the line "Context;" as the error point, is becuase it is designed to.

"Context;" is a debug marker. Everytime this macro is called, it stors the filename, and line number. Thus, whe your bot crashes, it tells you the last time the "Context;" macro was called.

This can be used, to tell, near enough (if used properly) where the error is.

The error you have, will be located between the line number shown in the last content message, and the next context.

Thus, if you place more "Context;" lines in, youw ill soon find out, exactly where the error is.
Locked