X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=hash.h;h=8a14e3a763529a6a47c6479dea828b15ee8e594e;hp=99f4486afdbfb2ecb68e636e1847ed6c7d41f100;hb=f24f82d9a9134562abc331558b9e21feff91b93b;hpb=f6f50d03a09d6bc423324206d274336e9905bbb4 diff --git a/hash.h b/hash.h index 99f4486a..8a14e3a7 100644 --- a/hash.h +++ b/hash.h @@ -1,12 +1,28 @@ -#include "portable_io.h" +/* + * Copyright (C) 2007-2009 Andre Noll + * + * Licensed under the GPL v2. For licencing details see COPYING. + */ + +/** \file hash.h Inline functions for hash values. */ + +/** hash arrays are always unsigned char. */ #define HASH_TYPE unsigned char -//#include "super_fast_hash.h" -//#define hash_function super_fast_hash #include "sha1.h" +/** We use openssl's sha1 implementation. */ #define hash_function sha1_hash -static inline int hash_compare(HASH_TYPE *h1, HASH_TYPE *h2) +/** + * Compare two hashes. + * + * \param h1 Pointer to the first hash value. + * \param h2 Pointer to the second hash value. + * + * \return 1, -1, or zero, depending on whether \a h1 is greater than, + * less than or equal to h2, respectively. + */ +_static_inline_ int hash_compare(HASH_TYPE *h1, HASH_TYPE *h2) { int i; @@ -19,7 +35,17 @@ static inline int hash_compare(HASH_TYPE *h1, HASH_TYPE *h2) return 0; } -static inline void hash_to_asc(HASH_TYPE *hash, char *asc) +/** + * Convert a hash value to ascii format. + * + * \param hash the hash value. + * \param asc Result pointer. + * + * \a asc must point to an area of at least 2 * \p HASH_SIZE + 1 bytes which + * will be filled by the function with the ascii representation of the hash + * value given by \a hash, and a terminating \p NULL byte. + */ +_static_inline_ void hash_to_asc(HASH_TYPE *hash, char *asc) { int i; const char hexchar[] = "0123456789abcdef";