]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-channel.c
2 * CHANNEL functionality
10 #include "../channel/channel.h"
12 void *channel_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
13 void channel_free(searchCtx
*ctx
, struct searchNode
*thenode
);
15 struct searchNode
*channel_parse(searchCtx
*ctx
, int argc
, char **argv
) {
16 struct searchNode
*thenode
, *convsn
;
21 parseError
= "channel: usage: channel <channel name>";
25 if (!(convsn
=argtoconststr("channel", ctx
, argv
[0], &p
)))
28 cip
=findorcreatechanindex(p
);
29 convsn
->free(ctx
, convsn
);
31 if (!(thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
)))) {
32 parseError
= "malloc: could not allocate memory for this search.";
36 thenode
->returntype
= RETURNTYPE_BOOL
;
37 thenode
->localdata
= cip
;
38 thenode
->exe
= channel_exe
;
39 thenode
->free
= channel_free
;
44 void *channel_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
45 nick
*np
= (nick
*)theinput
;
46 chanindex
*cip
= thenode
->localdata
;
51 if (ctx
->searchcmd
== reg_nicksearch
) {
57 if (getnumerichandlefromchanhash(cp
->users
, np
->numeric
))
60 ww
= (whowas
*)np
->next
; /* Eww. */
62 for (i
= 0; i
< WW_MAXCHANNELS
; i
++)
63 if (ww
->channels
[i
] == cip
)
70 void channel_free(searchCtx
*ctx
, struct searchNode
*thenode
) {
71 releasechanindex(thenode
->localdata
);