xref: /PHP-7.4/ext/dba/libcdb/cdb.h (revision 0cf7de1c)
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_H
22 #define CDB_H
23 
24 #include "uint32.h"
25 
26 #define CDB_HASHSTART 5381
27 
28 struct cdb {
29 	php_stream *fp;
30 	uint32 loop; /* number of hash slots searched under this key */
31 	uint32 khash; /* initialized if loop is nonzero */
32 	uint32 kpos; /* initialized if loop is nonzero */
33 	uint32 hpos; /* initialized if loop is nonzero */
34 	uint32 hslots; /* initialized if loop is nonzero */
35 	uint32 dpos; /* initialized if cdb_findnext() returns 1 */
36 	uint32 dlen; /* initialized if cdb_findnext() returns 1 */
37 };
38 
39 uint32 cdb_hash(char *, unsigned int);
40 
41 void cdb_free(struct cdb *);
42 void cdb_init(struct cdb *, php_stream *fp);
43 
44 int cdb_read(struct cdb *, char *, unsigned int, uint32);
45 
46 void cdb_findstart(struct cdb *);
47 int cdb_findnext(struct cdb *, char *, unsigned int);
48 int cdb_find(struct cdb *, char *, unsigned int);
49 
50 #define cdb_datapos(c) ((c)->dpos)
51 #define cdb_datalen(c) ((c)->dlen)
52 
53 char *cdb_version();
54 
55 #endif
56