#include "client.h"
#include "common.h"
#include "hash.h"
-#include "irc_string.h"
+#include "match.h"
#include "ircd.h"
#include "numeric.h"
#include "send.h"
#include "msg.h"
#include "cache.h"
#include "s_newconf.h"
+#include "s_assert.h"
#define hash_cli_fd(x) (x % CLI_FD_MAX)
rb_dlink_list *channelTable;
rb_dlink_list *idTable;
rb_dlink_list *resvTable;
-rb_dlink_list *hostTable;
+rb_dlink_list *hostTable;
/*
* look in whowas.c for the missing ...[WW_MAX]; entry
*
* A - GOPbot, B - chang, C - hanuaway, D - *.mu.OZ.AU
*
- * The order shown above is just one instant of the server.
+ * The order shown above is just one instant of the server.
*
*
* The hash functions currently used are based Fowler/Noll/Vo hashes
* which work amazingly well and have a extremely low collision rate
* For more info see http://www.isthe.com/chongo/tech/comp/fnv/index.html
*
- *
+ *
*/
/* init_hash()
}
/* del_from_channel_hash()
- *
+ *
* removes a channel from the channel hash table
*/
void
struct Client *target_p;
rb_dlink_node *ptr;
unsigned int hashv;
-
+
if(EmptyString(name))
return NULL;
- if((source_p == NULL || !MyClient(source_p)) &&
+ if((source_p == NULL || !MyClient(source_p)) &&
IsDigit(*name) && strlen(name) == 3)
{
target_p = find_id(name);
{
aconf = ptr->data;
- if(!irccmp(name, aconf->name))
+ if(!irccmp(name, aconf->host))
{
aconf->port++;
return aconf;
HASH_WALK_END
}
-void\r
-add_to_cli_fd_hash(struct Client *client_p)\r
-{\r
- rb_dlinkAddAlloc(client_p, &clientbyfdTable[hash_cli_fd(rb_get_fd(client_p->localClient->F))]);\r
-}\r
-\r
-\r
-void\r
-del_from_cli_fd_hash(struct Client *client_p)\r
-{\r
- unsigned int hashv;\r
- hashv = hash_cli_fd(rb_get_fd(client_p->localClient->F));\r
- rb_dlinkFindDestroy(client_p, &clientbyfdTable[hashv]);\r
-}\r
-\r
-struct Client *\r
-find_cli_fd_hash(int fd)\r
-{\r
- struct Client *target_p;\r
- rb_dlink_node *ptr;\r
- unsigned int hashv;\r
- hashv = hash_cli_fd(fd);\r
- RB_DLINK_FOREACH(ptr, clientbyfdTable[hashv].head)\r
- {\r
- target_p = ptr->data;\r
- if(rb_get_fd(target_p->localClient->F) == fd)\r
- return target_p;\r
- }\r
- return NULL; \r
+void
+add_to_cli_fd_hash(struct Client *client_p)
+{
+ rb_dlinkAddAlloc(client_p, &clientbyfdTable[hash_cli_fd(rb_get_fd(client_p->localClient->F))]);
+}
+
+
+void
+del_from_cli_fd_hash(struct Client *client_p)
+{
+ unsigned int hashv;
+ hashv = hash_cli_fd(rb_get_fd(client_p->localClient->F));
+ rb_dlinkFindDestroy(client_p, &clientbyfdTable[hashv]);
+}
+
+struct Client *
+find_cli_fd_hash(int fd)
+{
+ struct Client *target_p;
+ rb_dlink_node *ptr;
+ unsigned int hashv;
+ hashv = hash_cli_fd(fd);
+ RB_DLINK_FOREACH(ptr, clientbyfdTable[hashv].head)
+ {
+ target_p = ptr->data;
+ if(rb_get_fd(target_p->localClient->F) == fd)
+ return target_p;
+ }
+ return NULL;
}
static void
-output_hash(struct Client *source_p, const char *name, int length, int *counts, int deepest)
+output_hash(struct Client *source_p, const char *name, int length, int *counts, unsigned long deepest)
{
unsigned long total = 0;
int i;
(float) (total / (length - counts[0])),
(float) (total / length));
sendto_one_numeric(source_p, RPL_STATSDEBUG,
- "B :Average depth: %s Highest depth: %d",
+ "B :Average depth: %s Highest depth: %lu",
buf, deepest);
}
i, counts[i]);
}
}
-
+
static void
count_hash(struct Client *source_p, rb_dlink_list *table, int length, const char *name)
{
int counts[11];
- int deepest = 0;
+ unsigned long deepest = 0;
int i;
memset(counts, 0, sizeof(counts));
-
+
for(i = 0; i < length; i++)
{
if(rb_dlink_list_length(&table[i]) >= 10)
count_hash(source_p, idTable, U_MAX, "ID");
sendto_one_numeric(source_p, RPL_STATSDEBUG, "B :--");
count_hash(source_p, hostTable, HOST_MAX, "Hostname");
-}
+}