*
* $Id$
*/
+#include "config.h"
+
#include "hash.h"
#include "client.h"
#include "channel.h"
#include "ircd_chattr.h"
#include "ircd_string.h"
#include "ircd.h"
+#include "msg.h"
#include "send.h"
#include "struct.h"
-#include "support.h"
#include "sys.h"
#include <assert.h>
be symmetric, if HASHEQ(a,b) then HASHEQ(b,a), obvious ok but... :) */
#define HASHEQ(x,y) ((ToLower(x)) == (ToLower(y)))
-/* hash_init
+/* init_hash
* Initialize the maps used by hash functions and clear the tables */
-void hash_init(void)
+void init_hash(void)
{
int i;
int j;
*/
int hAddClient(struct Client *cptr)
{
- HASHREGS hashv = strhash(cptr->name);
+ HASHREGS hashv = strhash(cli_name(cptr));
- cptr->hnext = clientTable[hashv];
+ cli_hnext(cptr) = clientTable[hashv];
clientTable[hashv] = cptr;
return 0;
*/
int hRemClient(struct Client *cptr)
{
- HASHREGS hashv = strhash(cptr->name);
+ HASHREGS hashv = strhash(cli_name(cptr));
struct Client *tmp = clientTable[hashv];
if (tmp == cptr) {
- clientTable[hashv] = cptr->hnext;
- cptr->hnext = cptr;
+ clientTable[hashv] = cli_hnext(cptr);
+ cli_hnext(cptr) = cptr;
return 0;
}
while (tmp) {
- if (tmp->hnext == cptr) {
- tmp->hnext = tmp->hnext->hnext;
- cptr->hnext = cptr;
+ if (cli_hnext(tmp) == cptr) {
+ cli_hnext(tmp) = cli_hnext(cli_hnext(tmp));
+ cli_hnext(cptr) = cptr;
return 0;
}
- tmp = tmp->hnext;
+ tmp = cli_hnext(tmp);
}
return -1;
}
assert(0 != cptr);
hRemClient(cptr);
- cptr->hnext = clientTable[newhash];
+ cli_hnext(cptr) = clientTable[newhash];
clientTable[newhash] = cptr;
return 0;
}
struct Client *cptr = clientTable[hashv];
if (cptr) {
- if (0 == (cptr->status & TMask) || 0 != ircd_strcmp(name, cptr->name)) {
+ if (0 == (cli_status(cptr) & TMask) || 0 != ircd_strcmp(name, cli_name(cptr))) {
struct Client* prev;
- while (prev = cptr, cptr = cptr->hnext) {
- if ((cptr->status & TMask) && (0 == ircd_strcmp(name, cptr->name))) {
- prev->hnext = cptr->hnext;
- cptr->hnext = clientTable[hashv];
+ while (prev = cptr, cptr = cli_hnext(cptr)) {
+ if ((cli_status(cptr) & TMask) && (0 == ircd_strcmp(name, cli_name(cptr)))) {
+ cli_hnext(prev) = cli_hnext(cptr);
+ cli_hnext(cptr) = clientTable[hashv];
clientTable[hashv] = cptr;
break;
}
struct Channel* ch;
int i;
- sendto_one(sptr, "NOTICE %s :Hash Table Statistics", parv[0]);
+ sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Hash Table Statistics", sptr);
for (i = 0; i < HASHSIZE; ++i) {
if ((cl = clientTable[i])) {
int len = 0;
++buckets;
- for ( ; cl; cl = cl->hnext)
+ for ( ; cl; cl = cli_hnext(cl))
++len;
if (len > max_chain)
max_chain = len;
}
}
- sendto_one(sptr, "NOTICE %s :Client: entries: %d buckets: %d max chain: %d",
- parv[0], count, buckets, max_chain);
+ sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Client: entries: %d buckets: %d "
+ "max chain: %d", sptr, count, buckets, max_chain);
buckets = 0;
count = 0;
}
}
- sendto_one(sptr, "NOTICE %s :Channel: entries: %d buckets: %d max chain: %d",
- parv[0], count, buckets, max_chain);
+ sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Channel: entries: %d buckets: %d "
+ "max chain: %d", sptr, count, buckets, max_chain);
return 0;
}