-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDeepTrace_class.c
73 lines (63 loc) · 2.63 KB
/
DeepTrace_class.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
/*
* +------------------------------------------------------------------------+
* | DeepTrace (Website: http://www.snapserv.net/) |
* +------------------------------------------------------------------------+
* | Copyright (c) 2012-2013 P. Mathis ([email protected]) |
* | Y. Khalil ([email protected]) |
* +------------------------------------------------------------------------+
* | Licensed under the Apache License, Version 2.0 (the "License"); |
* | you may not use this file except in compliance with the License. |
* | You may obtain a copy of the License at |
* | |
* | http://www.apache.org/licenses/LICENSE-2.0 |
* | |
* | Unless required by applicable law or agreed to in writing, software |
* | distributed under the License is distributed on an "AS IS" BASIS, |
* | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
* | implied. See the License for the specific language governing |
* | permissions and limitations under the License. |
* +------------------------------------------------------------------------+
*/
#include "php_DeepTrace.h"
/* {{{ proto bool dt_remove_class(string className)
Deletes a PHP class */
PHP_FUNCTION(dt_remove_class)
{
DEEPTRACE_DECL_STRING_PARAM(className);
if(UNEXPECTED(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", DEEPTRACE_STRING_PARAM(className)) == FAILURE)) {
RETURN_FALSE;
}
/* Make class name lower case */
className = zend_str_tolower_dup(className, className_len);
/* Remove class in hash table */
if(UNEXPECTED(zend_hash_del(EG(class_table), className, className_len + 1) == FAILURE)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not remove class, trait or interface '%s'.", className);
efree(className);
RETURN_FALSE;
}
DeepTrace_clear_all_functions_runtime_cache(TSRMLS_C);
efree(className);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool dt_destroy_class_data(string className)
Destroys the data of a PHP class. */
PHP_FUNCTION(dt_destroy_class_data)
{
DEEPTRACE_DECL_STRING_PARAM(className);
zend_class_entry **class;
if(UNEXPECTED(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", DEEPTRACE_STRING_PARAM(className)) == FAILURE)) {
RETURN_FALSE;
}
/* Make class name lowercase */
className = zend_str_tolower_dup(className, className_len);
if(UNEXPECTED(zend_hash_find(EG(class_table), className, className_len + 1, (void **) &class) == FAILURE)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class '%s' not found.", className);
efree(className);
RETURN_FALSE;
}
zend_cleanup_class_data(class TSRMLS_CC);
efree(className);
RETURN_TRUE;
}
/* }}} */