ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/conf_cluster.c
Revision: 9858
Committed: Fri Jan 1 04:43:42 2021 UTC (3 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 2224 byte(s)
Log Message:
- Bump copyright years

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2021 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_cluster.c
23 * \brief Implements cluster {} block configuration management.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "ircd_defs.h"
29 #include "list.h"
30 #include "memory.h"
31 #include "conf_cluster.h"
32 #include "server_capab.h"
33 #include "send.h"
34
35
36 static dlink_list cluster_list;
37
38
39 const dlink_list *
40 cluster_get_list(void)
41 {
42 return &cluster_list;
43 }
44
45 void
46 cluster_clear(void)
47 {
48 while (cluster_list.head)
49 {
50 struct ClusterItem *cluster = cluster_list.head->data;
51
52 dlinkDelete(&cluster->node, &cluster_list);
53 xfree(cluster->server);
54 xfree(cluster);
55 }
56 }
57
58 struct ClusterItem *
59 cluster_make(void)
60 {
61 struct ClusterItem *cluster = xcalloc(sizeof(*cluster));
62 dlinkAdd(cluster, &cluster->node, &cluster_list);
63
64 return cluster;
65 }
66
67 void
68 cluster_distribute(const void *client, const char *command, unsigned int capab,
69 unsigned int type, const char *pattern, ...)
70 {
71 dlink_node *node;
72 va_list args;
73 char buf[IRCD_BUFSIZE];
74
75 va_start(args, pattern);
76 vsnprintf(buf, sizeof(buf), pattern, args);
77 va_end(args);
78
79 DLINK_FOREACH(node, cluster_list.head)
80 {
81 const struct ClusterItem *cluster = node->data;
82
83 if (cluster->type & type)
84 sendto_match_servs(client, cluster->server, CAPAB_CLUSTER | capab,
85 "%s %s %s", command, cluster->server, buf);
86 }
87 }

Properties

Name Value
svn:eol-style native
svn:keywords Id