ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/server_capab.c
Revision: 8172
Committed: Sun Apr 9 16:16:29 2017 UTC (8 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 3480 byte(s)
Log Message:
- server_capab.h, server_capab.c: propset

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 server_capab.c
23 * \brief Server CAPAB related functions.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "client.h"
30 #include "irc_string.h"
31 #include "ircd_defs.h"
32 #include "server_capab.h"
33 #include "memory.h"
34
35
36 static dlink_list capab_list; /* List of capabilities supported by this server */
37
38
39 /* capab_init()
40 *
41 * inputs - none
42 * output - none
43 */
44 void
45 capab_init(void)
46 {
47 capab_add("QS", CAPAB_QS);
48 capab_add("EOB", CAPAB_EOB);
49 capab_add("CLUSTER", CAPAB_CLUSTER);
50 capab_add("SVS", CAPAB_SVS);
51 capab_add("CHW", CAPAB_CHW);
52 capab_add("HOPS", CAPAB_HOPS);
53 }
54
55 /* capab_add()
56 *
57 * inputs - string name of CAPAB
58 * - int flag of capability
59 * output - NONE
60 * side effects - Adds given capability name and bit mask to
61 * current supported capabilities. This allows
62 * modules to dynamically add or subtract their capability.
63 */
64 void
65 capab_add(const char *name, unsigned int flag)
66 {
67 struct Capability *cap = xcalloc(sizeof(*cap));
68
69 cap->name = xstrdup(name);
70 cap->cap = flag;
71 dlinkAdd(cap, &cap->node, &capab_list);
72 }
73
74 /* capab_del()
75 *
76 * inputs - string name of CAPAB
77 * output - NONE
78 * side effects - delete given capability from ones known.
79 */
80 void
81 capab_del(const char *name)
82 {
83 dlink_node *node, *node_next;
84
85 DLINK_FOREACH_SAFE(node, node_next, capab_list.head)
86 {
87 struct Capability *cap = node->data;
88
89 if (!irccmp(cap->name, name))
90 {
91 dlinkDelete(node, &capab_list);
92 xfree(cap->name);
93 xfree(cap);
94 }
95 }
96 }
97
98 /*
99 * capab_find()
100 *
101 * inputs - string name of capab to find
102 * output - 0 if not found CAPAB otherwise
103 * side effects - none
104 */
105 unsigned int
106 capab_find(const char *name)
107 {
108 dlink_node *node;
109
110 DLINK_FOREACH(node, capab_list.head)
111 {
112 const struct Capability *cap = node->data;
113
114 if (!irccmp(cap->name, name))
115 return cap->cap;
116 }
117
118 return 0;
119 }
120
121 /*
122 * capab_get() - show current server capabilities
123 *
124 * inputs - pointer to a struct Client
125 * output - pointer to static string
126 * side effects - build up string representing capabilities of server listed
127 */
128 const char *
129 capab_get(const void *ptr)
130 {
131 static char buf[IRCD_BUFSIZE] = "";
132 dlink_node *node;
133
134 buf[0] = '\0';
135
136 DLINK_FOREACH(node, capab_list.head)
137 {
138 const struct Capability *cap = node->data;
139
140 if (ptr && !IsCapable(((const struct Client *)ptr), cap->cap))
141 continue;
142
143 strlcat(buf, cap->name, sizeof(buf));
144
145 if (node->next)
146 strlcat(buf, " ", sizeof(buf));
147 }
148
149 return buf;
150 }

Properties

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