forked from krakjoe/ilimit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp_ilimit.c
116 lines (99 loc) · 3.27 KB
/
php_ilimit.c
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
+----------------------------------------------------------------------+
| ilimit |
+----------------------------------------------------------------------+
| Copyright (c) Joe Watkins 2019 |
+----------------------------------------------------------------------+
| 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: |
| http://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 |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: krakjoe |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "php.h"
#include "ext/standard/info.h"
#include "php_ilimit.h"
#include "src/ilimit.h"
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(ilimit)
{
php_ilimit_startup();
return SUCCESS;
} /* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(ilimit)
{
php_info_print_table_start();
php_info_print_table_header(2, "ilimit support", "enabled");
php_info_print_table_end();
}
/* }}} */
/* {{{ arg info */
ZEND_BEGIN_ARG_INFO_EX(zend_ilimit_arginfo, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, callable, IS_CALLABLE, 0)
ZEND_ARG_TYPE_INFO(0, arguments, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, cpu, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, memory, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, interval, IS_LONG, 0)
ZEND_END_ARG_INFO() /* }}} */
/* {{{ proto mixed \ilimit\call(callable $function [, array $args, int $timeoutMS, int $memoryBytes, int $intervalMs = 100]) */
ZEND_NAMED_FUNCTION(zend_ilimit_call)
{
php_ilimit_call_t call;
zval *args = NULL;
php_ilimit_call_init(&call, execute_data);
ZEND_PARSE_PARAMETERS_START(1, 5)
Z_PARAM_FUNC(call.zend.info, call.zend.cache)
Z_PARAM_OPTIONAL
Z_PARAM_ARRAY(args)
Z_PARAM_LONG(call.limits.timeout)
Z_PARAM_LONG(call.limits.memory.max)
Z_PARAM_LONG(call.limits.memory.interval)
ZEND_PARSE_PARAMETERS_END();
call.zend.info.retval = return_value;
if (args) {
zend_fcall_info_args(&call.zend.info, args);
}
php_ilimit_call(&call);
if (args) {
zend_fcall_info_args_clear(&call.zend.info, 1);
}
} /* }}} */
/* {{{ zend_ilimit_functions[]
*/
static const zend_function_entry zend_ilimit_api[] = {
ZEND_NS_FENTRY("ilimit", call, zend_ilimit_call, zend_ilimit_arginfo, 0)
ZEND_FE_END
};
/* }}} */
/* {{{ ilimit_module_entry
*/
zend_module_entry ilimit_module_entry = {
STANDARD_MODULE_HEADER,
"ilimit",
zend_ilimit_api,
PHP_MINIT(ilimit),
NULL,
NULL,
NULL,
PHP_MINFO(ilimit),
PHP_ILIMIT_VERSION,
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_ILIMIT
# ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
# endif
ZEND_GET_MODULE(ilimit)
#endif