~rcr/rirc

ref: 17d4f632d1817867ad0e80b743faeafc8a9353af rirc/src/components/server.h -rw-r--r-- 1.8 KiB
17d4f632 — Richard Robbins fix assert_fatal not running the test statement 2 months ago
                                                                                
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
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef RIRC_COMPONENTS_SERVER_H
#define RIRC_COMPONENTS_SERVER_H

#include "src/components/buffer.h"
#include "src/components/channel.h"
#include "src/components/ircv3.h"
#include "src/components/mode.h"

// TODO: move this to utils
#define IRC_MESSAGE_LEN 510

struct server
{
	const char *host;
	const char *port;
	const char *pass;
	const char *username;
	const char *realname;
	const char *nick;
	enum casemapping casemapping;
	struct {
		size_t next;
		size_t size;
		const char *base;
		const char **set;
	} nicks;
	struct channel *channel;
	struct channel_list clist;
	struct ircv3_caps ircv3_caps;
	struct mode usermodes;
	struct mode_str mode_str;
	struct mode_cfg mode_cfg;
	struct server *next;
	struct server *prev;
	struct user_list ignore;
	unsigned ping;
	unsigned connected  : 1;
	unsigned quitting   : 1;
	unsigned registered : 1;
	void *connection;
	// TODO: move this to utils
	struct {
		size_t i;
		char cl;
		char buf[IRC_MESSAGE_LEN + 1]; /* callback message buffer */
	} read;
};

struct server_list
{
	/* Circular DLL */
	struct server *head;
	struct server *tail;
};

struct server* server(
	const char*,  /* host */
	const char*,  /* port */
	const char*,  /* pass */
	const char*,  /* username */
	const char*); /* realname */

struct server* server_list_add(struct server_list*, struct server*);
struct server* server_list_del(struct server_list*, struct server*);
struct server* server_list_get(struct server_list*, const char*, const char*);

int server_set_chans(struct server*, const char*);
int server_set_nicks(struct server*, const char*);
void server_set_004(struct server*, char*);
void server_set_005(struct server*, char*);

void server_nick_set(struct server*, const char*);
void server_nicks_next(struct server*);

void server_reset(struct server*);
void server_free(struct server*);

#endif