/[svn]/ircd-hybrid/branches/8.2.x/modules/m_hash.c
ViewVC logotype

Contents of /ircd-hybrid/branches/8.2.x/modules/m_hash.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7007 - (show annotations)
Fri Jan 1 00:09:08 2016 UTC (7 years, 1 month ago) by michael
File MIME type: text/x-chdr
File size: 4310 byte(s)
- Update copyright years

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 m_hash.c
23 * \brief Includes required functions for processing the HASH command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "ircd.h"
32 #include "numeric.h"
33 #include "send.h"
34 #include "parse.h"
35 #include "modules.h"
36 #include "userhost.h"
37
38
39 /*! \brief HASH command handler
40 *
41 * \param source_p Pointer to allocated Client struct from which the message
42 * originally comes from. This can be a local or remote client.
43 * \param parc Integer holding the number of supplied arguments.
44 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
45 * pointers.
46 * \note Valid arguments for this command are:
47 * - parv[0] = command
48 */
49 static int
50 mo_hash(struct Client *source_p, int parc, char *parv[])
51 {
52 unsigned int i = 0;
53 unsigned int max_chain = 0;
54 unsigned int buckets = 0;
55 unsigned int count = 0;
56 const struct Client *cl = NULL;
57 const struct Client *icl = NULL;
58 const struct Channel *ch = NULL;
59 const struct UserHost *ush = NULL;
60
61 for (i = 0; i < HASHSIZE; ++i)
62 {
63 if ((cl = hash_get_bucket(HASH_TYPE_CLIENT, i)))
64 {
65 unsigned int len = 0;
66
67 ++buckets;
68 for (; cl; cl = cl->hnext)
69 ++len;
70 if (len > max_chain)
71 max_chain = len;
72 count += len;
73 }
74 }
75
76 sendto_one_notice(source_p, &me, ":Client: entries: %u buckets: %u "
77 "max chain: %u", count, buckets, max_chain);
78
79 count = 0;
80 buckets = 0;
81 max_chain = 0;
82
83 for (i = 0; i < HASHSIZE; ++i)
84 {
85 if ((ch = hash_get_bucket(HASH_TYPE_CHANNEL, i)))
86 {
87 unsigned int len = 0;
88
89 ++buckets;
90 for (; ch; ch = ch->hnextch)
91 ++len;
92 if (len > max_chain)
93 max_chain = len;
94 count += len;
95 }
96 }
97
98 sendto_one_notice(source_p, &me, ":Channel: entries: %u buckets: %u "
99 "max chain: %u", count, buckets, max_chain);
100
101 count = 0;
102 buckets = 0;
103 max_chain = 0;
104
105 for (i = 0; i < HASHSIZE; ++i)
106 {
107 if ((icl = hash_get_bucket(HASH_TYPE_ID, i)))
108 {
109 unsigned int len = 0;
110
111 ++buckets;
112 for (; icl; icl = icl->idhnext)
113 ++len;
114 if (len > max_chain)
115 max_chain = len;
116 count += len;
117 }
118 }
119
120 sendto_one_notice(source_p, &me, ":Id: entries: %u buckets: %u "
121 "max chain: %u", count, buckets, max_chain);
122
123 count = 0;
124 buckets = 0;
125 max_chain = 0;
126
127 for (i = 0; i < HASHSIZE; ++i)
128 {
129 if ((ush = hash_get_bucket(HASH_TYPE_USERHOST, i)))
130 {
131 unsigned int len = 0;
132
133 ++buckets;
134 for (; ush; ush = ush->next)
135 ++len;
136 if (len > max_chain)
137 max_chain = len;
138 count += len;
139 }
140 }
141
142 sendto_one_notice(source_p, &me, ":UserHost: entries: %u buckets: %u "
143 "max chain: %u", count, buckets, max_chain);
144 return 0;
145 }
146
147 static struct Message hash_msgtab =
148 {
149 .cmd = "HASH",
150 .args_max = MAXPARA,
151 .handlers[UNREGISTERED_HANDLER] = m_unregistered,
152 .handlers[CLIENT_HANDLER] = m_not_oper,
153 .handlers[SERVER_HANDLER] = m_ignore,
154 .handlers[ENCAP_HANDLER] = m_ignore,
155 .handlers[OPER_HANDLER] = mo_hash
156 };
157
158 static void
159 module_init(void)
160 {
161 mod_add_cmd(&hash_msgtab);
162 }
163
164 static void
165 module_exit(void)
166 {
167 mod_del_cmd(&hash_msgtab);
168 }
169
170 struct module module_entry =
171 {
172 .version = "$Revision$",
173 .modinit = module_init,
174 .modexit = module_exit,
175 };

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28