cdb_make.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_MAKE_H
  18. #define CDB_MAKE_H
  19. #include <stdio.h>
  20. #include "uint32.h"
  21. #define CDB_HPLIST 1000
  22. struct cdb_hp {
  23. uint32 h;
  24. uint32 p;
  25. };
  26. struct cdb_hplist {
  27. struct cdb_hp hp[CDB_HPLIST];
  28. struct cdb_hplist *next;
  29. int num;
  30. } ;
  31. struct cdb_make {
  32. /* char bspace[8192]; */
  33. char final[2048];
  34. uint32 count[256];
  35. uint32 start[256];
  36. struct cdb_hplist *head;
  37. struct cdb_hp *split; /* includes space for hash */
  38. struct cdb_hp *hash;
  39. uint32 numentries;
  40. /* buffer b; */
  41. uint32 pos;
  42. /* int fd; */
  43. php_stream * fp;
  44. };
  45. int cdb_make_start(struct cdb_make *, php_stream *);
  46. int cdb_make_addbegin(struct cdb_make *, unsigned int, unsigned int);
  47. int cdb_make_addend(struct cdb_make *, unsigned int, unsigned int, uint32);
  48. int cdb_make_add(struct cdb_make *, char *, unsigned int, char *, unsigned int);
  49. int cdb_make_finish(struct cdb_make *);
  50. char *cdb_make_version(void);
  51. #endif