]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-modes.c
10 struct modes_localdata
{
15 void *modes_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
16 void modes_free(searchCtx
*ctx
, struct searchNode
*thenode
);
18 struct searchNode
*modes_parse(searchCtx
*ctx
, int argc
, char **argv
) {
19 struct modes_localdata
*localdata
;
20 struct searchNode
*thenode
, *modestring
;
25 parseError
="modes: usage: modes (mode string)";
29 if (ctx
->searchcmd
== reg_chansearch
) {
35 if (!(localdata
=(struct modes_localdata
*)malloc(sizeof(struct modes_localdata
)))) {
36 parseError
= "malloc: could not allocate memory for this search.";
40 localdata
->setmodes
=0;
41 localdata
->clearmodes
= ~0;
43 if (!(modestring
=argtoconststr("modes", ctx
, argv
[0], &p
))) {
48 setflags(&(localdata
->setmodes
), 0xFFFF, p
, flaglist
, REJECT_NONE
);
49 setflags(&(localdata
->clearmodes
), 0xFFFF, p
, flaglist
, REJECT_NONE
);
50 (modestring
->free
)(ctx
, modestring
);
52 localdata
->clearmodes
= ~(localdata
->clearmodes
);
54 if (!(thenode
=(struct searchNode
*)malloc(sizeof(struct searchNode
)))) {
55 /* couldn't malloc() memory for thenode, so free localdata to avoid leakage */
56 parseError
= "malloc: could not allocate memory for this search.";
61 thenode
->returntype
= RETURNTYPE_BOOL
;
62 thenode
->localdata
= (void *)localdata
;
63 thenode
->exe
= modes_exe
;
64 thenode
->free
= modes_free
;
69 void *modes_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *value
) {
70 struct modes_localdata
*localdata
;
75 localdata
= (struct modes_localdata
*)thenode
->localdata
;
77 if (ctx
->searchcmd
== reg_chansearch
) {
78 cip
=(chanindex
*)value
;
81 flags
=cip
->channel
->flags
;
87 if (~flags
& (localdata
->setmodes
))
90 if (flags
& (localdata
->clearmodes
))
96 void modes_free(searchCtx
*ctx
, struct searchNode
*thenode
) {
97 free (thenode
->localdata
);