ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_hash.c
Revision: 350
Committed: Sun Jan 1 09:29:42 2006 UTC (20 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 5124 byte(s)
Log Message:
- documentings

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 *
4 * Copyright (C) 2002 by the past and present ircd coders, and others.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 *
21 * $Id$
22 */
23
24 #include "stdinc.h"
25 #include "handlers.h"
26 #include "channel.h"
27 #include "channel_mode.h"
28 #include "client.h"
29 #include "hash.h"
30 #include "ircd.h"
31 #include "numeric.h"
32 #include "s_conf.h"
33 #include "s_serv.h"
34 #include "send.h"
35 #include "msg.h"
36 #include "parse.h"
37 #include "modules.h"
38 #include "s_user.h"
39 #include "resv.h"
40 #include "userhost.h"
41
42 static void mo_hash(struct Client *, struct Client *, int, char *[]);
43
44
45 struct Message hash_msgtab = {
46 "HASH", 0, 0, 0, 0, MFLG_SLOW, 0,
47 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_hash, m_ignore }
48 };
49
50 #ifndef STATIC_MODULES
51 void
52 _modinit(void)
53 {
54 mod_add_cmd(&hash_msgtab);
55 }
56
57 void
58 _moddeinit(void)
59 {
60 mod_del_cmd(&hash_msgtab);
61 }
62
63 const char *_version = "$Revision$";
64 #endif
65
66 /*! \brief HASH command handler (called for operators only)
67 *
68 * Returns various information such as maxmimum entries, slots that
69 * are in use and collision count
70 *
71 * \param client_p Pointer to allocated Client struct with physical connection
72 * to this server, i.e. with an open socket connected.
73 * \param source_p Pointer to allocated Client struct from which the message
74 * originally comes from. This can be a local or remote client.
75 * \param parc Integer holding the number of supplied arguments.
76 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
77 * pointers.
78 * \note Valid arguments for this command are:
79 * - parv[0] = sender prefix
80 */
81 static void
82 mo_hash(struct Client *client_p, struct Client *source_p,
83 int parc, char *parv[])
84 {
85 int i;
86 int max_chain = 0;
87 int buckets = 0;
88 int count = 0;
89 struct Client *cl;
90 struct Client *icl;
91 struct Channel *ch;
92 struct UserHost *ush;
93 struct ResvChannel *rch;
94
95 for (i = 0; i < HASHSIZE; ++i)
96 {
97 if ((cl = hash_get_bucket(HASH_TYPE_CLIENT, i)) != NULL)
98 {
99 int len = 0;
100
101 ++buckets;
102 for (; cl != NULL; cl = cl->hnext)
103 ++len;
104 if (len > max_chain)
105 max_chain = len;
106 count += len;
107 }
108 }
109
110 sendto_one(source_p, ":%s NOTICE %s :Client: entries: %d buckets: %d "
111 "max chain: %d", me.name, source_p->name, count, buckets,
112 max_chain);
113
114 count = 0;
115 buckets = 0;
116 max_chain = 0;
117
118 for (i = 0; i < HASHSIZE; ++i)
119 {
120 if ((ch = hash_get_bucket(HASH_TYPE_CHANNEL, i)) != NULL)
121 {
122 int len = 0;
123
124 ++buckets;
125 for (; ch != NULL; ch = ch->hnextch)
126 ++len;
127 if (len > max_chain)
128 max_chain = len;
129 count += len;
130 }
131 }
132
133 sendto_one(source_p, ":%s NOTICE %s :Channel: entries: %d buckets: %d "
134 "max chain: %d", me.name, source_p->name, count, buckets,
135 max_chain);
136
137 count = 0;
138 buckets = 0;
139 max_chain = 0;
140
141 for (i = 0; i < HASHSIZE; ++i)
142 {
143 if ((rch = hash_get_bucket(HASH_TYPE_RESERVED, i)) != NULL)
144 {
145 int len = 0;
146
147 ++buckets;
148 for (; rch != NULL; rch = rch->hnext)
149 ++len;
150 if (len > max_chain)
151 max_chain = len;
152 count += len;
153 }
154 }
155
156 sendto_one(source_p, ":%s NOTICE %s :Resv: entries: %d buckets: %d "
157 "max chain: %d", me.name, source_p->name, count, buckets,
158 max_chain);
159
160 count = 0;
161 buckets = 0;
162 max_chain = 0;
163
164 for (i = 0; i < HASHSIZE; ++i)
165 {
166 if ((icl = hash_get_bucket(HASH_TYPE_ID, i)) != NULL)
167 {
168 int len = 0;
169
170 ++buckets;
171 for (; icl != NULL; icl = icl->idhnext)
172 ++len;
173 if (len > max_chain)
174 max_chain = len;
175 count += len;
176 }
177 }
178
179 sendto_one(source_p, ":%s NOTICE %s :Id: entries: %d buckets: %d "
180 "max chain: %d", me.name, source_p->name, count, buckets,
181 max_chain);
182
183 count = 0;
184 buckets = 0;
185 max_chain = 0;
186
187 for (i = 0; i < HASHSIZE; ++i)
188 {
189 if ((ush = hash_get_bucket(HASH_TYPE_USERHOST, i)) != NULL)
190 {
191 int len = 0;
192
193 ++buckets;
194 for (; ush != NULL; ush = ush->next)
195 ++len;
196 if (len > max_chain)
197 max_chain = len;
198 count += len;
199 }
200 }
201
202 sendto_one(source_p, ":%s NOTICE %s :UserHost: entries: %d buckets: %d "
203 "max chain: %d", me.name, source_p->name, count, buckets,
204 max_chain);
205 }

Properties

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