Module: ngircd.git
Branch: master
Commit: 1765f0ae0b8932a4977c181c07d174f124143cef
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=1765f0ae…
Author: Florian Westphal <fw(a)strlen.de>
Date: Mon Jun 27 00:16:37 2011 +0200
hash: use more recent lookup3 algorithm instead of lookup2
Bob Jenkins published a newer hash function in May 2006, it has
better distribution.
See http://burtleburtle.net/bob/hash/doobs.html for lengthy
comparisions.
---
src/ngircd/hash.c | 82 ++++++++++++++++++++++++++++------------------------
1 files changed, 44 insertions(+), 38 deletions(-)
diff --git a/src/ngircd/hash.c b/src/ngircd/hash.c
index 113133d..7b7976c 100644
--- a/src/ngircd/hash.c
+++ b/src/ngircd/hash.c
@@ -26,8 +26,7 @@
#include "exp.h"
#include "hash.h"
-static UINT32 jenkins_hash PARAMS((register UINT8 *k, register UINT32 length,
- register UINT32 initval));
+static UINT32 jenkins_hash PARAMS((UINT8 *k, UINT32 length, UINT32 initval));
/**
* Calculate hash value for a given string.
@@ -46,66 +45,74 @@ Hash( const char *String )
} /* Hash */
/*
- * This hash function originates from lookup2.c of Bob Jenkins
- * (URL: <http://burtleburtle.net/bob/c/lookup2.c>):
+ * This hash function originates from lookup3.c of Bob Jenkins
+ * (URL: <http://burtleburtle.net/bob/c/lookup3.c>):
* --------------------------------------------------------------------
- * lookup2.c, by Bob Jenkins, December 1996, Public Domain.
- * hash(), hash2(), hash3, and mix() are externally useful functions.
- * Routines to test the hash are included if SELF_TEST is defined.
- * You can use this free for any purpose. It has no warranty.
+ * lookup3.c, by Bob Jenkins, May 2006, Public Domain.
+ * These are functions for producing 32-bit hashes for hash table lookup.
+ * hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
+ * are externally useful functions. Routines to test the hash are included
+ * if SELF_TEST is defined. You can use this free for any purpose. It's in
+ * the public domain. It has no warranty.
* --------------------------------------------------------------------
* Not all of his functions are used here.
*/
-#define hashsize(n) ((UINT32)1<<(n))
+#define hashsize(n) ((uint32_t)1<<(n))
#define hashmask(n) (hashsize(n)-1)
+#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
#define mix(a,b,c) \
{ \
- a -= b; a -= c; a ^= (c>>13); \
- b -= c; b -= a; b ^= (a<<8); \
- c -= a; c -= b; c ^= (b>>13); \
- a -= b; a -= c; a ^= (c>>12); \
- b -= c; b -= a; b ^= (a<<16); \
- c -= a; c -= b; c ^= (b>>5); \
- a -= b; a -= c; a ^= (c>>3); \
- b -= c; b -= a; b ^= (a<<10); \
- c -= a; c -= b; c ^= (b>>15); \
+ a -= c; a ^= rot(c, 4); c += b; \
+ b -= a; b ^= rot(a, 6); a += c; \
+ c -= b; c ^= rot(b, 8); b += a; \
+ a -= c; a ^= rot(c,16); c += b; \
+ b -= a; b ^= rot(a,19); a += c; \
+ c -= b; c ^= rot(b, 4); b += a; \
} /* mix */
+#define final(a,b,c) \
+{ \
+ c ^= b; c -= rot(b,14); \
+ a ^= c; a -= rot(c,11); \
+ b ^= a; b -= rot(a,25); \
+ c ^= b; c -= rot(b,16); \
+ a ^= c; a -= rot(c,4); \
+ b ^= a; b -= rot(a,14); \
+ c ^= b; c -= rot(b,24); \
+}
+
static UINT32
-jenkins_hash( register UINT8 *k, register UINT32 length, register UINT32 initval )
+jenkins_hash(UINT8 *k, UINT32 length, UINT32 initval)
{
/* k: the key
* length: length of the key
* initval: the previous hash, or an arbitrary value
*/
-
- register UINT32 a,b,c,len;
+ UINT32 a,b,c;
/* Set up the internal state */
- len = length;
- a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
- c = initval; /* the previous hash value */
+ a = b = c = 0xdeadbeef + length + initval;
/* handle most of the key */
- while (len >= 12)
- {
+ while (length > 12) {
a += (k[0] +((UINT32)k[1]<<8) +((UINT32)k[2]<<16) +((UINT32)k[3]<<24));
b += (k[4] +((UINT32)k[5]<<8) +((UINT32)k[6]<<16) +((UINT32)k[7]<<24));
c += (k[8] +((UINT32)k[9]<<8) +((UINT32)k[10]<<16)+((UINT32)k[11]<<24));
mix(a,b,c);
- k += 12; len -= 12;
+ length -= 12;
+ k += 12;
}
- /* handle the last 11 bytes */
- c += length;
- switch( (int)len ) /* all the case statements fall through */
+ /*-------------------------------- last block: affect all 32 bits of (c) */
+ switch(length) /* all the case statements fall through */
+
{
- case 11: c+=((UINT32)k[10]<<24);
- case 10: c+=((UINT32)k[9]<<16);
- case 9 : c+=((UINT32)k[8]<<8);
- /* the first byte of c is reserved for the length */
+ case 12: c+=((UINT32)k[11])<<24;
+ case 11: c+=((UINT32)k[10]<<16);
+ case 10: c+=((UINT32)k[9]<<8);
+ case 9 : c+=k[8];
case 8 : b+=((UINT32)k[7]<<24);
case 7 : b+=((UINT32)k[6]<<16);
case 6 : b+=((UINT32)k[5]<<8);
@@ -114,11 +121,10 @@ jenkins_hash( register UINT8 *k, register UINT32 length, register UINT32 initval
case 3 : a+=((UINT32)k[2]<<16);
case 2 : a+=((UINT32)k[1]<<8);
case 1 : a+=k[0];
- /* case 0: nothing left to add */
+ break;
+ case 0 : return c;
}
- mix(a,b,c);
-
- /* report the result */
+ final(a,b,c);
return c;
} /* jenkins_hash */
Module: ngircd.git
Branch: master
Commit: d99edb7728e058a889e4734f8592f495effa5bc3
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=d99edb77…
Author: Alexander Barton <alex(a)barton.de>
Date: Sun Jun 26 15:41:27 2011 +0200
Merge branch 'MorePrivacy'
* MorePrivacy:
New configuration opion "MorePrivacy" to "censor" some user information
---
Module: ngircd.git
Branch: master
Commit: 3282c1325e491f2fbc7ee388c557f40e1f9eaed6
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=3282c132…
Author: Alexander Barton <alex(a)barton.de>
Date: Sun Jun 26 15:24:07 2011 +0200
Merge branch 'newconfig'
* newconfig:
sample-ngircd.conf: "SyslogFacility" should be commented out
Move SSL-related configuration variables to new [SSL] section
CheckFileReadable(): only check when a filename is given ...
PAM: make clear which "Password" config option is ignored
Really remove [Features] in our manual pages
INSTALL: document changed location of configuration variables
Update sample config file and manual page for new config structure
Testsuite: update configuration files for new config file format
Display configuration errors more prominent on "--configtest"
conf.c: code cleanup
Check for redability of SSL-related files like for MOTD file
Restructure ngIRCd configuration, introduce [Limits] and [Options]
---
Module: ngircd.git
Branch: master
Commit: 3d0ce77f12117df9e12d364c725c3c54332901bd
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=3d0ce77f…
Author: Alexander Barton <alex(a)barton.de>
Date: Sun Jun 26 00:10:22 2011 +0200
sample-ngircd.conf: "SyslogFacility" should be commented out
---
doc/sample-ngircd.conf.tmpl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/doc/sample-ngircd.conf.tmpl b/doc/sample-ngircd.conf.tmpl
index 4079724..0f2e7ee 100644
--- a/doc/sample-ngircd.conf.tmpl
+++ b/doc/sample-ngircd.conf.tmpl
@@ -171,7 +171,7 @@
# user and local1 through local7 are possible values; see syslog(3).
# Default is "local5" for historical reasons, you probably want to
# change this to "daemon", for example.
- SyslogFacility = local1
+ ;SyslogFacility = local1
# Password required for using the WEBIRC command used by some
# Web-to-IRC gateways. If not set/empty, the WEBIRC command can't