ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_hash.c
Revision: 1011
Committed: Fri Sep 18 10:14:09 2009 UTC (15 years, 11 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.2/modules/m_hash.c
File size: 4429 byte(s)
Log Message:
- move list manipulation routines from tools.c to list.c
- mem_frob() goes to memory.c
- sort out redundant/unneeded header includes

File Contents

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

Properties

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