]>
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 type
, int argc
, char **argv
) {
23 struct searchNode
*thenode
;
27 if (type
!= SEARCHTYPE_NICK
) {
28 parseError
= "server: this function is only valid for nick searches.";
32 if (!(thenode
=(struct searchNode
*)malloc(sizeof (struct searchNode
)))) {
33 parseError
= "malloc: could not allocate memory for this search.";
39 for(i
=0;i
<MAXSERVERS
;i
++) {
40 sstring
*n
= serverlist
[i
].name
;
41 if(n
&& !strcmp(n
->content
, argv
[0])) {
48 parseError
= "server: server not found.";
52 thenode
->returntype
= RETURNTYPE_BOOL
;
53 thenode
->localdata
= (void *)numeric
;
55 thenode
->exe
= server_exe_bool
;
57 thenode
->returntype
= RETURNTYPE_STRING
;
58 thenode
->localdata
= NULL
;
60 thenode
->exe
= server_exe_str
;
63 thenode
->free
= server_free
;
68 void *server_exe_bool(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
69 nick
*np
= (nick
*)theinput
;
70 long server
= (long)thenode
->localdata
;
72 if(homeserver(np
->numeric
) == server
)
78 void *server_exe_str(searchCtx
*ctx
, struct searchNode
*thenode
, void *theinput
) {
79 nick
*np
= (nick
*)theinput
;
80 sstring
*n
= serverlist
[homeserver(np
->numeric
)].name
;
88 void server_free(searchCtx
*ctx
, struct searchNode
*thenode
) {