]> jfr.im git - irc/quakenet/newserv.git/blame - newsearch/ns-server.c
Merge.
[irc/quakenet/newserv.git] / newsearch / ns-server.c
CommitLineData
6c131217
CP
1/*
2 * SERVER functionality
3 */
4
5#include "newsearch.h"
6
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
10
11#include "../irc/irc_config.h"
12#include "../lib/irc_string.h"
13#include "../core/modules.h"
14#include "../server/server.h"
15
16void *server_exe(struct searchNode *thenode, void *theinput);
17void server_free(struct searchNode *thenode);
18
19int ext;
20
21struct searchNode *server_parse(int type, int argc, char **argv) {
22 struct searchNode *thenode;
23 int i;
24 long numeric;
25
26 if (type != SEARCHTYPE_NICK) {
27 parseError = "server: this function is only valid for nick searches.";
28 return NULL;
29 }
30
31 if (argc<1) {
32 parseError = "server: usage: server <server name>";
33 return NULL;
34 }
35
36 numeric = -1;
37 for(i=0;i<MAXSERVERS;i++) {
38 sstring *n = serverlist[i].name;
39 if(n && !strcmp(n->content, argv[0])) {
40 numeric = i;
41 break;
42 }
43 }
44
45 if(numeric == -1) {
46 parseError = "server: server not found.";
47 return NULL;
48 }
49
50 thenode->returntype = RETURNTYPE_BOOL;
51 thenode->localdata = (void *)numeric;
52 thenode->exe = server_exe;
53 thenode->free = server_free;
54
55 return thenode;
56}
57
58void *server_exe(struct searchNode *thenode, void *theinput) {
59 nick *np = (nick *)theinput;
60 long server = (long)thenode->localdata;
61
62 if(homeserver(np->numeric) == server)
63 return (void *)1;
64
65 return (void *)0;
66}
67
68void server_free(struct searchNode *thenode) {
69 free(thenode);
70}