sha1-lookup.hon commit editor: add a function to launch the sequence editor (2aed018)
   1#ifndef SHA1_LOOKUP_H
   2#define SHA1_LOOKUP_H
   3
   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);
  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);
  32#endif