summaryrefslogtreecommitdiff
path: root/src/core/servers.h
blob: 25f6ef5e9cdda4cbc0873e88f56025b94a8a2b55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef __SERVERS_H
#define __SERVERS_H

#include "modules.h"

#ifndef __NETWORK_H
typedef struct _ipaddr IPADDR;
#endif

/* Returns SERVER_REC if it's server, NULL if it isn't. */
#define SERVER(server) \
	MODULE_CHECK_CAST(server, SERVER_REC, type, "SERVER")

/* Returns SERVER_CONNECT_REC if it's server connection, NULL if it isn't. */
#define SERVER_CONNECT(conn) \
	MODULE_CHECK_CAST(conn, SERVER_CONNECT_REC, type, "SERVER CONNECT")

#define IS_SERVER(server) \
	(SERVER(server) ? TRUE : FALSE)

#define IS_SERVER_CONNECT(conn) \
	(SERVER_CONNECT(conn) ? TRUE : FALSE)

/* all strings should be either NULL or dynamically allocated */
/* address and nick are mandatory, rest are optional */
typedef struct {
#include "server-connect-rec.h"
} SERVER_CONNECT_REC;

#define STRUCT_SERVER_CONNECT_REC SERVER_CONNECT_REC
typedef struct {
#include "server-rec.h"
} SERVER_REC;

extern GSList *servers, *lookup_servers;

void servers_init(void);
void servers_deinit(void);

/* Connect to server */
SERVER_REC *server_connect(SERVER_CONNECT_REC *conn);
/* Disconnect from server */
void server_disconnect(SERVER_REC *server);

SERVER_REC *server_find_tag(const char *tag);
SERVER_REC *server_find_chatnet(const char *chatnet);

int server_start_connect(SERVER_REC *server);
void server_connect_free(SERVER_CONNECT_REC *conn);

#endif