]>
jfr.im git - irc/quakenet/newserv.git/blob - newsearch/ns-server.c
11 #include "../irc/irc_config.h"
12 #include "../lib/irc_string.h"
13 #include "../core/modules.h"
14 #include "../server/server.h"
16 void *server_exe_bool(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
17 void *server_exe_str(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
);
18 void server_free(searchCtx
*ctx
, struct searchNode
*thenode
);
22 struct searchNode
*server_parse(searchCtx
*ctx
, int argc
, char **argv
) {
23 struct searchNode
*thenode
;
27 if (!(thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
)))) {
28 parseError
= "malloc: could not allocate memory for this search.";
34 for(i
=0;i
<MAXSERVERS
;i
++) {
35 sstring
*n
= serverlist
[i
].name
;
36 if(n
&& !strcmp(n
->content
, argv
[0])) {
43 parseError
= "server: server not found.";
47 thenode
->returntype
= RETURNTYPE_BOOL
;
48 thenode
->localdata
= (void *)numeric
;
50 thenode
->exe
= server_exe_bool
;
52 thenode
->returntype
= RETURNTYPE_STRING
;
53 thenode
->localdata
= NULL
;
55 thenode
->exe
= server_exe_str
;
58 thenode
->free
= server_free
;
63 void *server_exe_bool(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
64 nick
*np
= (nick
*)theinput
;
65 long server
= (long)thenode
->localdata
;
67 if(homeserver(np
->numeric
) == server
)
73 void *server_exe_str(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
74 nick
*np
= (nick
*)theinput
;
75 sstring
*n
= serverlist
[homeserver(np
->numeric
)].name
;
83 void server_free(searchCtx
*ctx
, struct searchNode
*thenode
) {