]>
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.";
36 if(!(localdata
->variable
=var_register(ctx
, argv
[0], RETURNTYPE_STRING
))) {
41 if(!(thenode
=(struct searchNode
*)malloc(sizeof(struct searchNode
)))) {
42 parseError
= "malloc: could not allocate memory for this search.";
47 localdata
->currentchannel
= 0;
48 localdata
->lastnick
= NULL
;
50 thenode
->returntype
= RETURNTYPE_BOOL
;
51 thenode
->localdata
= localdata
;
52 thenode
->exe
= channeliter_exe
;
53 thenode
->free
= channeliter_free
;
58 void channeliter_free(searchCtx
*ctx
, struct searchNode
*thenode
) {
59 free(thenode
->localdata
);
63 void *channeliter_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
64 struct channeliter_localdata
*localdata
= thenode
->localdata
;
65 nick
*np
= (nick
*)theinput
;
67 if(np
!= localdata
->lastnick
) {
68 localdata
->lastnick
= np
;
69 localdata
->currentchannel
= 0;
72 /* if(np->channels->cursi > MAX_CHANS)
76 if(localdata
->currentchannel
>= np
->channels
->cursi
)
79 var_setstr(localdata
->variable
, ((channel
**)np
->channels
->content
)[localdata
->currentchannel
++]->index
->name
->content
);