ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_hash.c
Revision: 1178
Committed: Mon Aug 15 08:11:31 2011 UTC (12 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 4405 byte(s)
Log Message:
- Cleanup and restore older parts of the irc-command parser.
  Gives back ability to specify maximum amount of parameters
  that are processed within a command.

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 "list.h"
26 #include "handlers.h"
27 #include "channel.h"
28 #include "channel_mode.h"
29 #include "client.h"
30 #include "hash.h"
31 #include "irc_string.h"
32 #include "ircd.h"
33 #include "numeric.h"
34 #include "s_conf.h"
35 #include "s_serv.h"
36 #include "send.h"
37 #include "msg.h"
38 #include "parse.h"
39 #include "modules.h"
40 #include "s_user.h"
41 #include "resv.h"
42 #include "userhost.h"
43
44 static void mo_hash(struct Client *, struct Client *, int, char *[]);
45
46
47 struct Message hash_msgtab = {
48 "HASH", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
49 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_hash, m_ignore }
50 };
51
52 void
53 _modinit(void)
54 {
55 mod_add_cmd(&hash_msgtab);
56 }
57
58 void
59 _moddeinit(void)
60 {
61 mod_del_cmd(&hash_msgtab);
62 }
63
64 const char *_version = "$Revision$";
65
66 static void
67 mo_hash(struct Client *client_p, struct Client *source_p,
68 int parc, char *parv[])
69 {
70 int i;
71 int max_chain = 0;
72 int buckets = 0;
73 int count = 0;
74 struct Client *cl;
75 struct Client *icl;
76 struct Channel *ch;
77 struct UserHost *ush;
78 struct ResvChannel *rch;
79
80 for (i = 0; i < HASHSIZE; ++i)
81 {
82 if ((cl = hash_get_bucket(HASH_TYPE_CLIENT, i)) != NULL)
83 {
84 int len = 0;
85
86 ++buckets;
87 for (; cl != NULL; cl = cl->hnext)
88 ++len;
89 if (len > max_chain)
90 max_chain = len;
91 count += len;
92 }
93 }
94
95 sendto_one(source_p, ":%s NOTICE %s :Client: entries: %d buckets: %d "
96 "max chain: %d", me.name, source_p->name, count, buckets,
97 max_chain);
98
99 count = 0;
100 buckets = 0;
101 max_chain = 0;
102
103 for (i = 0; i < HASHSIZE; ++i)
104 {
105 if ((ch = hash_get_bucket(HASH_TYPE_CHANNEL, i)) != NULL)
106 {
107 int len = 0;
108
109 ++buckets;
110 for (; ch != NULL; ch = ch->hnextch)
111 ++len;
112 if (len > max_chain)
113 max_chain = len;
114 count += len;
115 }
116 }
117
118 sendto_one(source_p, ":%s NOTICE %s :Channel: entries: %d buckets: %d "
119 "max chain: %d", me.name, source_p->name, count, buckets,
120 max_chain);
121
122 count = 0;
123 buckets = 0;
124 max_chain = 0;
125
126 for (i = 0; i < HASHSIZE; ++i)
127 {
128 if ((rch = hash_get_bucket(HASH_TYPE_RESERVED, i)) != NULL)
129 {
130 int len = 0;
131
132 ++buckets;
133 for (; rch != NULL; rch = rch->hnext)
134 ++len;
135 if (len > max_chain)
136 max_chain = len;
137 count += len;
138 }
139 }
140
141 sendto_one(source_p, ":%s NOTICE %s :Resv: entries: %d buckets: %d "
142 "max chain: %d", me.name, source_p->name, count, buckets,
143 max_chain);
144
145 count = 0;
146 buckets = 0;
147 max_chain = 0;
148
149 for (i = 0; i < HASHSIZE; ++i)
150 {
151 if ((icl = hash_get_bucket(HASH_TYPE_ID, i)) != NULL)
152 {
153 int len = 0;
154
155 ++buckets;
156 for (; icl != NULL; icl = icl->idhnext)
157 ++len;
158 if (len > max_chain)
159 max_chain = len;
160 count += len;
161 }
162 }
163
164 sendto_one(source_p, ":%s NOTICE %s :Id: entries: %d buckets: %d "
165 "max chain: %d", me.name, source_p->name, count, buckets,
166 max_chain);
167
168 count = 0;
169 buckets = 0;
170 max_chain = 0;
171
172 for (i = 0; i < HASHSIZE; ++i)
173 {
174 if ((ush = hash_get_bucket(HASH_TYPE_USERHOST, i)) != NULL)
175 {
176 int len = 0;
177
178 ++buckets;
179 for (; ush != NULL; ush = ush->next)
180 ++len;
181 if (len > max_chain)
182 max_chain = len;
183 count += len;
184 }
185 }
186
187 sendto_one(source_p, ":%s NOTICE %s :UserHost: entries: %d buckets: %d "
188 "max chain: %d", me.name, source_p->name, count, buckets,
189 max_chain);
190 }

Properties

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