]>
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.";
33 struct searchNode
*servername
;
36 if (!(servername
=argtoconststr("server", ctx
, argv
[0], &p
))) {
42 for(i
=0;i
<MAXSERVERS
;i
++) {
43 sstring
*n
= serverlist
[i
].name
;
44 if(n
&& !strcmp(n
->content
, p
)) {
50 (servername
->free
)(ctx
, servername
);
53 parseError
= "server: server not found.";
58 thenode
->returntype
= RETURNTYPE_BOOL
;
59 thenode
->localdata
= (void *)numeric
;
61 thenode
->exe
= server_exe_bool
;
63 thenode
->returntype
= RETURNTYPE_STRING
;
64 thenode
->localdata
= NULL
;
66 thenode
->exe
= server_exe_str
;
69 thenode
->free
= server_free
;
74 void *server_exe_bool(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
75 nick
*np
= (nick
*)theinput
;
76 long server
= (long)thenode
->localdata
;
78 if(homeserver(np
->numeric
) == server
)
84 void *server_exe_str(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
85 nick
*np
= (nick
*)theinput
;
86 sstring
*n
= serverlist
[homeserver(np
->numeric
)].name
;
94 void server_free(searchCtx
*ctx
, struct searchNode
*thenode
) {