- Notifications
You must be signed in to change notification settings - Fork 7.8k
/
Copy pathphp_ini_builder.h
95 lines (79 loc) · 2.73 KB
/
php_ini_builder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Max Kellermann <max.kellermann@ionos.com> |
+----------------------------------------------------------------------+
*/
#ifndefPHP_INI_BUILDER_H
#definePHP_INI_BUILDER_H
#include"php.h"
/**
* A class which helps with constructing INI entries from the command
* line.
*/
structphp_ini_builder {
char*value;
size_tlength;
};
BEGIN_EXTERN_C()
staticinlinevoidphp_ini_builder_init(structphp_ini_builder*b)
{
b->value=NULL;
b->length=0;
}
staticinlinevoidphp_ini_builder_deinit(structphp_ini_builder*b)
{
free(b->value);
}
/**
* Null-terminate the buffer and return it.
*/
staticinlinechar*php_ini_builder_finish(structphp_ini_builder*b)
{
if (b->value!=NULL) {
/* null-terminate the string */
b->value[b->length] ='\0';
}
returnb->value;
}
/**
* Make room for more data.
*
* @param delta the number of bytes to be appended
*/
staticinlinevoidphp_ini_builder_realloc(structphp_ini_builder*b, size_tdelta)
{
/* reserve enough space for the null terminator */
b->value=realloc(b->value, b->length+delta+1);
}
/**
* Prepend a string.
*
* @param src the source string
* @param length the size of the source string
*/
PHPAPIvoidphp_ini_builder_prepend(structphp_ini_builder*b, constchar*src, size_tlength);
#definephp_ini_builder_prepend_literal(b, l) php_ini_builder_prepend(b, l, strlen(l))
/**
* Append an unquoted name/value pair.
*/
PHPAPIvoidphp_ini_builder_unquoted(structphp_ini_builder*b, constchar*name, size_tname_length, constchar*value, size_tvalue_length);
/**
* Append a quoted name/value pair.
*/
PHPAPIvoidphp_ini_builder_quoted(structphp_ini_builder*b, constchar*name, size_tname_length, constchar*value, size_tvalue_length);
/**
* Parse an INI entry from the command-line option "--define".
*/
PHPAPIvoidphp_ini_builder_define(structphp_ini_builder*b, constchar*arg);
END_EXTERN_C()
#endif