-
Notifications
You must be signed in to change notification settings - Fork 0
/
servers.c
49 lines (38 loc) · 1.09 KB
/
servers.c
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
/******************************************************************************
* eiwic - Extensible Ircbot Written In C
* Copyright (C) Hannes Gräuler <[email protected]>
*
* servers.c: This file contains functions to handle eiwic's internal list
* of IRC servers.
*****************************************************************************/
#include "eiwic.h"
#include "settings.h"
#include "plugins.h"
#include "servers.h"
SERVER *server_add(char *host, u_short port, char ipv6)
{
SERVER *server;
if (port == 0 || host == NULL)
return NULL;
server = malloc(sizeof(SERVER));
bzero(server, sizeof(SERVER));
strncpy(server->host, host, MAX_HOSTNAME_LEN - 1);
server->host[MAX_HOSTNAME_LEN - 1] = '\0';
server->port = port;
#ifdef IPV6
server->ipv6 = ipv6;
#endif
dlist_ins_next(&e_global->servers, dlist_tail(&e_global->servers), server);
log(LOG_INIT_DEBUG, "Server %s (Port: %i) has been added.",
server->host, server->port);
return server;
}
void server_remove(SERVER *server)
{
/* TODO */
}
void server_destroy(void *data)
{
SERVER *serv = data;
free(serv);
}