]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-kick.c
6 #include "../localuser/localuserchannel.h"
11 void *kick_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
12 void kick_free(searchCtx
*ctx
, struct searchNode
*thenode
);
14 struct searchNode
*kick_parse(searchCtx
*ctx
, int argc
, char **argv
) {
15 struct searchNode
*thenode
;
18 if (ctx
->type
!=SEARCHTYPE_CHANNEL
) {
19 parseError
="kick: only channel searches are supported";
24 parseError
="kick: usage: (kick target)";
28 if ((np
=getnickbynick(argv
[0]))==NULL
) {
29 parseError
="kick: unknown nickname";
33 if (IsOper(np
) || IsService(np
)) {
34 parseError
="kick: can't kick opers or services";
38 if (!(thenode
=(struct searchNode
*)malloc(sizeof(struct searchNode
)))) {
39 parseError
= "malloc: could not allocate memory for this search.";
43 thenode
->returntype
= RETURNTYPE_BOOL
;
44 thenode
->localdata
= np
;
45 thenode
->exe
= kick_exe
;
46 thenode
->free
= kick_free
;
51 void *kick_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
55 np
=thenode
->localdata
;
56 cip
=(chanindex
*)theinput
;
58 if (cip
->channel
==NULL
|| getnumerichandlefromchanhash(cip
->channel
->users
, np
->numeric
)==NULL
)
61 localkickuser(NULL
, cip
->channel
, np
, "");
65 void kick_free(searchCtx
*ctx
, struct searchNode
*thenode
) {