]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/newsearch/csns-qusers.c
5 #include "../../newsearch/newsearch.h"
6 #include "../../lib/flags.h"
7 #include "../chanserv.h"
12 void *qusers_exe(searchCtx
*, struct searchNode
*thenode
, void *theinput
);
13 void qusers_free(searchCtx
*, struct searchNode
*thenode
);
15 struct qusers_localdata
{
20 struct searchNode
*qusers_parse(searchCtx
*ctx
, int argc
, char **argv
) {
21 struct searchNode
*thenode
;
22 struct qusers_localdata
*localdata
;
24 if (!(thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
)))) {
25 parseError
= "malloc: could not allocate memory for this search.";
29 thenode
->localdata
=localdata
=malloc(sizeof(struct qusers_localdata
));
30 thenode
->returntype
= RETURNTYPE_INT
;
31 thenode
->exe
= qusers_exe
;
32 thenode
->free
= qusers_free
;
35 localdata
->setmodes
=0;
36 localdata
->clearmodes
=0;
38 struct searchNode
*arg
;
41 localdata
->setmodes
=0;
42 localdata
->clearmodes
=~0;
44 if (!(arg
=argtoconststr("qusers", ctx
, argv
[0], &p
))) {
49 setflags(&(localdata
->setmodes
), QCUFLAG_ALL
, p
, rcuflags
, REJECT_NONE
);
50 setflags(&(localdata
->clearmodes
), QCUFLAG_ALL
, p
, rcuflags
, REJECT_NONE
);
53 localdata
->clearmodes
= ~localdata
->clearmodes
;
59 void *qusers_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
60 chanindex
*cip
= (chanindex
*)theinput
;
63 struct qusers_localdata
*localdata
=thenode
->localdata
;
64 unsigned long i
,count
=0;
66 if (!(rcp
=cip
->exts
[chanservext
]))
69 for (i
=0;i
<REGCHANUSERHASHSIZE
;i
++) {
70 for (rcup
=rcp
->regusers
[i
];rcup
;rcup
=rcup
->nextbychan
) {
71 if ((rcup
->flags
& localdata
->setmodes
) != localdata
->setmodes
)
74 if (rcup
->flags
& localdata
->clearmodes
)
84 void qusers_free(searchCtx
*ctx
, struct searchNode
*thenode
) {
85 free(thenode
->localdata
);