summaryrefslogtreecommitdiff
path: root/src/core/server.h
blob: ea6ef94e06c9162668186b358dca2e8d618edcc2 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef __SERVER_H
#define __SERVER_H

#ifndef __NETWORK_H
typedef struct _ipaddr IPADDR;
#endif

/* all strings should be either NULL or dynamically allocated */
/* address and nick are mandatory, rest are optional */
typedef struct {
	/* if we're connecting via proxy, or just NULLs */
	char *proxy;
	int proxy_port;
	char *proxy_string;

	char *address;
	int port;
	char *ircnet;

	IPADDR *own_ip;
} SERVER_CONNECT_REC;

typedef struct {
	int type; /* server type */

	SERVER_CONNECT_REC *connrec;
	time_t connect_time; /* connection time */

	char *tag; /* tag name for addressing server */
	char *nick; /* current nick */

	int connected:1; /* connected to server */
	int connection_lost:1; /* Connection lost unintentionally */

	int handle; /* socket handle */
	int readtag; /* input tag */

	/* for net_connect_nonblock() */
	int connect_pipe[2];
	int connect_tag;
	int connect_pid;

	/* For deciding if event should be handled internally */
	GHashTable *eventtable; /* "event xxx" : GSList* of REDIRECT_RECs */
	GHashTable *eventgrouptable; /* event group : GSList* of REDIRECT_RECs */
	GHashTable *cmdtable; /* "command xxx" : REDIRECT_CMD_REC* */

	void *rawlog;
	void *buffer; /* receive buffer */
	GHashTable *module_data;
} SERVER_REC;

extern GSList *servers, *lookup_servers;

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

SERVER_REC *server_find_tag(const char *tag);
SERVER_REC *server_find_ircnet(const char *ircnet);

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

#endif