]> jfr.im git - irc/rqf/shadowircd.git/commitdiff
Some hash stuff
authorValery Yatsko <redacted>
Wed, 2 Apr 2008 10:20:27 +0000 (14:20 +0400)
committerValery Yatsko <redacted>
Wed, 2 Apr 2008 10:20:27 +0000 (14:20 +0400)
include/hash.h
src/hash.c

index 9766022152728d0a85b349ce2857f36d13936692..01f0d74c5fd71dbce934931c2385c024b72edea5 100644 (file)
@@ -98,6 +98,10 @@ extern void del_from_resv_hash(const char *name, struct ConfItem *aconf);
 extern struct ConfItem *hash_find_resv(const char *name);
 extern void clear_resv_hash(void);
 
+void add_to_cli_fd_hash(struct Client *client_p);\r
+void del_from_cli_fd_hash(struct Client *client_p);\r
+struct Client *find_cli_fd_hash(int fd);
+
 extern void hash_stats(struct Client *);
 
 #endif /* INCLUDED_hash_h */
index 41829bbe6c0f55aa62bae9f51575a0b28a2adb93..980153027209632783a5d11bcec80fd838d7001c 100644 (file)
@@ -660,6 +660,37 @@ clear_resv_hash(void)
        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
+}
+
 static void
 output_hash(struct Client *source_p, const char *name, int length, int *counts, int deepest)
 {