cdb.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Author: Marcus Boerger <helly@php.net> |
  14. +----------------------------------------------------------------------+
  15. */
  16. /* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
  17. #ifndef CDB_H
  18. #define CDB_H
  19. #include "uint32.h"
  20. #define CDB_HASHSTART 5381
  21. struct cdb {
  22. php_stream *fp;
  23. uint32 loop; /* number of hash slots searched under this key */
  24. uint32 khash; /* initialized if loop is nonzero */
  25. uint32 kpos; /* initialized if loop is nonzero */
  26. uint32 hpos; /* initialized if loop is nonzero */
  27. uint32 hslots; /* initialized if loop is nonzero */
  28. uint32 dpos; /* initialized if cdb_findnext() returns 1 */
  29. uint32 dlen; /* initialized if cdb_findnext() returns 1 */
  30. };
  31. uint32 cdb_hash(char *, unsigned int);
  32. void cdb_free(struct cdb *);
  33. void cdb_init(struct cdb *, php_stream *fp);
  34. int cdb_read(struct cdb *, char *, unsigned int, uint32);
  35. void cdb_findstart(struct cdb *);
  36. int cdb_findnext(struct cdb *, char *, unsigned int);
  37. int cdb_find(struct cdb *, char *, unsigned int);
  38. #define cdb_datapos(c) ((c)->dpos)
  39. #define cdb_datalen(c) ((c)->dlen)
  40. char *cdb_version(void);
  41. #endif