ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/server_capab.c
Revision: 8214
Committed: Sun Apr 16 11:44:44 2017 UTC (8 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 3515 byte(s)
Log Message:
- Store real host information in Client.realhost and extend the UID message to send the actual host.
  This allows operators to see the real host of a client in /whois and /whowas.

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 capab_add("RHOST", CAPAB_RHOST);
54 }
55
56 /* capab_add()
57 *
58 * inputs - string name of CAPAB
59 * - int flag of capability
60 * output - NONE
61 * side effects - Adds given capability name and bit mask to
62 * current supported capabilities. This allows
63 * modules to dynamically add or subtract their capability.
64 */
65 void
66 capab_add(const char *name, unsigned int flag)
67 {
68 struct Capability *cap = xcalloc(sizeof(*cap));
69
70 cap->name = xstrdup(name);
71 cap->cap = flag;
72 dlinkAdd(cap, &cap->node, &capab_list);
73 }
74
75 /* capab_del()
76 *
77 * inputs - string name of CAPAB
78 * output - NONE
79 * side effects - delete given capability from ones known.
80 */
81 void
82 capab_del(const char *name)
83 {
84 dlink_node *node, *node_next;
85
86 DLINK_FOREACH_SAFE(node, node_next, capab_list.head)
87 {
88 struct Capability *cap = node->data;
89
90 if (!irccmp(cap->name, name))
91 {
92 dlinkDelete(node, &capab_list);
93 xfree(cap->name);
94 xfree(cap);
95 }
96 }
97 }
98
99 /*
100 * capab_find()
101 *
102 * inputs - string name of capab to find
103 * output - 0 if not found CAPAB otherwise
104 * side effects - none
105 */
106 unsigned int
107 capab_find(const char *name)
108 {
109 dlink_node *node;
110
111 DLINK_FOREACH(node, capab_list.head)
112 {
113 const struct Capability *cap = node->data;
114
115 if (!irccmp(cap->name, name))
116 return cap->cap;
117 }
118
119 return 0;
120 }
121
122 /*
123 * capab_get() - show current server capabilities
124 *
125 * inputs - pointer to a struct Client
126 * output - pointer to static string
127 * side effects - build up string representing capabilities of server listed
128 */
129 const char *
130 capab_get(const void *ptr)
131 {
132 static char buf[IRCD_BUFSIZE] = "";
133 dlink_node *node;
134
135 buf[0] = '\0';
136
137 DLINK_FOREACH(node, capab_list.head)
138 {
139 const struct Capability *cap = node->data;
140
141 if (ptr && !IsCapable(((const struct Client *)ptr), cap->cap))
142 continue;
143
144 strlcat(buf, cap->name, sizeof(buf));
145
146 if (node->next)
147 strlcat(buf, " ", sizeof(buf));
148 }
149
150 return buf;
151 }

Properties

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