]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/hash.c
Add valx arg to config_parse_add - indicate which value in the current
[openldap] / libraries / liblutil / hash.c
index f801ffe3179150a71777566e7da93d45ae95de48..6668ae2401e245092df3fa09d2ee649fd7fa8b35 100644 (file)
@@ -1,19 +1,30 @@
 /* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2000-2006 The OpenLDAP Foundation.
+ * Portions Copyright 2000-2003 Kurt D. Zeilenga.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+
 /* This implements the Fowler / Noll / Vo (FNV-1) hash algorithm.
  * A summary of the algorithm can be found at:
  *   http://www.isthe.com/chongo/tech/comp/fnv/index.html
  */
 
 #include "portable.h"
-#include <ac/string.h>
-
-/* include socket.h to get sys/types.h and/or winsock2.h */
-#include <ac/socket.h>
 
 #include <lutil_hash.h>
 
 /* offset and prime for 32-bit FNV-1 */
-#define HASH_OFFSET    0x811c9dc5
+#define HASH_OFFSET    0x811c9dc5U
 #define HASH_PRIME     16777619
 
 
@@ -33,8 +44,7 @@ void
 lutil_HASHUpdate(
     struct lutil_HASHContext   *ctx,
     const unsigned char                *buf,
-    ber_len_t          len
-)
+    ber_len_t          len )
 {
        const unsigned char *p, *e;
        ber_uint_t h;
@@ -60,8 +70,8 @@ lutil_HASHFinal( unsigned char *digest, struct lutil_HASHContext *ctx )
 {
        ber_uint_t h = ctx->hash;
 
-       digest[0] = h & 0xff;
-       digest[1] = (h>>8) & 0xff;
-       digest[2] = (h>>16) & 0xff;
-       digest[3] = (h>>24) & 0xff;
+       digest[0] = h & 0xffU;
+       digest[1] = (h>>8) & 0xffU;
+       digest[2] = (h>>16) & 0xffU;
+       digest[3] = (h>>24) & 0xffU;
 }