]>
jfr.im git - irc/quakenet/newserv.git/blob - patriciasearch/ps-nick.c
1 #include "patriciasearch.h"
6 void *ps_nick_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
7 void ps_nick_free(searchCtx
*ctx
, struct searchNode
*thenode
);
9 struct nick_localdata
{
13 struct searchNode
*ps_nick_parse(searchCtx
*ctx
, int argc
, char **argv
) {
14 struct searchNode
*thenode
;
15 struct nick_localdata
*localdata
;
17 if (!(localdata
=(struct nick_localdata
*)malloc(sizeof(struct nick_localdata
)))) {
18 parseError
= "malloc: could not allocate memory for this search.";
23 parseError
="nick: usage: (nick target)";
27 if ((localdata
->np
=getnickbynick(argv
[0]))==NULL
) {
28 parseError
="nick: unknown nickname";
33 if (!(thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
)))) {
34 parseError
= "malloc: could not allocate memory for this search.";
38 thenode
->returntype
= RETURNTYPE_BOOL
;
39 thenode
->localdata
= localdata
;
40 thenode
->exe
= ps_nick_exe
;
41 thenode
->free
= ps_nick_free
;
46 void *ps_nick_exe(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
47 struct nick_localdata
*localdata
;
48 patricia_node_t
*node
;
53 localdata
= thenode
->localdata
;
54 node
= (patricia_node_t
*)theinput
;
56 if (pnode_ext
&& node
->exts
[pnode_ext
] ) {
57 pnp
= node
->exts
[pnode_ext
];
58 for (i
= 0; i
< PATRICIANICK_HASHSIZE
; i
++) {
59 for (np
= pnp
->identhash
[i
]; np
; np
=np
->exts
[pnick_ext
]) {
60 if (np
== localdata
->np
)
68 void ps_nick_free(searchCtx
*ctx
, struct searchNode
*thenode
) {
69 free(thenode
->localdata
);