ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_shared.c
Revision: 7209
Committed: Wed Feb 3 15:10:39 2016 UTC (9 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 2143 byte(s)
Log Message:
- Clustering has been broken in -r7159. Rewrote most of the shared/cluster implementation to be less obscure.
  This introduces a little bit of code duplication, but increases readability, is less error prone, and
  reduces memory consumption a bit.

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-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_shared.c
23 * \brief Implements shared {} block configuration management.
24 * \version $Id: conf_shared.c 7158 2016-01-28 11:25:55Z michael $
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "ircd_defs.h"
30 #include "irc_string.h"
31 #include "memory.h"
32 #include "conf_shared.h"
33
34
35 static dlink_list shared_list;
36
37
38 const dlink_list *
39 shared_get_list(void)
40 {
41 return &shared_list;
42 }
43
44 void
45 shared_clear(void)
46 {
47 while (shared_list.head)
48 {
49 struct SharedItem *shared = shared_list.head->data;
50
51 dlinkDelete(&shared->node, &shared_list);
52 xfree(shared->server);
53 xfree(shared->user);
54 xfree(shared->host);
55 xfree(shared);
56 }
57 }
58
59 struct SharedItem *
60 shared_make(void)
61 {
62 struct SharedItem *shared = xcalloc(sizeof(*shared));
63 dlinkAdd(shared, &shared->node, &shared_list);
64
65 return shared;
66 }
67
68 const struct SharedItem *
69 shared_find(unsigned int type, const char *server,
70 const char *user, const char *host)
71 {
72 dlink_node *node;
73
74 DLINK_FOREACH(node, shared_list.head)
75 {
76 const struct SharedItem *shared = node->data;
77
78 if (shared->type & type)
79 if (!match(shared->server, server))
80 if (!match(shared->user, user) &&
81 !match(shared->host, host))
82 return shared;
83 }
84
85 return NULL;
86 }