1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 2012-2016 ircd-hybrid development team |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
* USA |
20 |
*/ |
21 |
|
22 |
/*! \file conf_service.c |
23 |
* \brief Implements service {} block configuration management. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "list.h" |
29 |
#include "irc_string.h" |
30 |
#include "memory.h" |
31 |
#include "conf_service.h" |
32 |
|
33 |
|
34 |
static dlink_list service_list; |
35 |
|
36 |
|
37 |
const dlink_list * |
38 |
service_get_list(void) |
39 |
{ |
40 |
return &service_list; |
41 |
} |
42 |
|
43 |
void |
44 |
service_clear(void) |
45 |
{ |
46 |
while (service_list.head) |
47 |
{ |
48 |
struct ServiceItem *service = service_list.head->data; |
49 |
|
50 |
dlinkDelete(&service->node, &service_list); |
51 |
xfree(service->name); |
52 |
xfree(service); |
53 |
} |
54 |
} |
55 |
|
56 |
struct ServiceItem * |
57 |
service_make(void) |
58 |
{ |
59 |
struct ServiceItem *service = xcalloc(sizeof(*service)); |
60 |
dlinkAdd(service, &service->node, &service_list); |
61 |
|
62 |
return service; |
63 |
} |
64 |
|
65 |
const struct ServiceItem * |
66 |
service_find(const char *name) |
67 |
{ |
68 |
dlink_node *node; |
69 |
|
70 |
DLINK_FOREACH(node, service_list.head) |
71 |
{ |
72 |
const struct ServiceItem *service = node->data; |
73 |
|
74 |
if (!irccmp(service->name, name)) |
75 |
return service; |
76 |
} |
77 |
|
78 |
return NULL; |
79 |
} |