xref: /PHP-8.0/ext/dba/libflatfile/flatfile.h (revision 5d6e923d)
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    | http://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 
17 #ifndef PHP_LIB_FLATFILE_H
18 #define PHP_LIB_FLATFILE_H
19 
20 typedef struct {
21 	char *dptr;
22 	size_t dsize;
23 } datum;
24 
25 typedef struct {
26 	char *lockfn;
27 	int lockfd;
28 	php_stream *fp;
29 	size_t CurrentFlatFilePos;
30 	datum nextkey;
31 } flatfile;
32 
33 #define FLATFILE_INSERT 1
34 #define FLATFILE_REPLACE 0
35 
36 int flatfile_store(flatfile *dba, datum key_datum, datum value_datum, int mode);
37 datum flatfile_fetch(flatfile *dba, datum key_datum);
38 int flatfile_delete(flatfile *dba, datum key_datum);
39 int flatfile_findkey(flatfile *dba, datum key_datum);
40 datum flatfile_firstkey(flatfile *dba);
41 datum flatfile_nextkey(flatfile *dba);
42 char *flatfile_version();
43 
44 #endif
45