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.
 
 
 
 

53 lines
1.6 KiB

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