egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with Pointers - Need to tweak a little C function

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Modules & Programming
View previous topic :: View next topic  
Author Message
awyeah
Revered One


Joined: 26 Apr 2004
Posts: 1580
Location: Switzerland

PostPosted: Tue Feb 15, 2005 11:47 pm    Post subject: Help with Pointers - Need to tweak a little C function Reply with quote

This is not the most accurate place to ask, but anyway this is related to C, so anyway here goes.

I am using anope services (ChanServ, NickServ... etc) www.anope.org on my IRC network (bahamut-1.8.3) and wanted to modify their accest lists so that they also show ip address infront of nicknames, the last seen ip address of that registered nick, like DALnet has in their aop/sop/akick lists.

I modified the following code:

Code:

static int xop_list(User * u, int index, ChannelInfo * ci, int *sent_header,
int xlev, int xmsg) {

ChanAccess *access = &ci->access[index];
NickAlias *na;

if (!access->in_use || access->level != xlev)
return 0;

if (!*sent_header) {
notice_lang(s_ChanServ, u, xmsg, ci->name);
*sent_header = 1;
}

notice_lang(s_ChanServ, u, CHAN_XOP_LIST_FORMAT, index + 1,
access->nc->display, na->last_usermask);
return 1;
}


To this code, when I asked a project developer of anope team:

Code:

static int xop_list(User * u, int index, ChannelInfo * ci,
int *sent_header, int xlev, int xmsg)
{

NickCore *nc;
ChanAccess *access = &ci->access[index];
NickAlias *na = findnick(nc->display);

if (!access->in_use || access->level != xlev) {
return 0;
}
if (!*sent_header) {
notice_lang(s_ChanServ, u, xmsg, ci->name);
*sent_header = 1;
}

if (!(access->nc->na->last_usermask)) {
notice_lang(s_ChanServ, u, CHAN_XOP_LIST_FORMAT, index + 1,
access->nc->display, "(no record for userhost has been found)");
}

else {
notice_lang(s_ChanServ, u, CHAN_XOP_LIST_FORMAT, index + 1,
access->nc->na->last_usermask);

}
return 1;
}



This is the generated error by the compiler:

Quote:

$ make
sh version.sh
gcc -O2 -Wall -g -c chanserv.c
chanserv.c: In function `xop_list':
chanserv.c:3621: structure has no member named `na'
chanserv.c:3628: structure has no member named `na'
chanserv.c:3611: warning: unused variable `na'
chanserv.c:3610: warning: `nc' might be used uninitialized in this function
*** Error code 1


If anyone is aware of this network services and know's C, I would really appreciate if you could help me out here, especially in these pointers.
_________________
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Galadhrim
Op


Joined: 11 Apr 2003
Posts: 123
Location: Netherlands, Enschede

PostPosted: Mon Mar 14, 2005 6:49 am    Post subject: Reply with quote

alright. took me 30 secs to find the errors (maybe cause im used to getting errors :p )

first of all:
Code:
NickCore *nc;
ChanAccess *access = &ci->access[index];
NickAlias *na = findnick(nc->display);

both nc and na are empty because you didnt initialize nc (na is empty because you tried to find an empty nick with value null - nothing)

hence these two errors:
Code:
chanserv.c:3611: warning: unused variable `na'
chanserv.c:3610: warning: `nc' might be used uninitialized in this function


second:
Code:
if (!(access->nc->na->last_usermask)) {

&
Code:
access->nc->na->last_usermask

the structure access has a member called nc but nc doesnt have a member called na. maybe you should check the source files to see how the structure ChanAccess looks like. you should find a reference to another structure for nc so you can check what the members in that structure are...

hence these two errors:
Code:
chanserv.c:3621: structure has no member named `na'
chanserv.c:3628: structure has no member named `na'
Back to top
View user's profile Send private message
awyeah
Revered One


Joined: 26 Apr 2004
Posts: 1580
Location: Switzerland

PostPosted: Mon Mar 14, 2005 8:05 am    Post subject: Reply with quote

I fixed the code with another technique. The source code compiles fine without an error or a single warning. But sometimes in between while displaying access lists services crashes for no reason. Rolling Eyes

Never encountered this type of error before. Showed the code to alot of people logicially it looks fine and works fine but sometimes it doesn't. I will check the services.core file generated by gdb.
_________________
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Modules & Programming All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber