X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fhash.c;h=d9aa79bb1f1b93478a9f1dd7c0e135ac7ed62408;hp=876b92f5e41c18fc222151dc28a573839ea4677a;hb=3243d9ee441e9cd4338965bac7c2ed3b49a3c2dd;hpb=95a4b1b1587f33692830153d6d03081b5e51d172 diff --git a/src/ngircd/hash.c b/src/ngircd/hash.c index 876b92f5..d9aa79bb 100644 --- a/src/ngircd/hash.c +++ b/src/ngircd/hash.c @@ -2,45 +2,42 @@ * ngIRCd -- The Next Generation IRC Daemon * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de) * - * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen - * der GNU General Public License (GPL), wie von der Free Software Foundation - * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2 - * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version. - * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste - * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * Please read the file COPYING, README and AUTHORS for more information. * - * $Id: hash.c,v 1.4 2002/03/25 19:11:01 alex Exp $ - * - * hash.c: Hash-Werte berechnen + * Hash calculation */ #include "portab.h" +static char UNUSED id[] = "$Id: hash.c,v 1.13 2006/10/06 21:23:47 fw Exp $"; + #include "imp.h" #include #include #include "defines.h" -#include "log.h" #include "tool.h" #include "exp.h" #include "hash.h" -LOCAL UINT32 jenkins_hash( register UINT8 *k, register UINT32 length, register UINT32 initval); +static UINT32 jenkins_hash PARAMS(( register UINT8 *k, register UINT32 length, register UINT32 initval )); -GLOBAL UINT32 Hash( CHAR *String ) +GLOBAL UINT32 +Hash( const char *String ) { /* Hash-Wert ueber String berechnen */ - CHAR buffer[LINE_LEN]; + char buffer[LINE_LEN]; - strncpy( buffer, String, LINE_LEN - 1 ); - buffer[LINE_LEN - 1] = '\0'; - + strlcpy( buffer, String, sizeof( buffer )); return jenkins_hash( (UINT8 *)ngt_LowerStr( buffer ), strlen( buffer ), 42 ); } /* Hash */ @@ -75,7 +72,8 @@ GLOBAL UINT32 Hash( CHAR *String ) } /* mix */ -LOCAL UINT32 jenkins_hash( register UINT8 *k, register UINT32 length, register UINT32 initval) +static UINT32 +jenkins_hash( register UINT8 *k, register UINT32 length, register UINT32 initval ) { /* k: the key * length: length of the key @@ -101,7 +99,7 @@ LOCAL UINT32 jenkins_hash( register UINT8 *k, register UINT32 length, register U /* handle the last 11 bytes */ c += length; - switch(len) /* all the case statements fall through */ + switch( (int)len ) /* all the case statements fall through */ { case 11: c+=((UINT32)k[10]<<24); case 10: c+=((UINT32)k[9]<<16);