ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_cluster.c
Revision: 7924
Committed: Sat Dec 31 13:57:08 2016 UTC (8 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 2216 byte(s)
Log Message:
- Update copyright years

File Contents

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

Properties

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