diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./config/Makefile.config.in ./config/Makefile.config.in
--- ./config/Makefile.config.in	2005-10-09 17:51:43.000000000 +0200
+++ ./config/Makefile.config.in	2005-11-29 02:58:41.000000000 +0100
@@ -8,6 +8,7 @@
 CONFIG_INCLUDES=@CONFIG_INCLUDES@
 
 OCAMLC=@OCAMLC@
+OCAMLLIB=@OCAMLLIB@
 OCAMLOPT=@OCAMLOPT@ -inline 10
 OCAMLLEX=@OCAMLLEX@
 OCAMLDEP=@OCAMLDEP@ @OCAMLDEP_OPTIONS@
@@ -55,8 +56,6 @@
 PTHREAD_LIBS=@PTHREAD_LIBS@
 PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
 
-SHA1_VERSION=@SHA1_VERSION@
-
 CURRENT_VERSION=@MLDONKEY_VERSION@
 
 OS_FILES=@OS_FILES@
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./config/Makefile.in ./config/Makefile.in
--- ./config/Makefile.in	2005-11-27 15:04:33.000000000 +0100
+++ ./config/Makefile.in	2005-11-29 03:16:28.000000000 +0100
@@ -213,7 +213,7 @@
   $(LIB)/avifile.ml $(LIB)/http_lexer.mll $(LIB)/url.ml \
   $(LIB)/date.ml  $(LIB)/fst_hash.c \
   $(LIB)/md4_comp.c $(LIB)/md4_c.c \
-  $(LIB)/gettext.ml4 $(LIB)/md5_c.c $(LIB)/$(SHA1_VERSION)_c.c \
+  $(LIB)/gettext.ml4 $(LIB)/md5_c.c $(LIB)/sha1_c.c \
   $(LIB)/tiger.c \
   $(LIB)/CryptoPP.cc \
   $(LIB)/stubs_c.c  $(LIB)/set2.ml $(LIB)/queues.ml \
@@ -1690,7 +1690,6 @@
 	rm -f src/utils/lib/autoconf.ml.new
 	rm -f src/utils/lib/gAutoconf.ml
 	rm -f src/utils/lib/gAutoconf.ml.new
-	rm -f src/utils/lib/endian.h
 	rm -f src/utils/lib/misc2.ml
 	rm -f src/utils/cdk/tar.ml
 	rm -f src/utils/cdk/tar.mli
@@ -2037,7 +2036,7 @@
 	$(OCAMLC) -verbose -ccopt "-I $(OCAML_SRC)/byterun -o $*.o" -ccopt "$(CFLAGS)" $(LIBS_flags) -c $<
 
 .cc.o :
-	$(CXX) $(CXXFLAGS) -o $*.o -c $<
+	$(CXX) $(CXXFLAGS) -o $*.o -I$(OCAMLLIB) -c $<
 
 .cmo.byte:
 	$(OCAMLC) -o $*.byte $(LIBS) $<
@@ -2049,12 +2048,8 @@
 .plugindep:
 	echo toto
 
-src/utils/lib/sha1old_c.o: src/utils/lib/sha1old_c.h \
-  src/utils/lib/sha1_c.h src/utils/lib/os_stubs.h
-
-
-src/utils/lib/sha1new_c.o: src/utils/lib/sha1new_c.h \
-  src/utils/lib/sha1_c.h src/utils/lib/os_stubs.h
+src/utils/lib/sha1_c.o: src/utils/lib/sha1_c.h \
+  src/utils/lib/os_stubs.h
 
 src/daemon/common/commonHasher_c.o: src/utils/lib/sha1_c.h
 src/utils/lib/stubs_c.o: src/utils/lib/sha1_c.h
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./config/config.h.in ./config/config.h.in
--- ./config/config.h.in	2005-09-08 14:44:52.000000000 +0200
+++ ./config/config.h.in	2005-11-29 02:58:41.000000000 +0100
@@ -3,9 +3,6 @@
 /* Define to 1 if you want to replace iconv and related with stubs. */
 #undef DISABLE_ICONV
 
-/* Define to 1 if you want to use the faster sha1new implementation. */
-#undef ENABLE_SHA1NEW
-
 /* Define to 1 if you have the <arpa/inet.h> header file. */
 #undef HAVE_ARPA_INET_H
 
@@ -33,12 +30,6 @@
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
-/* Define to 1 if you have a locally generated endian.h header file. */
-#undef HAVE_LOCAL_ENDIAN_H
-
-/* Define to 1 if you have the <machine/endian.h> header file. */
-#undef HAVE_MACHINE_ENDIAN_H
-
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
@@ -69,9 +60,6 @@
 /* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
 
-/* Define to 1 if you have the <sys/endian.h> header file. */
-#undef HAVE_SYS_ENDIAN_H
-
 /* Define to 1 if you have the <sys/poll.h> header file. */
 #undef HAVE_SYS_POLL_H
 
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./config/configure.in ./config/configure.in
--- ./config/configure.in	2005-11-23 00:17:45.000000000 +0100
+++ ./config/configure.in	2005-11-29 03:17:02.000000000 +0100
@@ -500,6 +500,7 @@
 AC_PATH_PROG(PERL, perl, perl)
 
 OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
+OCAMLLIB=`$OCAMLC -where`
 REBUILD_OCAML=no
 case "$OCAMLVERSION" in
     "$REQUIRED_OCAML"*) ;;
@@ -614,25 +615,6 @@
 fi
 
 AC_CHECK_HEADERS(byteswap.h,,)
-AC_CHECK_HEADERS(endian.h sys/endian.h machine/endian.h,[SHA1_VERSION=sha1new; break],[SHA1_VERSION=sha1old])
-if test "$SHA1_VERSION" = "sha1old"; then
-    AC_MSG_CHECKING(trying to guess endianess)
-    $CC -o endian endian.c
-    BYTE_ORDER="`./endian | grep BYTE_ORDER | cut -c24-40`"
-    if test "$BYTE_ORDER" = "" ; then
-        echo "You don't have endian.h or sys/endian.h or machine/endian.h installed."
-        echo "This script will fallback on the old slower sha1 implementation."
-    else
-        AC_MSG_RESULT($BYTE_ORDER)
-        ./endian > ../src/utils/lib/endian.h
-        SHA1_VERSION=sha1new
-        AC_DEFINE(HAVE_LOCAL_ENDIAN_H, 1, [Define to 1 if you have a locally generated endian.h header file.])
-        AC_DEFINE(ENABLE_SHA1NEW, 1, [Define to 1 if you want to use the faster sha1new implementation.])
-    fi
-    rm -f ./endian ./endian.exe
-else
-    AC_DEFINE(ENABLE_SHA1NEW, 1, [Define to 1 if you want to use the faster sha1new implementation.])
-fi
 
 if test "$ICONV" = "yes"; then
   AM_ICONV
@@ -1134,6 +1116,7 @@
 
 AC_SUBST(TYPE_FORMAT)
 AC_SUBST(OCAMLC)
+AC_SUBST(OCAMLLIB)
 AC_SUBST(OCAMLOPT)
 AC_SUBST(OCAMLLEX)
 AC_SUBST(OCAMLYACC)
@@ -1144,7 +1127,6 @@
 AC_SUBST(OCAMLMKTOP)
 AC_SUBST(SYSTEM)
 
-AC_SUBST(SHA1_VERSION)
 AC_SUBST(MORE_TARGETS)
 AC_SUBST(MORE_SUBDIRS)
 AC_SUBST(LABLGL_CMA)
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./config/endian.c ./config/endian.c
--- ./config/endian.c	2005-05-17 15:18:05.000000000 +0200
+++ ./config/endian.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,19 +0,0 @@
-#include <stdio.h>
-
-int litend() {
-	int i = 0;
-	((char *)(&i))[0] = 1;
-	return(i == 1);
-}
-
-int bigend() {
-	return !litend();
-}
-
-int main() {
-	printf("#define __LITTLE_ENDIAN 1234\n");
-	printf("#define __BIG_ENDIAN    4321\n");
-	printf("#define __BYTE_ORDER __%s_ENDIAN\n",
-	  litend() ? "LITTLE" : "BIG");
-	exit(0);
-}
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/config/unix/os_stubs_c.c ./src/config/unix/os_stubs_c.c
--- ./src/config/unix/os_stubs_c.c	2005-10-06 12:50:31.000000000 +0200
+++ ./src/config/unix/os_stubs_c.c	2005-11-29 02:58:41.000000000 +0100
@@ -113,7 +113,7 @@
 
 }
 
-int glibc_version(void)
+value glibc_version(void)
 {
   CAMLparam0 ();
   CAMLlocal1 (v);
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/daemon/common/commonComplexOptions.ml ./src/daemon/common/commonComplexOptions.ml
--- ./src/daemon/common/commonComplexOptions.ml	2005-11-12 21:07:01.000000000 +0100
+++ ./src/daemon/common/commonComplexOptions.ml	2005-11-29 02:58:41.000000000 +0100
@@ -1083,7 +1083,7 @@
       ^ (if Autoconf.scm_version <> "" then "\nSCM version info: " ^ Autoconf.scm_version else "")
       ^ "\nNetworks: " ^ !networks_string
       ^ "\nOcaml version: " ^ Sys.ocaml_version
-      ^ "\nBuild on: " ^ Autoconf.build_system
+      ^ "\nBuild on: " ^ Autoconf.build_system ^ " (" ^ Unix2.endianness () ^ ")"
       ^ (if Autoconf.glibc_version = "" then "" 
           else
             let real_glibc_version = MlUnix.glibc_version_num () in
@@ -1124,7 +1124,6 @@
 	  ^ (if not Autoconf.has_gd then " no-gd" else "")
           ^ (if Autoconf.has_iconv then " iconv" else " no-iconv")
           ^ (if Autoconf.check_bounds then " check-bounds" else " no-check-bounds")
-          ^ " " ^ Autoconf.sha1_version
   )
   
 let runinfo () =
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/cdk/unix2.ml ./src/utils/cdk/unix2.ml
--- ./src/utils/cdk/unix2.ml	2005-10-17 17:25:46.000000000 +0200
+++ ./src/utils/cdk/unix2.ml	2005-11-29 02:58:41.000000000 +0100
@@ -133,6 +133,8 @@
 external c_getdtablesize : unit -> int = "ml_getdtablesize"
 external c_sizeofoff_t : unit -> int = "ml_sizeofoff_t"
 
+external endianness : unit -> string = "ml_check_endianness"
+
 let rec remove_all_directory dirname =
   let files = list_directory dirname in
   List.iter (fun file ->
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/CryptoPP.h ./src/utils/lib/CryptoPP.h
--- ./src/utils/lib/CryptoPP.h	2005-10-06 12:50:31.000000000 +0200
+++ ./src/utils/lib/CryptoPP.h	2005-11-29 02:58:41.000000000 +0100
@@ -86,6 +86,7 @@
 #define CRYPTOPP_H
 
 #include <inttypes.h>
+#include <caml/config.h>
 
 ////////////////////////////////////////////////////////////////////////////////
 #ifndef CRYPTOPP_CONFIG_H5392
@@ -93,17 +94,15 @@
 
 // ***************** Important Settings ********************
 
-// define this if running on a big-endian CPU
-#if !defined(IS_LITTLE_ENDIAN) && (defined(__BIG_ENDIAN__) || defined(__sparc) || defined(__sparc__) || defined(__hppa__) || defined(__mips__) || (defined(__MWERKS__) && !defined(__INTEL__)))
-#	define IS_BIG_ENDIAN
-#endif
-
 // define this if running on a little-endian CPU
 // big endian will be assumed if IS_LITTLE_ENDIAN is not defined
-#ifndef IS_BIG_ENDIAN
+#ifndef ARCH_BIG_ENDIAN
 #	define IS_LITTLE_ENDIAN
 #endif
 
+// override #define in caml/compatability.h
+#undef flush 
+
 // define this if you want to disable all OS-dependent features,
 // such as sockets and OS-provided random number generators
 // #define NO_OS_DEPENDENCE
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/autoconf.ml.new.in ./src/utils/lib/autoconf.ml.new.in
--- ./src/utils/lib/autoconf.ml.new.in	2005-10-06 12:21:10.000000000 +0200
+++ ./src/utils/lib/autoconf.ml.new.in	2005-11-29 02:58:41.000000000 +0100
@@ -46,6 +46,4 @@
 let zlib__compress_string s = Zlib.compress_string s
 let zlib__gzip_string s = Zlib.gzip_string s
 
-let sha1_version = "@SHA1_VERSION@"
-
 @TYPE_FORMAT@
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/md5_c.c ./src/utils/lib/md5_c.c
--- ./src/utils/lib/md5_c.c	2003-11-20 17:43:25.000000000 +0100
+++ ./src/utils/lib/md5_c.c	2005-11-29 03:14:07.000000000 +0100
@@ -40,6 +40,7 @@
 #include "md5.h"
 #include "os_stubs.h"
 #include <string.h>
+#include <caml/config.h>
 
 #ifdef TEST
 /*
@@ -171,10 +172,7 @@
 	c = pms->abcd[2], d = pms->abcd[3];
     md5_word_t t;
 
-#ifndef ARCH_IS_BIG_ENDIAN
-# define ARCH_IS_BIG_ENDIAN 1	/* slower, default implementation */
-#endif
-#if ARCH_IS_BIG_ENDIAN
+#if defined(ARCH_BIG_ENDIAN)
 
     /*
      * On big-endian machines, we must arrange the bytes in the right
@@ -187,7 +185,7 @@
     for (i = 0; i < 16; ++i, xp += 4)
 	X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
 
-#else  /* !ARCH_IS_BIG_ENDIAN */
+#else  /* !ARCH_BIG_ENDIAN */
 
     /*
      * On little-endian machines, we can process properly aligned data
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/sha1_c.c ./src/utils/lib/sha1_c.c
--- ./src/utils/lib/sha1_c.c	1970-01-01 01:00:00.000000000 +0100
+++ ./src/utils/lib/sha1_c.c	2005-11-29 02:59:11.000000000 +0100
@@ -0,0 +1,296 @@
+/*
+ ---------------------------------------------------------------------------
+ Copyright (c) 2002, Dr Brian Gladman, Worcester, UK.   All rights reserved.
+
+ LICENSE TERMS
+
+ The free distribution and use of this software in both source and binary
+ form is allowed (with or without changes) provided that:
+
+   1. distributions of this source code include the above copyright
+      notice, this list of conditions and the following disclaimer;
+
+   2. distributions in binary form include the above copyright
+      notice, this list of conditions and the following disclaimer
+      in the documentation and/or other associated materials;
+
+   3. the copyright holder's name is not used to endorse products
+      built using this software without specific written permission.
+
+ ALTERNATIVELY, provided that this notice is retained in full, this product
+ may be distributed under the terms of the GNU General Public License (GPL),
+ in which case the provisions of the GPL apply INSTEAD OF those given above.
+
+ DISCLAIMER
+
+ This software is provided 'as is' with no explicit or implied warranties
+ in respect of its properties, including, but not limited to, correctness
+ and/or fitness for purpose.
+ ---------------------------------------------------------------------------
+ Issue Date: 16/01/2004
+
+ This is a byte oriented version of SHA1 that operates on arrays of bytes
+ stored in memory. It runs at 22 cycles per byte on a Pentium P4 processor
+ */
+
+/*
+    This file is part of mldonkey.
+
+    mldonkey 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.
+
+    mldonkey is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mldonkey; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+     */
+
+/*swap order of arguments in sha1_hash and sha1_end to 'fit' mldonkey*/
+
+#include <string.h>     /* for memcpy() etc.        */
+#include <stdlib.h>     /* for _lrotl with VC++     */
+#include <caml/config.h>
+#include "sha1_c.h"
+
+#if defined(HAVE_BYTESWAP_H)
+#  include <byteswap.h>
+#endif
+
+#define BRG_LITTLE_ENDIAN   1234 /* byte 0 is least significant (i386) */
+#define BRG_BIG_ENDIAN      4321 /* byte 0 is most significant (mc68k) */
+
+#ifdef ARCH_BIG_ENDIAN
+#      define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
+#else
+#      define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
+#endif
+
+#if defined(__cplusplus)
+extern "C"
+    {
+#endif
+
+#ifdef _MSC_VER
+#pragma intrinsic(memcpy)
+#endif
+
+#if 0 && defined(_MSC_VER)
+#define rotl32  _lrotl
+#define rotr32  _lrotr
+#else
+#define rotl32(x,n)   (((x) << n) | ((x) >> (32 - n)))
+#define rotr32(x,n)   (((x) >> n) | ((x) << (32 - n)))
+#endif
+
+#if !defined(bswap_32)
+#define bswap_32(x) (rotr32((x), 24) & 0x00ff00ff | rotr32((x), 8) & 0xff00ff00)
+#endif
+
+#if (PLATFORM_BYTE_ORDER == BRG_LITTLE_ENDIAN)
+#define SWAP_BYTES
+#else
+#undef  SWAP_BYTES
+#endif
+
+#if defined(SWAP_BYTES)
+#define bsw_32(p,n) \
+    { int _i = (n); while(_i--) ((sha1_32t*)p)[_i] = bswap_32(((sha1_32t*)p)[_i]); }
+#else
+#define bsw_32(p,n)
+#endif
+
+#define SHA1_MASK   (SHA1_BLOCK_SIZE - 1)
+
+#if 0
+
+#define ch(x,y,z)       (((x) & (y)) ^ (~(x) & (z)))
+#define parity(x,y,z)   ((x) ^ (y) ^ (z))
+#define maj(x,y,z)      (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
+
+#else   /* Discovered by Rich Schroeppel and Colin Plumb   */
+
+#define ch(x,y,z)       ((z) ^ ((x) & ((y) ^ (z))))
+#define parity(x,y,z)   ((x) ^ (y) ^ (z))
+#define maj(x,y,z)      (((x) & (y)) | ((z) & ((x) ^ (y))))
+
+#endif
+
+/* Compile 64 bytes of hash data into SHA1 context. Note    */
+/* that this routine assumes that the byte order in the     */
+/* ctx->wbuf[] at this point is in such an order that low   */
+/* address bytes in the ORIGINAL byte stream in this buffer */
+/* will go to the high end of 32-bit words on BOTH big and  */
+/* little endian systems                                    */
+
+#ifdef ARRAY
+#define q(v,n)  v[n]
+#else
+#define q(v,n)  v##n
+#endif
+
+#define one_cycle(v,a,b,c,d,e,f,k,h)            \
+    q(v,e) += rotr32(q(v,a),27) +               \
+              f(q(v,b),q(v,c),q(v,d)) + k + h;  \
+    q(v,b)  = rotr32(q(v,b), 2)
+
+#define five_cycle(v,f,k,i)                 \
+    one_cycle(v, 0,1,2,3,4, f,k,hf(i  ));   \
+    one_cycle(v, 4,0,1,2,3, f,k,hf(i+1));   \
+    one_cycle(v, 3,4,0,1,2, f,k,hf(i+2));   \
+    one_cycle(v, 2,3,4,0,1, f,k,hf(i+3));   \
+    one_cycle(v, 1,2,3,4,0, f,k,hf(i+4))
+
+void sha1_compile(sha1_context ctx[1])
+{   sha1_32t    *w = ctx->wbuf;
+
+#ifdef ARRAY
+    sha1_32t    v[5];
+    memcpy(v, ctx->hash, 5 * sizeof(sha1_32t));
+#else
+    sha1_32t    v0, v1, v2, v3, v4;
+    v0 = ctx->hash[0]; v1 = ctx->hash[1];
+    v2 = ctx->hash[2]; v3 = ctx->hash[3];
+    v4 = ctx->hash[4];
+#endif
+
+#define hf(i)   w[i]
+
+    five_cycle(v, ch, 0x5a827999,  0);
+    five_cycle(v, ch, 0x5a827999,  5);
+    five_cycle(v, ch, 0x5a827999, 10);
+    one_cycle(v,0,1,2,3,4, ch, 0x5a827999, hf(15)); \
+
+#undef  hf
+#define hf(i) (w[(i) & 15] = rotl32(                    \
+                 w[((i) + 13) & 15] ^ w[((i) + 8) & 15] \
+               ^ w[((i) +  2) & 15] ^ w[(i) & 15], 1))
+
+    one_cycle(v,4,0,1,2,3, ch, 0x5a827999, hf(16));
+    one_cycle(v,3,4,0,1,2, ch, 0x5a827999, hf(17));
+    one_cycle(v,2,3,4,0,1, ch, 0x5a827999, hf(18));
+    one_cycle(v,1,2,3,4,0, ch, 0x5a827999, hf(19));
+
+    five_cycle(v, parity, 0x6ed9eba1,  20);
+    five_cycle(v, parity, 0x6ed9eba1,  25);
+    five_cycle(v, parity, 0x6ed9eba1,  30);
+    five_cycle(v, parity, 0x6ed9eba1,  35);
+
+    five_cycle(v, maj, 0x8f1bbcdc,  40);
+    five_cycle(v, maj, 0x8f1bbcdc,  45);
+    five_cycle(v, maj, 0x8f1bbcdc,  50);
+    five_cycle(v, maj, 0x8f1bbcdc,  55);
+
+    five_cycle(v, parity, 0xca62c1d6,  60);
+    five_cycle(v, parity, 0xca62c1d6,  65);
+    five_cycle(v, parity, 0xca62c1d6,  70);
+    five_cycle(v, parity, 0xca62c1d6,  75);
+
+#ifdef ARRAY
+    ctx->hash[0] += v[0]; ctx->hash[1] += v[1];
+    ctx->hash[2] += v[2]; ctx->hash[3] += v[3];
+    ctx->hash[4] += v[4];
+#else
+    ctx->hash[0] += v0; ctx->hash[1] += v1;
+    ctx->hash[2] += v2; ctx->hash[3] += v3;
+    ctx->hash[4] += v4;
+#endif
+}
+
+int sha1_begin(SHA1_CTX* ctx)
+{
+    ctx->count[0] = ctx->count[1] = 0;
+    ctx->hash[0] = 0x67452301;
+    ctx->hash[1] = 0xefcdab89;
+    ctx->hash[2] = 0x98badcfe;
+    ctx->hash[3] = 0x10325476;
+    ctx->hash[4] = 0xc3d2e1f0;
+
+    return 0;
+}
+
+/* SHA1 hash data in an array of bytes into hash buffer and */
+/* call the hash_compile function as required.              */
+
+int sha1_hash(SHA1_CTX* ctx, const unsigned char data[], unsigned long len)
+{   sha1_32t pos = (sha1_32t)(ctx->count[0] & SHA1_MASK),
+            space = SHA1_BLOCK_SIZE - pos;
+    const unsigned char *sp = data;
+
+    if((ctx->count[0] += len) < len)
+        ++(ctx->count[1]);
+
+    while(len >= space)     /* tranfer whole blocks if possible  */
+    {
+        memcpy(((unsigned char*)ctx->wbuf) + pos, sp, space);
+        sp += space; len -= space; space = SHA1_BLOCK_SIZE; pos = 0;
+        bsw_32(ctx->wbuf, SHA1_BLOCK_SIZE >> 2);
+        sha1_compile(ctx);
+    }
+
+    memcpy(((unsigned char*)ctx->wbuf) + pos, sp, len);
+    return 0;
+}
+
+/* SHA1 final padding and digest calculation  */
+
+int sha1_end(SHA1_CTX* ctx, unsigned char hval[])
+{   sha1_32t    i = (sha1_32t)(ctx->count[0] & SHA1_MASK);
+
+    /* put bytes in the buffer in an order in which references to   */
+    /* 32-bit words will put bytes with lower addresses into the    */
+    /* top of 32 bit words on BOTH big and little endian machines   */
+    bsw_32(ctx->wbuf, (i + 3) >> 2);
+
+    /* we now need to mask valid bytes and add the padding which is */
+    /* a single 1 bit and as many zero bits as necessary. Note that */
+    /* we can always add the first padding byte here because the    */
+    /* buffer always has at least one empty slot                    */
+    ctx->wbuf[i >> 2] &= 0xffffff80 << 8 * (~i & 3);
+    ctx->wbuf[i >> 2] |= 0x00000080 << 8 * (~i & 3);
+
+    /* we need 9 or more empty positions, one for the padding byte  */
+    /* (above) and eight for the length count. If there is not      */
+    /* enough space, pad and empty the buffer                       */
+    if(i > SHA1_BLOCK_SIZE - 9)
+    {
+        if(i < 60) ctx->wbuf[15] = 0;
+        sha1_compile(ctx);
+        i = 0;
+    }
+    else    /* compute a word index for the empty buffer positions  */
+        i = (i >> 2) + 1;
+
+    while(i < 14) /* and zero pad all but last two positions        */
+        ctx->wbuf[i++] = 0;
+
+    /* the following 32-bit length fields are assembled in the      */
+    /* wrong byte order on little endian machines but this is       */
+    /* corrected later since they are only ever used as 32-bit      */
+    /* word values.                                                 */
+    ctx->wbuf[14] = (ctx->count[1] << 3) | (ctx->count[0] >> 29);
+    ctx->wbuf[15] = ctx->count[0] << 3;
+    sha1_compile(ctx);
+
+    /* extract the hash value as bytes in case the hash buffer is   */
+    /* misaligned for 32-bit words                                  */
+    for(i = 0; i < SHA1_DIGEST_SIZE; ++i)
+        hval[i] = (unsigned char)(ctx->hash[i >> 2] >> (8 * (~i & 3)));
+
+    return 0;
+}
+
+void sha1(unsigned char hval[], const unsigned char data[], unsigned long len)
+{   sha1_context    cx[1];
+
+    sha1_begin(cx); sha1_hash(cx, data, len); sha1_end( cx, hval);
+    }
+
+#if defined(__cplusplus)
+}
+#endif
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/sha1_c.h ./src/utils/lib/sha1_c.h
--- ./src/utils/lib/sha1_c.h	2005-04-25 17:19:05.000000000 +0200
+++ ./src/utils/lib/sha1_c.h	2005-11-29 02:58:41.000000000 +0100
@@ -1,19 +1,114 @@
+/*
+ ---------------------------------------------------------------------------
+ Copyright (c) 2002, Dr Brian Gladman, Worcester, UK.   All rights reserved.
+
+ LICENSE TERMS
+
+ The free distribution and use of this software in both source and binary
+ form is allowed (with or without changes) provided that:
+
+   1. distributions of this source code include the above copyright
+      notice, this list of conditions and the following disclaimer;
+
+   2. distributions in binary form include the above copyright
+      notice, this list of conditions and the following disclaimer
+      in the documentation and/or other associated materials;
+
+   3. the copyright holder's name is not used to endorse products
+      built using this software without specific written permission.
+
+ ALTERNATIVELY, provided that this notice is retained in full, this product
+ may be distributed under the terms of the GNU General Public License (GPL),
+ in which case the provisions of the GPL apply INSTEAD OF those given above.
+
+ DISCLAIMER
+
+ This software is provided 'as is' with no explicit or implied warranties
+ in respect of its properties, including, but not limited to, correctness
+ and/or fitness for purpose.
+ ---------------------------------------------------------------------------
+ Issue Date: 26/08/2003
+*/
+
+/*
+    This file is part of mldonkey.
+
+    mldonkey 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.
+
+    mldonkey is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mldonkey; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/*swap order of arguments in sha1_hash and sha1_end to 'fit' mldonkey*/
 
 #ifndef _SHA1_H
 #define _SHA1_H
 
-#include "../../../config/config.h"
+#include <limits.h>
+
+#define SHA1_BLOCK_SIZE  64
+#define SHA1_DIGEST_SIZE 20
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
+/* define an unsigned 32-bit type */
 
-#if defined(ENABLE_SHA1NEW)
-#include "sha1new_c.h"
+#if defined(_MSC_VER)
+  typedef   unsigned long    sha1_32t;
+#elif defined(ULONG_MAX) && ULONG_MAX == 0xfffffffful
+  typedef   unsigned long    sha1_32t;
+#elif defined(UINT_MAX) && UINT_MAX == 0xffffffff
+  typedef   unsigned int     sha1_32t;
 #else
-#include "os_stubs.h"
-#include "sha1old_c.h"
+#  error Please define sha1_32t as an unsigned 32 bit type in sha1.h
 #endif
 
+
+/* type to hold the SHA256 context  */
+
+typedef struct sha1_context
+{   sha1_32t count[2];
+    sha1_32t hash[5];
+    sha1_32t wbuf[16];
+} sha1_context;
+
+typedef struct sha1_context SHA1_CTX;
+
+/* Note that these prototypes are the same for both bit and */
+/* byte oriented implementations. However the length fields */
+/* are in bytes or bits as appropriate for the version used */
+/* and bit sequences are input as arrays of bytes in which  */
+/* bit sequences run from the most to the least significant */
+/* end of each byte                                         */
+
+void sha1_compile(sha1_context ctx[1]);
+
+/*
+void sha1_begin(sha1_ctx ctx[1]);
+void sha1_hash(sha1_ctx ctx[1], const unsigned char data[], unsigned long len);
+void sha1_end(sha1_ctx ctx[1], unsigned char hval[]);
+*/
+
+void sha1(unsigned char hval[], const unsigned char data[], unsigned long len);
+
 int sha1_begin(SHA1_CTX*);
 int sha1_hash(SHA1_CTX*, const unsigned char [], unsigned long);
 int sha1_end(SHA1_CTX*, unsigned char hval[]);
 
+#if defined(__cplusplus)
+}
 #endif
 
+#endif
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/sha1new_c.c ./src/utils/lib/sha1new_c.c
--- ./src/utils/lib/sha1new_c.c	2005-07-26 23:35:11.000000000 +0200
+++ ./src/utils/lib/sha1new_c.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,395 +0,0 @@
-/*
- ---------------------------------------------------------------------------
- Copyright (c) 2002, Dr Brian Gladman, Worcester, UK.   All rights reserved.
-
- LICENSE TERMS
-
- The free distribution and use of this software in both source and binary
- form is allowed (with or without changes) provided that:
-
-   1. distributions of this source code include the above copyright
-      notice, this list of conditions and the following disclaimer;
-
-   2. distributions in binary form include the above copyright
-      notice, this list of conditions and the following disclaimer
-      in the documentation and/or other associated materials;
-
-   3. the copyright holder's name is not used to endorse products
-      built using this software without specific written permission.
-
- ALTERNATIVELY, provided that this notice is retained in full, this product
- may be distributed under the terms of the GNU General Public License (GPL),
- in which case the provisions of the GPL apply INSTEAD OF those given above.
-
- DISCLAIMER
-
- This software is provided 'as is' with no explicit or implied warranties
- in respect of its properties, including, but not limited to, correctness
- and/or fitness for purpose.
- ---------------------------------------------------------------------------
- Issue Date: 16/01/2004
-
- This is a byte oriented version of SHA1 that operates on arrays of bytes
- stored in memory. It runs at 22 cycles per byte on a Pentium P4 processor
- */
-
-/*
-    This file is part of mldonkey.
-
-    mldonkey 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.
-
-    mldonkey is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with mldonkey; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-     */
-
-/*swap order of arguments in sha1_hash and sha1_end to 'fit' mldonkey*/
-
-#include <string.h>     /* for memcpy() etc.        */
-#include <stdlib.h>     /* for _lrotl with VC++     */
-
-#include "sha1_c.h"
-
-#if defined(__cplusplus)
-extern "C"
-    {
-#endif
-
-    /*
-    To obtain the highest speed on processors with 32-bit words, this code
-    needs to determine the order in which bytes are packed into such words.
-    The following block of code is an attempt to capture the most obvious
-    ways in which various environemnts specify their endian definitions.
-    It may well fail, in which case the definitions will need to be set by
-    editing at the points marked **** EDIT HERE IF NECESSARY **** below.
-*/
-
-/*  PLATFORM SPECIFIC INCLUDES */
-
-#define BRG_LITTLE_ENDIAN   1234 /* byte 0 is least significant (i386) */
-#define BRG_BIG_ENDIAN      4321 /* byte 0 is most significant (mc68k) */
-
-#if defined(__GNUC__) || defined(__GNU_LIBRARY__)
-#  if defined(HAVE_SYS_ENDIAN_H)
-#    if (defined(__FreeBSD__) && __FreeBSD_version >= 470000) || defined(__OpenBSD__) || defined(__NetBSD__)
-#      include <sys/endian.h>
-#    endif
-#  elif defined( BSD ) && ( BSD >= 199103 )
-#      if defined(__FreeBSD__)
-#        define _KERNEL
-#        define I486_CPU /* Will crash unless 486+ */
-#      endif
-#      include <machine/endian.h>
-#      if defined(__FreeBSD__)
-#        undef _KERNEL
-#        undef I486_CPU
-#        define bswap_32(x) (ntohl(x))
-#      endif
-#  elif defined(__APPLE__)
-#    if defined(__BIG_ENDIAN__) && !defined( BIG_ENDIAN )
-#      define BIG_ENDIAN
-#    elif defined(__LITTLE_ENDIAN__) && !defined( LITTLE_ENDIAN )
-#      define LITTLE_ENDIAN
-#    endif
-#  else
-#    if defined(HAVE_LOCAL_ENDIAN_H)
-#      include "endian.h"
-#    else
-#      include <endian.h>
-#      if defined(HAVE_BYTESWAP_H)
-#        include <byteswap.h>
-#      endif
-#    endif
-#  endif
-#endif
-
-#if !defined(PLATFORM_BYTE_ORDER)
-#  if defined(LITTLE_ENDIAN) || defined(BIG_ENDIAN)
-#    if    defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
-#      define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
-#    elif !defined(LITTLE_ENDIAN) &&  defined(BIG_ENDIAN)
-#      define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
-#    elif defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
-#      define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
-#    elif defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
-#      define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
-#    endif
-#  elif defined(_LITTLE_ENDIAN) || defined(_BIG_ENDIAN)
-#    if    defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
-#      define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
-#    elif !defined(_LITTLE_ENDIAN) &&  defined(_BIG_ENDIAN)
-#      define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
-#    elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _LITTLE_ENDIAN)
-#      define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
-#    elif defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)
-#      define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
-#   endif
-#  elif defined(__LITTLE_ENDIAN__) || defined(__BIG_ENDIAN__)
-#    if    defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
-#      define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
-#    elif !defined(__LITTLE_ENDIAN__) &&  defined(__BIG_ENDIAN__)
-#      define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
-#    elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __LITTLE_ENDIAN__)
-#      define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
-#    elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)
-#      define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
-#    endif
-#  endif
-#endif
-
-/*  if the platform is still unknown, try to find its byte order    */
-/*  from commonly used machine defines                              */
-
-#if !defined(PLATFORM_BYTE_ORDER)
-
-#if   defined( __alpha__ ) || defined( __alpha ) || defined( i386 )       || \
-      defined( __i386__ )  || defined( _M_I86 )  || defined( _M_IX86 )    || \
-      defined( __OS2__ )   || defined( sun386 )  || defined( __TURBOC__ ) || \
-      defined( vax )       || defined( vms )     || defined( VMS )        || \
-      defined( __VMS )
-#  define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
-
-#elif defined( AMIGA )    || defined( applec )  || defined( __AS400__ )  || \
-      defined( _CRAY )    || defined( __hppa )  || defined( __hp9000 )   || \
-      defined( ibm370 )   || defined( mc68000 ) || defined( m68k )       || \
-      defined( __MRC__ )  || defined( __MVS__ ) || defined( __MWERKS__ ) || \
-      defined( sparc )    || defined( __sparc)  || defined( SYMANTEC_C ) || \
-      defined( __TANDEM ) || defined( THINK_C ) || defined( __VMCMS__ )
-#  define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
-
-#elif 0     /* **** EDIT HERE IF NECESSARY **** */
-#  define PLATFORM_BYTE_ORDER BRG_LITTLE_ENDIAN
-#elif 0     /* **** EDIT HERE IF NECESSARY **** */
-#  define PLATFORM_BYTE_ORDER BRG_BIG_ENDIAN
-#else
-#  error Please edit sha1.c (line 134 or 136) to set the platform byte order
-#endif
-
-#endif
-
-#ifdef _MSC_VER
-#pragma intrinsic(memcpy)
-#endif
-
-#if 0 && defined(_MSC_VER)
-#define rotl32  _lrotl
-#define rotr32  _lrotr
-#else
-#define rotl32(x,n)   (((x) << n) | ((x) >> (32 - n)))
-#define rotr32(x,n)   (((x) >> n) | ((x) << (32 - n)))
-#endif
-
-#if !defined(bswap_32)
-#define bswap_32(x) (rotr32((x), 24) & 0x00ff00ff | rotr32((x), 8) & 0xff00ff00)
-#endif
-
-#if (PLATFORM_BYTE_ORDER == BRG_LITTLE_ENDIAN)
-#define SWAP_BYTES
-#else
-#undef  SWAP_BYTES
-#endif
-
-#if defined(SWAP_BYTES)
-#define bsw_32(p,n) \
-    { int _i = (n); while(_i--) ((sha1_32t*)p)[_i] = bswap_32(((sha1_32t*)p)[_i]); }
-#else
-#define bsw_32(p,n)
-#endif
-
-#define SHA1_MASK   (SHA1_BLOCK_SIZE - 1)
-
-#if 0
-
-#define ch(x,y,z)       (((x) & (y)) ^ (~(x) & (z)))
-#define parity(x,y,z)   ((x) ^ (y) ^ (z))
-#define maj(x,y,z)      (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
-
-#else   /* Discovered by Rich Schroeppel and Colin Plumb   */
-
-#define ch(x,y,z)       ((z) ^ ((x) & ((y) ^ (z))))
-#define parity(x,y,z)   ((x) ^ (y) ^ (z))
-#define maj(x,y,z)      (((x) & (y)) | ((z) & ((x) ^ (y))))
-
-#endif
-
-/* Compile 64 bytes of hash data into SHA1 context. Note    */
-/* that this routine assumes that the byte order in the     */
-/* ctx->wbuf[] at this point is in such an order that low   */
-/* address bytes in the ORIGINAL byte stream in this buffer */
-/* will go to the high end of 32-bit words on BOTH big and  */
-/* little endian systems                                    */
-
-#ifdef ARRAY
-#define q(v,n)  v[n]
-#else
-#define q(v,n)  v##n
-#endif
-
-#define one_cycle(v,a,b,c,d,e,f,k,h)            \
-    q(v,e) += rotr32(q(v,a),27) +               \
-              f(q(v,b),q(v,c),q(v,d)) + k + h;  \
-    q(v,b)  = rotr32(q(v,b), 2)
-
-#define five_cycle(v,f,k,i)                 \
-    one_cycle(v, 0,1,2,3,4, f,k,hf(i  ));   \
-    one_cycle(v, 4,0,1,2,3, f,k,hf(i+1));   \
-    one_cycle(v, 3,4,0,1,2, f,k,hf(i+2));   \
-    one_cycle(v, 2,3,4,0,1, f,k,hf(i+3));   \
-    one_cycle(v, 1,2,3,4,0, f,k,hf(i+4))
-
-void sha1_compile(sha1_context ctx[1])
-{   sha1_32t    *w = ctx->wbuf;
-
-#ifdef ARRAY
-    sha1_32t    v[5];
-    memcpy(v, ctx->hash, 5 * sizeof(sha1_32t));
-#else
-    sha1_32t    v0, v1, v2, v3, v4;
-    v0 = ctx->hash[0]; v1 = ctx->hash[1];
-    v2 = ctx->hash[2]; v3 = ctx->hash[3];
-    v4 = ctx->hash[4];
-#endif
-
-#define hf(i)   w[i]
-
-    five_cycle(v, ch, 0x5a827999,  0);
-    five_cycle(v, ch, 0x5a827999,  5);
-    five_cycle(v, ch, 0x5a827999, 10);
-    one_cycle(v,0,1,2,3,4, ch, 0x5a827999, hf(15)); \
-
-#undef  hf
-#define hf(i) (w[(i) & 15] = rotl32(                    \
-                 w[((i) + 13) & 15] ^ w[((i) + 8) & 15] \
-               ^ w[((i) +  2) & 15] ^ w[(i) & 15], 1))
-
-    one_cycle(v,4,0,1,2,3, ch, 0x5a827999, hf(16));
-    one_cycle(v,3,4,0,1,2, ch, 0x5a827999, hf(17));
-    one_cycle(v,2,3,4,0,1, ch, 0x5a827999, hf(18));
-    one_cycle(v,1,2,3,4,0, ch, 0x5a827999, hf(19));
-
-    five_cycle(v, parity, 0x6ed9eba1,  20);
-    five_cycle(v, parity, 0x6ed9eba1,  25);
-    five_cycle(v, parity, 0x6ed9eba1,  30);
-    five_cycle(v, parity, 0x6ed9eba1,  35);
-
-    five_cycle(v, maj, 0x8f1bbcdc,  40);
-    five_cycle(v, maj, 0x8f1bbcdc,  45);
-    five_cycle(v, maj, 0x8f1bbcdc,  50);
-    five_cycle(v, maj, 0x8f1bbcdc,  55);
-
-    five_cycle(v, parity, 0xca62c1d6,  60);
-    five_cycle(v, parity, 0xca62c1d6,  65);
-    five_cycle(v, parity, 0xca62c1d6,  70);
-    five_cycle(v, parity, 0xca62c1d6,  75);
-
-#ifdef ARRAY
-    ctx->hash[0] += v[0]; ctx->hash[1] += v[1];
-    ctx->hash[2] += v[2]; ctx->hash[3] += v[3];
-    ctx->hash[4] += v[4];
-#else
-    ctx->hash[0] += v0; ctx->hash[1] += v1;
-    ctx->hash[2] += v2; ctx->hash[3] += v3;
-    ctx->hash[4] += v4;
-#endif
-}
-
-int sha1_begin(SHA1_CTX* ctx)
-{
-    ctx->count[0] = ctx->count[1] = 0;
-    ctx->hash[0] = 0x67452301;
-    ctx->hash[1] = 0xefcdab89;
-    ctx->hash[2] = 0x98badcfe;
-    ctx->hash[3] = 0x10325476;
-    ctx->hash[4] = 0xc3d2e1f0;
-
-    return 0;
-}
-
-/* SHA1 hash data in an array of bytes into hash buffer and */
-/* call the hash_compile function as required.              */
-
-int sha1_hash(SHA1_CTX* ctx, const unsigned char data[], unsigned long len)
-{   sha1_32t pos = (sha1_32t)(ctx->count[0] & SHA1_MASK),
-            space = SHA1_BLOCK_SIZE - pos;
-    const unsigned char *sp = data;
-
-    if((ctx->count[0] += len) < len)
-        ++(ctx->count[1]);
-
-    while(len >= space)     /* tranfer whole blocks if possible  */
-    {
-        memcpy(((unsigned char*)ctx->wbuf) + pos, sp, space);
-        sp += space; len -= space; space = SHA1_BLOCK_SIZE; pos = 0;
-        bsw_32(ctx->wbuf, SHA1_BLOCK_SIZE >> 2);
-        sha1_compile(ctx);
-    }
-
-    memcpy(((unsigned char*)ctx->wbuf) + pos, sp, len);
-    return 0;
-}
-
-/* SHA1 final padding and digest calculation  */
-
-int sha1_end(SHA1_CTX* ctx, unsigned char hval[])
-{   sha1_32t    i = (sha1_32t)(ctx->count[0] & SHA1_MASK);
-
-    /* put bytes in the buffer in an order in which references to   */
-    /* 32-bit words will put bytes with lower addresses into the    */
-    /* top of 32 bit words on BOTH big and little endian machines   */
-    bsw_32(ctx->wbuf, (i + 3) >> 2);
-
-    /* we now need to mask valid bytes and add the padding which is */
-    /* a single 1 bit and as many zero bits as necessary. Note that */
-    /* we can always add the first padding byte here because the    */
-    /* buffer always has at least one empty slot                    */
-    ctx->wbuf[i >> 2] &= 0xffffff80 << 8 * (~i & 3);
-    ctx->wbuf[i >> 2] |= 0x00000080 << 8 * (~i & 3);
-
-    /* we need 9 or more empty positions, one for the padding byte  */
-    /* (above) and eight for the length count. If there is not      */
-    /* enough space, pad and empty the buffer                       */
-    if(i > SHA1_BLOCK_SIZE - 9)
-    {
-        if(i < 60) ctx->wbuf[15] = 0;
-        sha1_compile(ctx);
-        i = 0;
-    }
-    else    /* compute a word index for the empty buffer positions  */
-        i = (i >> 2) + 1;
-
-    while(i < 14) /* and zero pad all but last two positions        */
-        ctx->wbuf[i++] = 0;
-
-    /* the following 32-bit length fields are assembled in the      */
-    /* wrong byte order on little endian machines but this is       */
-    /* corrected later since they are only ever used as 32-bit      */
-    /* word values.                                                 */
-    ctx->wbuf[14] = (ctx->count[1] << 3) | (ctx->count[0] >> 29);
-    ctx->wbuf[15] = ctx->count[0] << 3;
-    sha1_compile(ctx);
-
-    /* extract the hash value as bytes in case the hash buffer is   */
-    /* misaligned for 32-bit words                                  */
-    for(i = 0; i < SHA1_DIGEST_SIZE; ++i)
-        hval[i] = (unsigned char)(ctx->hash[i >> 2] >> (8 * (~i & 3)));
-
-    return 0;
-}
-
-void sha1(unsigned char hval[], const unsigned char data[], unsigned long len)
-{   sha1_context    cx[1];
-
-    sha1_begin(cx); sha1_hash(cx, data, len); sha1_end( cx, hval);
-    }
-
-#if defined(__cplusplus)
-}
-#endif
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/sha1new_c.h ./src/utils/lib/sha1new_c.h
--- ./src/utils/lib/sha1new_c.h	2004-02-11 00:25:09.000000000 +0100
+++ ./src/utils/lib/sha1new_c.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,110 +0,0 @@
-/*
- ---------------------------------------------------------------------------
- Copyright (c) 2002, Dr Brian Gladman, Worcester, UK.   All rights reserved.
-
- LICENSE TERMS
-
- The free distribution and use of this software in both source and binary
- form is allowed (with or without changes) provided that:
-
-   1. distributions of this source code include the above copyright
-      notice, this list of conditions and the following disclaimer;
-
-   2. distributions in binary form include the above copyright
-      notice, this list of conditions and the following disclaimer
-      in the documentation and/or other associated materials;
-
-   3. the copyright holder's name is not used to endorse products
-      built using this software without specific written permission.
-
- ALTERNATIVELY, provided that this notice is retained in full, this product
- may be distributed under the terms of the GNU General Public License (GPL),
- in which case the provisions of the GPL apply INSTEAD OF those given above.
-
- DISCLAIMER
-
- This software is provided 'as is' with no explicit or implied warranties
- in respect of its properties, including, but not limited to, correctness
- and/or fitness for purpose.
- ---------------------------------------------------------------------------
- Issue Date: 26/08/2003
-*/
-
-/*
-    This file is part of mldonkey.
-
-    mldonkey 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.
-
-    mldonkey is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with mldonkey; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/*swap order of arguments in sha1_hash and sha1_end to 'fit' mldonkey*/
-
-#ifndef _SHA1NEW_H
-#define _SHA1NEW_H
-
-#include "sha1_c.h"
-#include <limits.h>
-
-#define SHA1_BLOCK_SIZE  64
-#define SHA1_DIGEST_SIZE 20
-
-#if defined(__cplusplus)
-extern "C"
-{
-#endif
-
-/* define an unsigned 32-bit type */
-
-#if defined(_MSC_VER)
-  typedef   unsigned long    sha1_32t;
-#elif defined(ULONG_MAX) && ULONG_MAX == 0xfffffffful
-  typedef   unsigned long    sha1_32t;
-#elif defined(UINT_MAX) && UINT_MAX == 0xffffffff
-  typedef   unsigned int     sha1_32t;
-#else
-#  error Please define sha1_32t as an unsigned 32 bit type in sha1.h
-#endif
-
-/* type to hold the SHA256 context  */
-
-typedef struct sha1_context
-{   sha1_32t count[2];
-    sha1_32t hash[5];
-    sha1_32t wbuf[16];
-} sha1_context;
-
-typedef struct sha1_context SHA1_CTX;
-
-/* Note that these prototypes are the same for both bit and */
-/* byte oriented implementations. However the length fields */
-/* are in bytes or bits as appropriate for the version used */
-/* and bit sequences are input as arrays of bytes in which  */
-/* bit sequences run from the most to the least significant */
-/* end of each byte                                         */
-
-void sha1_compile(sha1_context ctx[1]);
-
-/*
-void sha1_begin(sha1_ctx ctx[1]);
-void sha1_hash(sha1_ctx ctx[1], const unsigned char data[], unsigned long len);
-void sha1_end(sha1_ctx ctx[1], unsigned char hval[]);
-*/
-
-void sha1(unsigned char hval[], const unsigned char data[], unsigned long len);
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/sha1old_c.c ./src/utils/lib/sha1old_c.c
--- ./src/utils/lib/sha1old_c.c	2004-02-11 00:25:09.000000000 +0100
+++ ./src/utils/lib/sha1old_c.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,445 +0,0 @@
-/*
- *
- * This file comes from RFC 3174. Inclusion in gtk-gnutella is:
- *
- */
-
-/*
- *  sha1.c
- *
- *  Description:
- *      This file implements the Secure Hashing Algorithm 1 as
- *      defined in FIPS PUB 180-1 published April 17, 1995.
- *
- *      The SHA-1, produces a 160-bit message digest for a given
- *      data stream.  It should take about 2**n steps to find a
- *      message with the same digest as a given message and
- *      2**(n/2) to find any two messages with the same digest,
- *      when n is the digest size in bits.  Therefore, this
- *      algorithm can serve as a means of providing a
- *      "fingerprint" for a message.
- *
- *  Portability Issues:
- *      SHA-1 is defined in terms of 32-bit "words".  This code
- *      uses <stdint.h> (included via "sha1.h" to define 32 and 8
- *      bit unsigned integer types.  If your C compiler does not
- *      support 32 bit unsigned integers, this code is not
- *      appropriate.
- *
- *  Caveats:
- *      SHA-1 is designed to work with messages less than 2^64 bits
- *      long.  Although SHA-1 allows a message digest to be generated
- *      for messages of any number of bits less than 2^64, this
- *      implementation only works with messages with a length that is
- *      a multiple of the size of an 8-bit character.
- *
- */
-
-#include "sha1_c.h"
-
-/*
- *  Define the SHA1 circular left shift macro
- */
-#define SHA1CircularShift(bits,word) \
-                (((word) << (bits)) | ((word) >> (32-(bits))))
-
-/* Local Function Prototyptes */
-void SHA1PadMessage(sha1_context *);
-void SHA1ProcessMessageBlock(sha1_context *);
-
-/*
- *  SHA1Reset
- *
- *  Description:
- *      This function will initialize the sha1_context in preparation
- *      for computing a new SHA1 message digest.
- *
- *  Parameters:
- *      context: [in/out]
- *          The context to reset.
- *
- *  Returns:
- *      sha Error Code.
- *
- */
-int sha1_begin(SHA1_CTX* context)
-{
-    if (!context)
-    {
-        return shaNull;
-    }
-
-    context->Length_Low             = 0;
-    context->Length_High            = 0;
-    context->Message_Block_Index    = 0;
-
-    context->Intermediate_Hash[0]   = 0x67452301;
-    context->Intermediate_Hash[1]   = 0xEFCDAB89;
-    context->Intermediate_Hash[2]   = 0x98BADCFE;
-    context->Intermediate_Hash[3]   = 0x10325476;
-    context->Intermediate_Hash[4]   = 0xC3D2E1F0;
-
-    context->Computed   = 0;
-    context->Corrupted  = 0;
-
-    return shaSuccess;
-}
-
-/*
- *  SHA1Result
- *
- *  Description:
- *      This function will return the 160-bit message digest into the
- *      Message_Digest array  provided by the caller.
- *      NOTE: The first octet of hash is stored in the 0th element,
- *            the last octet of hash in the 19th element.
- *
- *  Parameters:
- *      context: [in/out]
- *          The context to use to calculate the SHA-1 hash.
- *      Message_Digest: [out]
- *          Where the digest is returned.
- *
- *  Returns:
- *      sha Error Code.
- *
- */
-int sha1_end(sha1_context *context,
-                uint8 Message_Digest[SHA1HashSize])
-{
-    int i;
-
-    if (!context || !Message_Digest)
-    {
-        return shaNull;
-    }
-
-    if (context->Corrupted)
-    {
-        return context->Corrupted;
-    }
-
-    if (!context->Computed)
-    {
-        SHA1PadMessage(context);
-        for(i=0; i<64; ++i)
-        {
-            /* message may be sensitive, clear it out */
-            context->Message_Block[i] = 0;
-        }
-        context->Length_Low = 0;    /* and clear length */
-        context->Length_High = 0;
-        context->Computed = 1;
-    }
-
-    for(i = 0; i < SHA1HashSize; ++i)
-    {
-        Message_Digest[i] = context->Intermediate_Hash[i>>2]
-                            >> 8 * ( 3 - ( i & 0x03 ) );
-    }
-
-    return shaSuccess;
-}
-
-/*
- *  SHA1Input
- *
- *  Description:
- *      This function accepts an array of octets as the next portion
- *      of the message.
- *
- *  Parameters:
- *      context: [in/out]
- *          The SHA context to update
- *      message_array: [in]
- *          An array of characters representing the next portion of
- *          the message.
- *      length: [in]
- *          The length of the message in message_array
- *
- *  Returns:
- *      sha Error Code.
- *
- */
-int sha1_hash(    SHA1_CTX    *context,
-                  const unsigned char  message_array[],
-                  unsigned long       length)
-{
-    if (!length)
-    {
-        return shaSuccess;
-    }
-
-    if (!context || !message_array)
-    {
-        return shaNull;
-    }
-
-    if (context->Computed)
-    {
-        context->Corrupted = shaStateError;
-        return shaStateError;
-    }
-
-    if (context->Corrupted)
-    {
-         return context->Corrupted;
-    }
-    while(length-- && !context->Corrupted)
-    {
-    context->Message_Block[context->Message_Block_Index++] =
-                    (*message_array & 0xFF);
-
-    context->Length_Low += 8;
-    if (context->Length_Low == 0)
-    {
-        context->Length_High++;
-        if (context->Length_High == 0)
-        {
-            /* Message is too long */
-            context->Corrupted = 1;
-        }
-    }
-
-    if (context->Message_Block_Index == 64)
-    {
-        SHA1ProcessMessageBlock(context);
-    }
-
-    message_array++;
-    }
-
-    return shaSuccess;
-}
-
-/*
- *  SHA1ProcessMessageBlock
- *
- *  Description:
- *      This function will process the next 512 bits of the message
- *      stored in the Message_Block array.
- *
- *  Parameters:
- *      None.
- *
- *  Returns:
- *      Nothing.
- *
- *  Comments:
- *      Many of the variable names in this code, especially the
- *      single character names, were used because those were the
- *      names used in the publication.
- *
- *
- */
-void SHA1ProcessMessageBlock(sha1_context *context)
-{
-    const uint32 K[] =    {       /* Constants defined in SHA-1   */
-                            0x5A827999,
-                            0x6ED9EBA1,
-                            0x8F1BBCDC,
-                            0xCA62C1D6
-                            };
-    int           t;                 /* Loop counter                */
-    uint32      temp;              /* Temporary word value        */
-    uint32      W[80];             /* Word sequence               */
-    uint32      A, B, C, D, E;     /* Word buffers                */
-
-    /*
-     *  Initialize the first 16 words in the array W
-     */
-    for(t = 0; t < 16; t++)
-    {
-        W[t] = context->Message_Block[t * 4] << 24;
-        W[t] |= context->Message_Block[t * 4 + 1] << 16;
-        W[t] |= context->Message_Block[t * 4 + 2] << 8;
-        W[t] |= context->Message_Block[t * 4 + 3];
-    }
-
-    for(t = 16; t < 80; t++)
-    {
-       W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
-    }
-
-    A = context->Intermediate_Hash[0];
-    B = context->Intermediate_Hash[1];
-    C = context->Intermediate_Hash[2];
-    D = context->Intermediate_Hash[3];
-    E = context->Intermediate_Hash[4];
-
-    for(t = 0; t < 20; t++)
-    {
-        temp =  SHA1CircularShift(5,A) +
-                ((B & C) | ((~B) & D)) + E + W[t] + K[0];
-        E = D;
-        D = C;
-        C = SHA1CircularShift(30,B);
-        B = A;
-        A = temp;
-    }
-
-    for(t = 20; t < 40; t++)
-    {
-        temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
-        E = D;
-        D = C;
-        C = SHA1CircularShift(30,B);
-        B = A;
-        A = temp;
-    }
-
-    for(t = 40; t < 60; t++)
-    {
-        temp = SHA1CircularShift(5,A) +
-               ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
-        E = D;
-        D = C;
-        C = SHA1CircularShift(30,B);
-        B = A;
-        A = temp;
-    }
-
-    for(t = 60; t < 80; t++)
-    {
-        temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
-        E = D;
-        D = C;
-        C = SHA1CircularShift(30,B);
-        B = A;
-        A = temp;
-    }
-
-    context->Intermediate_Hash[0] += A;
-    context->Intermediate_Hash[1] += B;
-    context->Intermediate_Hash[2] += C;
-    context->Intermediate_Hash[3] += D;
-    context->Intermediate_Hash[4] += E;
-
-    context->Message_Block_Index = 0;
-}
-
-
-/*
- *  SHA1PadMessage
- *
- *  Description:
- *      According to the standard, the message must be padded to an even
- *      512 bits.  The first padding bit must be a '1'.  The last 64
- *      bits represent the length of the original message.  All bits in
- *      between should be 0.  This function will pad the message
- *      according to those rules by filling the Message_Block array
- *      accordingly.  It will also call the ProcessMessageBlock function
- *      provided appropriately.  When it returns, it can be assumed that
- *      the message digest has been computed.
- *
- *  Parameters:
- *      context: [in/out]
- *          The context to pad
- *      ProcessMessageBlock: [in]
- *          The appropriate SHA*ProcessMessageBlock function
- *  Returns:
- *      Nothing.
- *
- */
-
-void SHA1PadMessage(sha1_context *context)
-{
-    /*
-     *  Check to see if the current message block is too small to hold
-     *  the initial padding bits and length.  If so, we will pad the
-     *  block, process it, and then continue padding into a second
-     *  block.
-     */
-    if (context->Message_Block_Index > 55)
-    {
-        context->Message_Block[context->Message_Block_Index++] = 0x80;
-        while(context->Message_Block_Index < 64)
-        {
-            context->Message_Block[context->Message_Block_Index++] = 0;
-        }
-
-        SHA1ProcessMessageBlock(context);
-
-        while(context->Message_Block_Index < 56)
-        {
-            context->Message_Block[context->Message_Block_Index++] = 0;
-        }
-    }
-    else
-    {
-        context->Message_Block[context->Message_Block_Index++] = 0x80;
-        while(context->Message_Block_Index < 56)
-        {
-            context->Message_Block[context->Message_Block_Index++] = 0;
-        }
-    }
-
-    /*
-     *  Store the message length as the last 8 octets
-     */
-    context->Message_Block[56] = context->Length_High >> 24;
-    context->Message_Block[57] = context->Length_High >> 16;
-    context->Message_Block[58] = context->Length_High >> 8;
-    context->Message_Block[59] = context->Length_High;
-    context->Message_Block[60] = context->Length_Low >> 24;
-    context->Message_Block[61] = context->Length_Low >> 16;
-    context->Message_Block[62] = context->Length_Low >> 8;
-    context->Message_Block[63] = context->Length_Low;
-
-    SHA1ProcessMessageBlock(context);
-}
-
-
-/**************************************************************************
-
-
-                      Ocaml stubs (copied from md4_c.c)
- 
-
-***************************************************************************/
-
-/*
-#include "caml/mlvalues.h"
-#include "caml/fail.h"
-#include "caml/alloc.h"
-
-value sha1_unsafe_string(value digest_v, value string_v, value len_v)
-{
-  unsigned char *digest = String_val(digest_v);
-  unsigned char *string = String_val(string_v);
-  long len = Long_val(len_v);
-  sha1_context context;
-
-  sha1_init (&context);
-  sha1_append (&context, string, len);
-  sha1_finish (&context, digest);
- 
-  return Val_unit;
-}
-
-#include <stdio.h>
-
-value sha1_unsafe_file (value digest_v, value filename_v)
-{
-  char *filename  = String_val(filename_v);
-  unsigned char *digest = String_val(digest_v);
-  FILE *file;
-  sha1_context context;
-  int len;
-
-  if ((file = fopen (filename, "rb")) == NULL)
-    raise_not_found();
-
-  else {
-    sha1_init (&context);
-    while ((len = fread (hash_buffer, 1, HASH_BUFFER_LEN, file)))
-      sha1_append (&context, hash_buffer, len);
-    sha1_finish (&context, digest);
-
-    fclose (file);
-  }
-  return Val_unit;
-}
-
-*/
-
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/sha1old_c.h ./src/utils/lib/sha1old_c.h
--- ./src/utils/lib/sha1old_c.h	2004-02-11 00:25:09.000000000 +0100
+++ ./src/utils/lib/sha1old_c.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,59 +0,0 @@
-/*
- *
- * This file comes from RFC 3174. Inclusion in gtk-gnutella is:
- */
-
-#ifndef _SHA1OLD_H_
-#define _SHA1OLD_H_
-
-#if __STDC_VERSION__ >= 199901L
-#include <stdint.h>
-#else
-#endif
-
-typedef unsigned char uint8;
-
-/*
- * If you do not have the ISO standard stdint.h header file, then you
- * must typdef the following:
- *    name              meaning
- *  guint32         unsigned 32 bit integer
- *  guint8          unsigned 8 bit integer (i.e., unsigned char)
- *  gint    		integer of >= 16 bits
- *
- */
-
-#ifndef _SHA_enum_
-#define _SHA_enum_
-enum
-{
-    shaSuccess = 0,
-    shaNull,            /* Null pointer parameter */
-    shaInputTooLong,    /* input data too long */
-    shaStateError       /* called Input after Result */
-};
-#endif
-#define SHA1HashSize 20
-
-/*
- *  This structure will hold context information for the SHA-1
- *  hashing operation
- */
-typedef struct sha1_context
-{
-    uint32 Intermediate_Hash[SHA1HashSize/4]; /* Message Digest  */
-
-    uint32 Length_Low;            /* Message length in bits      */
-    uint32 Length_High;           /* Message length in bits      */
-
-                               /* Index into message block array   */
-    int Message_Block_Index;
-    uint8 Message_Block[64];      /* 512-bit message blocks      */
-
-    int Computed;               /* Is the digest computed?         */
-    int Corrupted;             /* Is the message digest corrupted? */
-} sha1_context;
-
-typedef struct sha1_context SHA1_CTX;
-
-#endif
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/stubs_c.c ./src/utils/lib/stubs_c.c
--- ./src/utils/lib/stubs_c.c	2005-10-27 11:42:06.000000000 +0200
+++ ./src/utils/lib/stubs_c.c	2005-11-29 02:58:41.000000000 +0100
@@ -22,6 +22,7 @@
 
 #include <string.h> 
 #include <ctype.h>
+#include <caml/config.h>
 
 #define lseek XXXXXXXXX
 #define read XXXXXXXXX
@@ -1281,3 +1282,14 @@
 	return ml_verifySignature(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
 }
 
+value ml_check_endianness(void)
+{
+  CAMLparam0 ();
+  CAMLlocal1 (v);
+#ifdef ARCH_BIG_ENDIAN
+  v = copy_string ("big endian");
+#else
+  v = copy_string ("little endian");
+#endif
+  CAMLreturn (v);
+}
diff -a -x CVS -x Root -x Repository -x Tag -x Entries -x Entries.Log -x .svn -x '*.rej' -x '*.orig' -x .cvsignore -N -r -u ./src/utils/lib/tiger.c ./src/utils/lib/tiger.c
--- ./src/utils/lib/tiger.c	2005-10-25 11:46:50.000000000 +0200
+++ ./src/utils/lib/tiger.c	2005-11-29 02:58:41.000000000 +0100
@@ -18,11 +18,7 @@
 */
 
 #include "tiger.h"
-
-/* Big endian:                                         */
-#if !(defined(__alpha)||defined(__i386__)||defined(__vax__))
-#define BIG_ENDIAN
-#endif
+#include <caml/config.h>
 
 /* The following macro denotes that an optimization    */
 /* for Alpha is required. It is used only for          */
@@ -193,7 +189,7 @@
 
   for(i=length; i>=64; i-=64)
     {
-#ifdef BIG_ENDIAN
+#ifdef ARCH_BIG_ENDIAN
       for(j=0; j<64; j++)
 	temp[j^7] = ((byte*)str)[j];
       tiger_compress(((word64*)temp), res);
@@ -203,7 +199,7 @@
       str += 8;
     }
 
-#ifdef BIG_ENDIAN
+#ifdef ARCH_BIG_ENDIAN
   for(j=0; j<i; j++)
     temp[j^7] = ((byte*)str)[j];
 
@@ -753,7 +749,7 @@
 
 void swap_digest(unsigned char *digest)
 {
-  #ifdef BIG_ENDIAN
+  #ifdef ARCH_BIG_ENDIAN
   {
     int i,j; 
     for(i=0; i<3; i++){
