-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy path_context.c
More file actions
56 lines (45 loc) · 1.28 KB
/
_context.c
File metadata and controls
56 lines (45 loc) · 1.28 KB
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
// Copyright 2017 Alexander Palaistras. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
static void _context_bind(char *name, zval *value) {
ZEND_SET_SYMBOL(EG(active_symbol_table), name, value);
}
static void _context_ini(char *name, char *value) {
if (zend_alter_ini_entry_ex(name, strlen(name) + 1, value, strlen(value) + 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0) == FAILURE) {
errno = 1;
}
}
static void _context_eval(zend_op_array *op, zval *ret) {
zend_op_array *oparr = EG(active_op_array);
zval *retval = NULL;
zval **retvalptr = EG(return_value_ptr_ptr);
zend_op **opline = EG(opline_ptr);
int interact = CG(interactive);
EG(return_value_ptr_ptr) = &retval;
EG(active_op_array) = op;
EG(no_extensions) = 1;
if (!EG(active_symbol_table)) {
zend_rebuild_symbol_table();
}
CG(interactive) = 0;
zend_try {
zend_execute(op);
} zend_catch {
destroy_op_array(op);
efree(op);
zend_bailout();
} zend_end_try();
destroy_op_array(op);
efree(op);
CG(interactive) = interact;
if (retval) {
ZVAL_COPY_VALUE(ret, retval);
zval_copy_ctor(ret);
} else {
ZVAL_NULL(ret);
}
EG(no_extensions) = 0;
EG(opline_ptr) = opline;
EG(active_op_array) = oparr;
EG(return_value_ptr_ptr) = retvalptr;
}