]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/newsearch/csns-qchanflags.c
2 * qchanflags functionality
5 #include "../../newsearch/newsearch.h"
6 #include "../../lib/flags.h"
7 #include "../chanserv.h"
12 void *qchanflags_exe(searchCtx
*, struct searchNode
*thenode
, void *theinput
);
13 void qchanflags_free(searchCtx
*, struct searchNode
*thenode
);
15 struct qchanflags_localdata
{
20 struct searchNode
*qchanflags_parse(searchCtx
*ctx
, int type
, int argc
, char **argv
) {
21 struct searchNode
*thenode
;
22 struct qchanflags_localdata
*localdata
;
24 if (type
!= SEARCHTYPE_CHANNEL
) {
25 parseError
= "qchanflags: this function is only valid for channel searches.";
29 if (!(thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
)))) {
30 parseError
= "malloc: could not allocate memory for this search.";
34 thenode
->localdata
=localdata
=malloc(sizeof(struct qchanflags_localdata
));
35 thenode
->returntype
= RETURNTYPE_INT
;
36 thenode
->exe
= qchanflags_exe
;
37 thenode
->free
= qchanflags_free
;
40 localdata
->setmodes
=0;
41 localdata
->clearmodes
=0;
43 localdata
->setmodes
=0;
44 localdata
->clearmodes
=~0;
46 setflags(&(localdata
->setmodes
), QCFLAG_ALL
, argv
[0], rcuflags
, REJECT_NONE
);
47 setflags(&(localdata
->clearmodes
), QCFLAG_ALL
, argv
[0], rcuflags
, REJECT_NONE
);
49 localdata
->clearmodes
= ~localdata
->clearmodes
;
55 void *qchanflags_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
56 chanindex
*cip
= (chanindex
*)theinput
;
58 struct qchanflags_localdata
*localdata
=thenode
->localdata
;
60 if (!(rcp
=cip
->exts
[chanservext
]))
63 if (((rcp
->flags
& localdata
->setmodes
) != localdata
->setmodes
) || (rcp
->flags
& localdata
->clearmodes
))
69 void qchanflags_free(searchCtx
*ctx
, struct searchNode
*thenode
) {
70 free(thenode
->localdata
);