ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_hash.c
Revision: 1826
Committed: Mon Apr 15 09:09:09 2013 UTC (13 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 3864 byte(s)
Log Message:
- Minor cleanups to hash.c; removed now unused functions, style cleanups

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    
52     for (i = 0; i < HASHSIZE; ++i)
53     {
54     if ((cl = hash_get_bucket(HASH_TYPE_CLIENT, i)) != NULL)
55     {
56     int len = 0;
57    
58     ++buckets;
59     for (; cl != NULL; cl = cl->hnext)
60     ++len;
61     if (len > max_chain)
62     max_chain = len;
63     count += len;
64     }
65     }
66    
67     sendto_one(source_p, ":%s NOTICE %s :Client: entries: %d buckets: %d "
68     "max chain: %d", me.name, source_p->name, count, buckets,
69     max_chain);
70    
71     count = 0;
72     buckets = 0;
73     max_chain = 0;
74    
75     for (i = 0; i < HASHSIZE; ++i)
76     {
77     if ((ch = hash_get_bucket(HASH_TYPE_CHANNEL, i)) != NULL)
78     {
79     int len = 0;
80    
81     ++buckets;
82     for (; ch != NULL; ch = ch->hnextch)
83     ++len;
84     if (len > max_chain)
85     max_chain = len;
86     count += len;
87     }
88     }
89    
90     sendto_one(source_p, ":%s NOTICE %s :Channel: entries: %d buckets: %d "
91     "max chain: %d", me.name, source_p->name, count, buckets,
92     max_chain);
93    
94     count = 0;
95     buckets = 0;
96     max_chain = 0;
97    
98     for (i = 0; i < HASHSIZE; ++i)
99     {
100     if ((icl = hash_get_bucket(HASH_TYPE_ID, i)) != NULL)
101     {
102     int len = 0;
103    
104     ++buckets;
105     for (; icl != NULL; icl = icl->idhnext)
106     ++len;
107     if (len > max_chain)
108     max_chain = len;
109     count += len;
110     }
111     }
112    
113     sendto_one(source_p, ":%s NOTICE %s :Id: entries: %d buckets: %d "
114     "max chain: %d", me.name, source_p->name, count, buckets,
115     max_chain);
116    
117     count = 0;
118     buckets = 0;
119     max_chain = 0;
120    
121     for (i = 0; i < HASHSIZE; ++i)
122     {
123     if ((ush = hash_get_bucket(HASH_TYPE_USERHOST, i)) != NULL)
124     {
125     int len = 0;
126    
127     ++buckets;
128     for (; ush != NULL; ush = ush->next)
129     ++len;
130     if (len > max_chain)
131     max_chain = len;
132     count += len;
133     }
134     }
135    
136     sendto_one(source_p, ":%s NOTICE %s :UserHost: entries: %d buckets: %d "
137     "max chain: %d", me.name, source_p->name, count, buckets,
138     max_chain);
139     }
140 michael 1230
141     static struct Message hash_msgtab = {
142     "HASH", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
143     { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_hash, m_ignore }
144     };
145    
146     static void
147     module_init(void)
148     {
149     mod_add_cmd(&hash_msgtab);
150     }
151    
152     static void
153     module_exit(void)
154     {
155     mod_del_cmd(&hash_msgtab);
156     }
157    
158     struct module module_entry = {
159     .node = { NULL, NULL, NULL },
160     .name = NULL,
161     .version = "$Revision$",
162     .handle = NULL,
163     .modinit = module_init,
164     .modexit = module_exit,
165     .flags = 0
166     };

Properties

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