]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-channeliter.c
12 void channeliter_free(searchCtx
*ctx
, struct searchNode
*thenode
);
13 void *channeliter_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
15 struct channeliter_localdata
{
17 struct searchVariable
*variable
;
21 struct searchNode
*channeliter_parse(searchCtx
*ctx
, int argc
, char **argv
) {
23 struct channeliter_localdata
*localdata
;
26 parseError
= "channeliter: usage: channeliter variable";
30 if(!(localdata
=(struct channeliter_localdata
*)malloc(sizeof(struct channeliter_localdata
)))) {
31 parseError
= "malloc: could not allocate memory for this search.";
35 if(!(localdata
->variable
=var_register(ctx
, argv
[0], RETURNTYPE_STRING
))) {
40 if(!(thenode
=(struct searchNode
*)malloc(sizeof(struct searchNode
)))) {
41 parseError
= "malloc: could not allocate memory for this search.";
46 localdata
->currentchannel
= 0;
47 localdata
->lastnick
= NULL
;
49 thenode
->returntype
= RETURNTYPE_BOOL
;
50 thenode
->localdata
= localdata
;
51 thenode
->exe
= channeliter_exe
;
52 thenode
->free
= channeliter_free
;
57 void channeliter_free(searchCtx
*ctx
, struct searchNode
*thenode
) {
58 free(thenode
->localdata
);
62 void *channeliter_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
63 struct channeliter_localdata
*localdata
= thenode
->localdata
;
64 nick
*np
= (nick
*)theinput
;
66 if(np
!= localdata
->lastnick
) {
67 localdata
->lastnick
= np
;
68 localdata
->currentchannel
= 0;
71 /* if(np->channels->cursi > MAX_CHANS)
75 if(localdata
->currentchannel
>= np
->channels
->cursi
)
78 var_setstr(localdata
->variable
, ((channel
**)np
->channels
->content
)[localdata
->currentchannel
++]->index
->name
->content
);