xref: /PHP-7.2/ext/dba/libflatfile/flatfile.h (revision 7a7ec01a)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2018 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 /* $Id$ */
20 
21 #ifndef PHP_LIB_FLATFILE_H
22 #define PHP_LIB_FLATFILE_H
23 
24 typedef struct {
25 	char *dptr;
26 	size_t dsize;
27 } datum;
28 
29 typedef struct {
30 	char *lockfn;
31 	int lockfd;
32 	php_stream *fp;
33 	size_t CurrentFlatFilePos;
34 	datum nextkey;
35 } flatfile;
36 
37 #define FLATFILE_INSERT 1
38 #define FLATFILE_REPLACE 0
39 
40 int flatfile_store(flatfile *dba, datum key_datum, datum value_datum, int mode);
41 datum flatfile_fetch(flatfile *dba, datum key_datum);
42 int flatfile_delete(flatfile *dba, datum key_datum);
43 int flatfile_findkey(flatfile *dba, datum key_datum);
44 datum flatfile_firstkey(flatfile *dba);
45 datum flatfile_nextkey(flatfile *dba);
46 char *flatfile_version();
47 
48 #endif
49