]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-modes.c
10 struct modes_localdata
{
16 void *modes_exe(struct searchNode
*thenode
, void *theinput
);
17 void modes_free(struct searchNode
*thenode
);
19 struct searchNode
*modes_parse(int type
, int argc
, char **argv
) {
20 struct modes_localdata
*localdata
;
21 struct searchNode
*thenode
;
25 parseError
="modes: usage: modes (mode string)";
30 case SEARCHTYPE_CHANNEL
:
39 parseError
="modes: unsupported search type";
43 if (!(localdata
=(struct modes_localdata
*)malloc(sizeof(struct modes_localdata
)))) {
44 parseError
= "malloc: could not allocate memory for this search.";
49 localdata
->setmodes
=0;
50 localdata
->clearmodes
= ~0;
52 setflags(&(localdata
->setmodes
), 0xFFFF, argv
[0], flaglist
, REJECT_NONE
);
53 setflags(&(localdata
->clearmodes
), 0xFFFF, argv
[0], flaglist
, REJECT_NONE
);
55 localdata
->clearmodes
= ~(localdata
->clearmodes
);
57 if (!(thenode
=(struct searchNode
*)malloc(sizeof(struct searchNode
)))) {
58 /* couldn't malloc() memory for thenode, so free localdata to avoid leakage */
59 parseError
= "malloc: could not allocate memory for this search.";
64 thenode
->returntype
= RETURNTYPE_BOOL
;
65 thenode
->localdata
= (void *)localdata
;
66 thenode
->exe
= modes_exe
;
67 thenode
->free
= modes_free
;
72 void *modes_exe(struct searchNode
*thenode
, void *value
) {
73 struct modes_localdata
*localdata
;
78 localdata
= (struct modes_localdata
*)thenode
->localdata
;
80 switch (localdata
->type
) {
81 case SEARCHTYPE_CHANNEL
:
82 cip
=(chanindex
*)value
;
85 flags
=cip
->channel
->flags
;
97 if (~flags
& (localdata
->setmodes
))
100 if (flags
& (localdata
->clearmodes
))
106 void modes_free(struct searchNode
*thenode
) {
107 free (thenode
->localdata
);