Replace void *row by struct osl_row *row.
[paraslash.git] / hash.h
1 #include "portable_io.h"
2 #define HASH_TYPE unsigned char
3
4 //#include "super_fast_hash.h"
5 //#define hash_function super_fast_hash
6 #include "sha1.h"
7 #define hash_function sha1_hash
8
9 static inline int hash_compare(HASH_TYPE *h1, HASH_TYPE *h2)
10 {
11         int i;
12
13         for (i = 0; i < HASH_SIZE; i++) {
14                 if (h1[i] < h2[i])
15                         return -1;
16                 if (h1[i] > h2[i])
17                         return 1;
18         }
19         return 0;
20 }
21
22 static inline void hash_to_asc(HASH_TYPE *hash, char *asc)
23 {
24         int i;
25         const char hexchar[] = "0123456789abcdef";
26
27         for (i = 0; i < HASH_SIZE; i++) {
28                 asc[2 * i] = hexchar[hash[i] >> 4];
29                 asc[2 * i + 1] = hexchar[hash[i] & 0xf];
30         }
31         asc[2 * HASH_SIZE] = '\0';
32 }