1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) The PHP Group                                          |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Author: Marcus Boerger <helly@php.net>                               |
16    +----------------------------------------------------------------------+
17  */
18 
19 /* incorporated from D.J.Bernstein's cdb-0.75 (http://cr.yp.to/cdb.html)*/
20 
21 #ifndef CDB_MAKE_H
22 #define CDB_MAKE_H
23 
24 #include <stdio.h>
25 #include "uint32.h"
26 
27 #define CDB_HPLIST 1000
28 
29 struct cdb_hp {
30 	uint32 h;
31 	uint32 p;
32 };
33 
34 struct cdb_hplist {
35 	struct cdb_hp hp[CDB_HPLIST];
36 	struct cdb_hplist *next;
37 	int num;
38 } ;
39 
40 struct cdb_make {
41 	/* char bspace[8192]; */
42 	char final[2048];
43 	uint32 count[256];
44 	uint32 start[256];
45 	struct cdb_hplist *head;
46 	struct cdb_hp *split; /* includes space for hash */
47 	struct cdb_hp *hash;
48 	uint32 numentries;
49 	/* buffer b; */
50 	uint32 pos;
51 	/* int fd; */
52 	php_stream * fp;
53 };
54 
55 int cdb_make_start(struct cdb_make *, php_stream *);
56 int cdb_make_addbegin(struct cdb_make *, unsigned int, unsigned int);
57 int cdb_make_addend(struct cdb_make *, unsigned int, unsigned int, uint32);
58 int cdb_make_add(struct cdb_make *, char *, unsigned int, char *, unsigned int);
59 int cdb_make_finish(struct cdb_make *);
60 char *cdb_make_version();
61 
62 #endif
63