ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_hash.c
Revision: 69
Committed: Tue Oct 4 16:09:51 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 4387 byte(s)
Log Message:
- splitted ircd/libio, all headers connected with libio sources have been
  moved for internal use only. To use libio interface, include "libio.h"
  (which is already done in "stdinc.h")


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     #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 knight 31 const char *_version = "$Revision$";
64 adx 30 #endif
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