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