ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_hash.c
Revision: 1632
Committed: Sun Nov 4 15:37:10 2012 UTC (13 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 4394 byte(s)
Log Message:
- Initial rewrite of the configuration subsystem

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

Properties

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