ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_hash.c
Revision: 3275
Committed: Sun Apr 6 12:36:48 2014 UTC (11 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 4323 byte(s)
Log Message:
- Worked towards improving documentation

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2014 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
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)) != NULL)
64 {
65 unsigned int len = 0;
66
67 ++buckets;
68 for (; cl != NULL; 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)) != NULL)
86 {
87 unsigned int len = 0;
88
89 ++buckets;
90 for (; ch != NULL; 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)) != NULL)
108 {
109 unsigned int len = 0;
110
111 ++buckets;
112 for (; icl != NULL; 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)) != NULL)
130 {
131 unsigned int len = 0;
132
133 ++buckets;
134 for (; ush != NULL; 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 "HASH", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
150 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_hash, m_ignore }
151 };
152
153 static void
154 module_init(void)
155 {
156 mod_add_cmd(&hash_msgtab);
157 }
158
159 static void
160 module_exit(void)
161 {
162 mod_del_cmd(&hash_msgtab);
163 }
164
165 struct module module_entry =
166 {
167 .node = { NULL, NULL, NULL },
168 .name = NULL,
169 .version = "$Revision$",
170 .handle = NULL,
171 .modinit = module_init,
172 .modexit = module_exit,
173 .flags = 0
174 };

Properties

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