Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.6 KiB

15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
  1. /* this header file comes from libowfat, http://www.fefe.de/libowfat/ */
  2. #ifndef CDB_H
  3. #define CDB_H
  4. #include <stddef.h>
  5. #include <libowfat/uint32.h>
  6. #include <libowfat/uint64.h>
  7. #include <libowfat/compiler.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #define CDB_HASHSTART 5381
  12. att_const
  13. uint32 cdb_hashadd(uint32 h, unsigned char c);
  14. att_pure
  15. att_read(1)
  16. uint32 cdb_hash(const unsigned char *buf, size_t len);
  17. struct cdb {
  18. char *map; /* 0 if no map is available */
  19. int64 fd;
  20. uint32 size; /* initialized if map is nonzero */
  21. uint32 loop; /* number of hash slots searched under this key */
  22. uint32 khash; /* initialized if loop is nonzero */
  23. uint32 kpos; /* initialized if loop is nonzero */
  24. uint32 hpos; /* initialized if loop is nonzero */
  25. uint32 hslots; /* initialized if loop is nonzero */
  26. uint32 dpos; /* initialized if cdb_findnext() returns 1 */
  27. uint32 dlen; /* initialized if cdb_findnext() returns 1 */
  28. } ;
  29. void cdb_free(struct cdb *);
  30. void cdb_init(struct cdb *, int64 fd);
  31. int cdb_read(struct cdb * restrict, unsigned char * restrict, size_t, uint32);
  32. extern void cdb_findstart(struct cdb *);
  33. extern int cdb_findnext(struct cdb *, const unsigned char *, size_t);
  34. extern int cdb_find(struct cdb *, const unsigned char *, size_t);
  35. extern int cdb_firstkey(struct cdb *c,uint32 *kpos);
  36. extern int cdb_nextkey(struct cdb *c,uint32 *kpos);
  37. extern int cdb_successor(struct cdb *c, const unsigned char *, size_t);
  38. #define cdb_datapos(c) ((c)->dpos)
  39. #define cdb_datalen(c) ((c)->dlen)
  40. #define cdb_keypos(c) ((c)->kpos)
  41. #define cdb_keylen(c) ((c)->dpos-(c)->kpos)
  42. #ifdef __cplusplus
  43. }
  44. #endif
  45. #endif