1 /* 2 +----------------------------------------------------------------------+ 3 | Zend Engine | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) | 6 +----------------------------------------------------------------------+ 7 | This source file is subject to version 2.00 of the Zend license, | 8 | that is bundled with this package in the file LICENSE, and is | 9 | available through the world-wide-web at the following url: | 10 | http://www.zend.com/license/2_00.txt. | 11 | If you did not receive a copy of the Zend license and are unable to | 12 | obtain it through the world-wide-web, please send a note to | 13 | license@zend.com so we can mail you a copy immediately. | 14 +----------------------------------------------------------------------+ 15 | Authors: Levi Morrison <levim@php.net> | 16 | Sammy Kaye Powers <sammyk@php.net> | 17 +----------------------------------------------------------------------+ 18 */ 19 20 #ifndef ZEND_OBSERVER_H 21 #define ZEND_OBSERVER_H 22 23 #include "zend.h" 24 #include "zend_compile.h" 25 26 BEGIN_EXTERN_C() 27 28 extern ZEND_API int zend_observer_fcall_op_array_extension; 29 30 #define ZEND_OBSERVER_ENABLED (zend_observer_fcall_op_array_extension != -1) 31 32 #define ZEND_OBSERVER_FCALL_BEGIN(execute_data) do { \ 33 if (ZEND_OBSERVER_ENABLED) { \ 34 zend_observer_fcall_begin(execute_data); \ 35 } \ 36 } while (0) 37 38 #define ZEND_OBSERVER_FCALL_END(execute_data, return_value) do { \ 39 if (ZEND_OBSERVER_ENABLED) { \ 40 zend_observer_fcall_end(execute_data, return_value); \ 41 } \ 42 } while (0) 43 44 typedef void (*zend_observer_fcall_begin_handler)(zend_execute_data *execute_data); 45 typedef void (*zend_observer_fcall_end_handler)(zend_execute_data *execute_data, zval *retval); 46 47 typedef struct _zend_observer_fcall_handlers { 48 zend_observer_fcall_begin_handler begin; 49 zend_observer_fcall_end_handler end; 50 } zend_observer_fcall_handlers; 51 52 /* If the fn should not be observed then return {NULL, NULL} */ 53 typedef zend_observer_fcall_handlers (*zend_observer_fcall_init)(zend_execute_data *execute_data); 54 55 // Call during minit/startup ONLY 56 ZEND_API void zend_observer_fcall_register(zend_observer_fcall_init); 57 58 ZEND_API void zend_observer_startup(void); // Called by engine before MINITs 59 ZEND_API void zend_observer_post_startup(void); // Called by engine after MINITs 60 ZEND_API void zend_observer_activate(void); 61 ZEND_API void zend_observer_deactivate(void); 62 ZEND_API void zend_observer_shutdown(void); 63 64 ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin( 65 zend_execute_data *execute_data); 66 67 ZEND_API void ZEND_FASTCALL zend_observer_generator_resume( 68 zend_execute_data *execute_data); 69 70 ZEND_API void ZEND_FASTCALL zend_observer_fcall_end( 71 zend_execute_data *execute_data, 72 zval *return_value); 73 74 ZEND_API void zend_observer_fcall_end_all(void); 75 76 typedef void (*zend_observer_error_cb)(int type, const char *error_filename, uint32_t error_lineno, zend_string *message); 77 78 ZEND_API void zend_observer_error_register(zend_observer_error_cb callback); 79 void zend_observer_error_notify(int type, const char *error_filename, uint32_t error_lineno, zend_string *message); 80 81 END_EXTERN_C() 82 83 #endif /* ZEND_OBSERVER_H */ 84