xref: /PHP-8.0/ext/dba/libinifile/inifile.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_INIFILE_H
18 #define PHP_LIB_INIFILE_H
19 
20 typedef struct {
21 	char *group;
22 	char *name;
23 } key_type;
24 
25 typedef struct {
26 	char *value;
27 } val_type;
28 
29 typedef struct {
30 	key_type key;
31 	val_type val;
32 	size_t pos;
33 } line_type;
34 
35 typedef struct {
36 	char *lockfn;
37 	int lockfd;
38 	php_stream *fp;
39 	int readonly;
40 	line_type curr;
41 	line_type next;
42 } inifile;
43 
44 val_type inifile_fetch(inifile *dba, const key_type *key, int skip);
45 int inifile_firstkey(inifile *dba);
46 int inifile_nextkey(inifile *dba);
47 int inifile_delete(inifile *dba, const key_type *key);
48 int inifile_delete_ex(inifile *dba, const key_type *key, zend_bool *found);
49 int inifile_replace(inifile *dba, const key_type *key, const val_type *val);
50 int inifile_replace_ex(inifile *dba, const key_type *key, const val_type *val, zend_bool *found);
51 int inifile_append(inifile *dba, const key_type *key, const val_type *val);
52 char *inifile_version();
53 
54 key_type inifile_key_split(const char *group_name);
55 char * inifile_key_string(const key_type *key);
56 
57 void inifile_key_free(key_type *key);
58 void inifile_val_free(val_type *val);
59 void inifile_line_free(line_type *ln);
60 
61 inifile * inifile_alloc(php_stream *fp, int readonly, int persistent);
62 void inifile_free(inifile *dba, int persistent);
63 
64 #endif
65