]> git.ipfire.org Git - thirdparty/git.git/blame - sha1-lookup.h
tests: use shorter labels in chainlint.sed for AIX sed
[thirdparty/git.git] / sha1-lookup.h
CommitLineData
628522ec
JH
1#ifndef SHA1_LOOKUP_H
2#define SHA1_LOOKUP_H
3
96beef8c
CC
4typedef const unsigned char *sha1_access_fn(size_t index, void *table);
5
6extern int sha1_pos(const unsigned char *sha1,
7 void *table,
8 size_t nr,
9 sha1_access_fn fn);
b4e00f73
JT
10
11/*
12 * Searches for sha1 in table, using the given fanout table to determine the
13 * interval to search, then using binary search. Returns 1 if found, 0 if not.
14 *
15 * Takes the following parameters:
16 *
17 * - sha1: the hash to search for
18 * - fanout_nbo: a 256-element array of NETWORK-order 32-bit integers; the
19 * integer at position i represents the number of elements in table whose
20 * first byte is less than or equal to i
21 * - table: a sorted list of hashes with optional extra information in between
22 * - stride: distance between two consecutive elements in table (should be
23 * GIT_MAX_RAWSZ or greater)
24 * - result: if not NULL, this function stores the element index of the
25 * position found (if the search is successful) or the index of the least
26 * element that is greater than sha1 (if the search is not successful)
27 *
28 * This function does not verify the validity of the fanout table.
29 */
30int bsearch_hash(const unsigned char *sha1, const uint32_t *fanout_nbo,
31 const unsigned char *table, size_t stride, uint32_t *result);
628522ec 32#endif