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.

module programming - step 2

Old posts that have not been replied to for several years.
l
lobz

Post by lobz »

stdragon wrote:2. Right after you include module.h, try these lines:

#undef putlog
#define putlog ((int(*)(...))global[197])
That solved the problem, but i get the same error with dprintf. Is this a global problem with functions having "..." in the parameter list?

I'm using now gcc but i renamed the file to <name>.cpp
l
lobz

Post by lobz »

Ok, I did the same thing with dprintf. Is there a global way to do this for all functions?
l
lobz

module loading

Post by lobz »

Another problem: when compiling the file with .c extension the module loads fine but compiled with .cpp it sais:
base: Error loading module: base.so: undefined symbol: base_start__Fv

The module's name is "base"
l
lobz

Re: module loading

Post by lobz »

lobz wrote:Another problem: when compiling the file with .c extension the module loads fine but compiled with .cpp it sais:
base: Error loading module: base.so: undefined symbol: base_start__Fv

The module's name is "base"
I solved thisone. I put the base_start function's declaration in extern "C" {}

The previous problem is still unsolved:)
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Look in module.h for dprintf, copy the line, and do the same thing I did with putlog, in your module after you include module.h.
s
serra
Voice
Posts: 17
Joined: Sat Feb 22, 2003 10:24 pm

user entry

Post by serra »

Well, i've been looking deep in module.h, and I did realy found some usefull funcions.
However i havent found how do I get a user entry (struct userrec *) by a string containig the nick, or how to get the handle by the nick like in TCL (nick2hand).
i've found function get_user_by_nick(char *nick); in userrec.c but this one is not working, i always get a segment violation.

why do i need this? Well im working with a H_raw, i need to check the flags of the user and i only now his nick (in a string). Am I thinking well? Is there another way to do this?

greetings
pedro
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Are you sure get_user_by_nick is crashing? It returns NULL if the nick doesn't match any user. Use putlog() to figure out exactly where it is crashing. You can even add putlogs into userrec.c. This will help a lot in debugging.
l
lobz

Post by lobz »

stdragon wrote:Look in module.h for dprintf, copy the line, and do the same thing I did with putlog, in your module after you include module.h.
Now I have a problem with the nmalloc and nfree macros. What should I to to be usable in C++? The problem is the same as with putlog and dprintf.
G
Galadhrim
Op
Posts: 123
Joined: Fri Apr 11, 2003 8:38 am
Location: Netherlands, Enschede

Post by Galadhrim »

compile your bot with debug: 'make debug' and use gdb to see where it failed ('gdb eggdrop core').
Locked