cvs: pecl /inclued INSTALL config.m4 gengraph.php inclued.c inclued.h inclued_zend.c inclued_zend.h

From: Date: Wed, 23 Jan 2008 20:05:28 +0000
Subject: cvs: pecl /inclued INSTALL config.m4 gengraph.php inclued.c inclued.h inclued_zend.c inclued_zend.h
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-9583@lists.php.net to get a copy of this message
gopalv Wed Jan 23 20:05:28 2008 UTC Added files: /pecl/inclued INSTALL config.m4 gengraph.php inclued.c inclued.h inclued_zend.c inclued_zend.h Log: initial check-in

http://cvs.php.net/viewvc.cgi/pecl/inclued/config.m4?view=markup&rev=1.1 Index: pecl/inclued/config.m4 +++ pecl/inclued/config.m4 dnl $Id: config.m4,v 1.1 2008/01/23 20:05:28 gopalv Exp $ dnl config.m4 for extension inclued PHP_ARG_ENABLE(inclued, whether to enable inclued support, [ --enable-inclued Enable inclued support]) if test "$PHP_INCLUED" != "no"; then dnl Write more examples of tests here... dnl # --with-inclued -> check with-path dnl SEARCH_PATH="/usr/local /usr" # you might want to change this dnl SEARCH_FOR="/include/inclued.h" # you most likely want to change this dnl if test -r $PHP_INCLUED/; then # path given as parameter dnl INCLUED_DIR=$PHP_INCLUED dnl else # search default path list dnl AC_MSG_CHECKING([for inclued files in default path]) dnl for i in $SEARCH_PATH ; do dnl if test -r $i/$SEARCH_FOR; then dnl INCLUED_DIR=$i dnl AC_MSG_RESULT(found in $i) dnl fi dnl done dnl fi dnl dnl if test -z "$INCLUED_DIR"; then dnl AC_MSG_RESULT([not found]) dnl AC_MSG_ERROR([Please reinstall the inclued distribution]) dnl fi dnl # --with-inclued -> add include path dnl PHP_ADD_INCLUDE($INCLUED_DIR/include) dnl # --with-inclued -> check for lib and symbol presence dnl LIBNAME=inclued # you may want to change this dnl LIBSYMBOL=inclued # you most likely want to change this dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, dnl [ dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $INCLUED_DIR/lib, INCLUED_SHARED_LIBADD) dnl AC_DEFINE(HAVE_INCLUEDLIB,1,[ ]) dnl ],[ dnl AC_MSG_ERROR([wrong inclued lib version or lib not found]) dnl ],[ dnl -L$INCLUED_DIR/lib -lm -ldl dnl ]) dnl dnl PHP_SUBST(INCLUED_SHARED_LIBADD) inclued_sources="inclued.c \ inclued_zend.c" PHP_NEW_EXTENSION(inclued, $inclued_sources, $ext_shared) fi http://cvs.php.net/viewvc.cgi/pecl/inclued/gengraph.php?view=markup&rev=1.1 Index: pecl/inclued/gengraph.php +++ pecl/inclued/gengraph.php <?php /* +----------------------------------------------------------------------+ | Inclued | +----------------------------------------------------------------------+ | Copyright (c) 2007 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: | | 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 | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Gopal Vijayaraghavan <gopalv@php.net> | +----------------------------------------------------------------------+ */ $options = getopt("i:t:o:d:"); function usage() { echo "{$GLOBALS['argv'][0]} -i <inclued_dump> [-t includes|classes] [-o <output_file>] [-d docroot]\n"; exit(1); } if(!isset($options['o'])) $ofile = "inclued.out.dot"; else $ofile = $options['o']; if(!isset($options['i'])) usage(); else $ifile = $options['i']; if(!isset($options['d'])) $docroot = ""; else $docroot = $options['d']; if(!isset($options['t'])) $type = "includes"; else $type = $options['t']; if($type != 'includes' && $type != 'classes') { echo "unknown type provided: $type\n"; exit(1); } $data = unserialize(file_get_contents($ifile)); if(!$data) { echo "Could not deserialize data dump\n"; exit(1); } function dump_include($fp, $inc) { global $docroot; $style = isset($inc['duplicate']) ? "dashed" : "solid"; $short_fromfile = str_replace($docroot, '', $inc['fromfile']); $short_opened_path = str_replace($docroot, '', $inc['opened_path']); $content = <<<EOF "{$inc['fromfile']}" [label="{$short_fromfile}"]; "{$inc['opened_path']}" [label="{$short_opened_path}"]; "{$inc['fromfile']}" -> "{$inc['opened_path']}" [label = "{$inc['operation']}", style="{$style}"]; EOF; fwrite($fp, $content); } function dump_filemap($fp, $filemap) { global $docroot; foreach($filemap as $k => $v) { $short_path = str_replace($docroot, '', $k); $content = <<<EOF subgraph "cluster_{$k}" { label="{$short_path}"; fontcolor = "blue"; color = "lightgrey"; fontsize = "11pt"; EOF; fwrite($fp, $content); foreach($v as $kk => $vv) { $class = $vv; $content = <<<EOF "{$class['mangled_name']}" [label="{$class['name']}"]; EOF; fwrite($fp, $content); } $content = <<<EOF }; /* end subgraph "{$k}" */ EOF; fwrite($fp, $content); } foreach($filemap as $k => $v) { foreach($v as $kk => $vv) { $class = $vv; $derieved = isset($class['parent']); $internal = false; if($derieved) { $parent_name = strtolower($class['parent']['name']); $internal = isset($class['parent']['internal']); } else { $parent_name = "<object>"; } $content = <<<EOF "{$parent_name}" -> "{$class['mangled_name']}"; EOF; if($internal) { $content .= <<<EOF "<object>" -> "{$parent_name}"; EOF; } fwrite($fp, $content); } } } $fp = fopen($ofile, "wb"); $content = <<<EOF digraph phpdeps { size="6.6"; node [shape = ellipse]; node [color="#add960", style=filled]; graph [bgcolor="#f7f7f7"]; rankdir = "LR"; EOF; fwrite($fp, $content); if($type == 'includes') { foreach($data["includes"] as $k => $v) dump_include($fp, $v); } else /* classes */ { $filemap = array(); foreach($data["classes"] as $k => $v) { $class = $v; if(isset($class["mangled_name"])) { if(strstr($class["mangled_name"], '/')) { /* must have a real counterpart, if it was used */ continue; } } if(isset($class['internal'])) { $class['filename'] = "internal"; } if(!isset($filemap[$class['filename']])) { $filemap[$class['filename']] = array(); } array_push($filemap[$class['filename']], $class); } dump_filemap($fp, $filemap); } fwrite($fp, "}"); echo "Written $ofile...\nTo generate images: dot -Tpng -o inclued.png $ofile\n"; /* $Id: gengraph.php,v 1.1 2008/01/23 20:05:28 gopalv Exp $ */ ?> http://cvs.php.net/viewvc.cgi/pecl/inclued/inclued.c?view=markup&rev=1.1 Index: pecl/inclued/inclued.c +++ pecl/inclued/inclued.c /* +----------------------------------------------------------------------+ | Inclued | +----------------------------------------------------------------------+ | Copyright (c) 2007 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: | | 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 | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Gopal Vijayaraghavan <gopalv@php.net> | +----------------------------------------------------------------------+ */ /* $Id: inclued.c,v 1.1 2008/01/23 20:05:28 gopalv Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "inclued.h" /* {{{ stupid stringifcation */ #if DEFAULT_SLASH == '/' #define DEFAULT_SLASH_STRING "/" #elif DEFAULT_SLASH == '\\' #define DEFAULT_SLASH_STRING "\\" #else #error "Unknown value for DEFAULT_SLASH" #endif /* }}} */ /* {{{ inclued globals * * true globals, no need for thread safety here */ /* nothing for now */ /* }}} */ /* {{{ ZEND_DECLARE_MODULE_GLOBALS(inclued) */ ZEND_DECLARE_MODULE_GLOBALS(inclued) /* }}} */ /* {{{ php_inclued_init_globals */ static void php_inclued_init_globals(zend_inclued_globals* inclued_globals TSRMLS_DC) { inclued_globals->enabled = 0; inclued_globals->counter = 0; inclued_globals->dumpdir = 0; inclued_globals->includes_hash = NULL; inclued_globals->inh_hash = NULL; } /* }}} */ /* {{{ php_inclued_shutdown_globals */ static void php_inclued_shutdown_globals(zend_inclued_globals* inclued_globals TSRMLS_DC) { /* nothing ? */ } /* }}} */ /* {{{ ini entries */ PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN("inclued.enabled", "0", PHP_INI_SYSTEM, OnUpdateBool, enabled, zend_inclued_globals, inclued_globals) STD_PHP_INI_BOOLEAN("inclued.dumpdir", NULL, PHP_INI_SYSTEM, OnUpdateString, dumpdir, zend_inclued_globals, inclued_globals) PHP_INI_END() /* }}} */ /* {{{ PHP_FUNCTION declarations */ PHP_FUNCTION(inclued_get_data); /* }}} */ /* {{{ inclued_functions[] * * Every user visible function must have an entry in inclued_functions[]. */ zend_function_entry inclued_functions[] = { PHP_FE(inclued_get_data, NULL) {NULL, NULL, NULL} /* Must be the last line in inclued_functions[] */ }; /* }}} */ /* {{{ inclued_module_entry */ zend_module_entry inclued_module_entry = { STANDARD_MODULE_HEADER, "inclued", inclued_functions, PHP_MINIT(inclued), PHP_MSHUTDOWN(inclued), PHP_RINIT(inclued), PHP_RSHUTDOWN(inclued), PHP_MINFO(inclued), #if ZEND_MODULE_API_NO >= 20010901 "@PACKAGE_VERSION@", #endif STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_INCLUED ZEND_GET_MODULE(inclued) #endif /* {{{ copy_class_table */ static zval* copy_class_table(HashTable *ht) { HashPosition pos; zval *class_table = NULL; zend_class_entry **pce = NULL; zend_class_entry *ce = NULL; char *key = NULL; uint keylen = 0; zval *class_entry, *parent_entry; MAKE_STD_ZVAL(class_table); array_init(class_table); zend_hash_internal_pointer_reset_ex(ht, &pos); while(zend_hash_get_current_data_ex(ht, (void **) &pce, &pos) == SUCCESS) { zend_hash_get_current_key_ex(ht, &key, &keylen, NULL, 0, &pos); ce = pce[0]; if(ce->type == ZEND_INTERNAL_CLASS) { goto next; } /* TODO: class flags */ MAKE_STD_ZVAL(class_entry); array_init(class_entry); add_assoc_stringl(class_entry, "name", ce->name, ce->name_length, 1); if(ce->name[0] != key[0]) { add_assoc_stringl(class_entry, "mangled_name", key, keylen-1, 1); } add_assoc_string(class_entry, "filename", ce->filename, 1); add_assoc_long(class_entry, "line", ce->line_start); if(ce->parent) { MAKE_STD_ZVAL(parent_entry); array_init(parent_entry); add_assoc_stringl(parent_entry, "name", ce->parent->name, ce->parent->name_length, 1); if(ce->parent->type == ZEND_INTERNAL_CLASS) { add_assoc_bool(parent_entry, "internal", 1); } else { add_assoc_string(parent_entry, "filename", ce->parent->filename, 1); add_assoc_long(parent_entry, "line", ce->parent->line_start); } add_assoc_zval(class_entry, "parent", parent_entry); } add_next_index_zval(class_table, class_entry); next: zend_hash_move_forward_ex(ht, &pos); } return class_table; } /* }}} */ /* {{{ pack_output */ static void pack_output(zval* return_value) { zval **data; zval *includes_hash; zval *inh_hash; zval *request_hash; zval *class_table; #define COPY_INCLUED_G(h) do { \ MAKE_STD_ZVAL(h); \ *h = *INCLUED_G(h);\ zval_copy_ctor(h); \ }\ while(0) COPY_INCLUED_G(includes_hash); COPY_INCLUED_G(inh_hash); MAKE_STD_ZVAL(request_hash); array_init(request_hash); #define PULL_ZVAL(symtab, name) do { \ if (zend_hash_find((symtab), #name , sizeof(#name), (void **) &data) != FAILURE) \ { \ zval *copy_zval;\ MAKE_STD_ZVAL(copy_zval);\ *copy_zval = *data[0];\ zval_copy_ctor(copy_zval);\ add_assoc_zval(request_hash, #name, copy_zval);\ }\ } while(0); PULL_ZVAL(&EG(symbol_table),PHP_SELF); PULL_ZVAL(&EG(symbol_table),_REQUEST); PULL_ZVAL(&EG(symbol_table),_COOKIE); if (zend_hash_find((&EG(symbol_table)), "_SERVER", sizeof("_SERVER"), (void **) &data) != FAILURE) { HashTable *_server = Z_ARRVAL_PP(data); PULL_ZVAL(_server, SCRIPT_FILENAME); PULL_ZVAL(_server, REQUEST_URI); PULL_ZVAL(_server, REQUEST_TIME); } class_table = copy_class_table(EG(class_table)); array_init(return_value); add_assoc_zval(return_value, "request", request_hash); add_assoc_zval(return_value, "includes", includes_hash); add_assoc_zval(return_value, "inheritance", inh_hash); add_assoc_zval(return_value, "classes", class_table); return; } /* }}} */ /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(inclued) { ZEND_INIT_MODULE_GLOBALS(inclued, php_inclued_init_globals, php_inclued_shutdown_globals); REGISTER_INI_ENTRIES(); if(INCLUED_G(enabled)) { inclued_zend_init(TSRMLS_C); } return SUCCESS; } /* }}} */ /* {{{ PHP_MSHUTDOWN_FUNCTION * */ PHP_MSHUTDOWN_FUNCTION(inclued) { if(INCLUED_G(enabled)) { inclued_zend_shutdown(TSRMLS_C); } #ifdef ZTS ts_free_id(inclued_globals_id); #else php_inclued_shutdown_globals(&inclued_globals); #endif UNREGISTER_INI_ENTRIES(); return SUCCESS; } /* }}} */ /* {{{ PHP_RINIT_FUNCTION(inclued) */ PHP_RINIT_FUNCTION(inclued) { zval **data = NULL; if(INCLUED_G(enabled)) { /* allocate new info table */ ALLOC_INIT_ZVAL(INCLUED_G(includes_hash)); array_init(INCLUED_G(includes_hash)); ALLOC_INIT_ZVAL(INCLUED_G(inh_hash)); array_init(INCLUED_G(inh_hash)); INCLUED_G(counter)++; } return SUCCESS; } /* }}} */ /* {{{ PHP_RSHUTDOWN_FUNCTION(inclued) */ PHP_RSHUTDOWN_FUNCTION(inclued) { char path[MAXPATHLEN]; FILE *dumpfile; smart_str buf = {0}; php_serialize_data_t var_hash; zval retval; zval *pretval = &retval; if(INCLUED_G(enabled) && INCLUED_G(dumpdir)) { snprintf(path, MAXPATHLEN, "%s" DEFAULT_SLASH_STRING "inclued.%05d.%d", INCLUED_G(dumpdir), getpid(), INCLUED_G(counter)); if(!(dumpfile = fopen(path, "w"))) { zend_error(E_WARNING, "cannot write to %s" DEFAULT_SLASH_STRING, INCLUED_G(dumpdir)); } pack_output(pretval); PHP_VAR_SERIALIZE_INIT(var_hash); php_var_serialize(&buf, (zval**)&(pretval), &var_hash TSRMLS_CC); PHP_VAR_SERIALIZE_DESTROY(var_hash); fwrite(buf.c, buf.len, 1, dumpfile); fclose(dumpfile); smart_str_free(&buf); zval_dtor(pretval); } if(INCLUED_G(enabled)) { /* free allocated stuff */ zval_dtor(INCLUED_G(includes_hash)); INCLUED_G(includes_hash) = NULL; zval_dtor(INCLUED_G(inh_hash)); INCLUED_G(inh_hash) = NULL; } return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(inclued) { const char * ini_path = NULL; int module_number = zend_module->module_number; php_info_print_table_start(); php_info_print_table_row(2, "inclued support", INCLUED_G(enabled) ? "enabled" : "disabled"); php_info_print_table_row(2, "inclued.dumpdir", \ INCLUED_G(dumpdir) ? INCLUED_G(dumpdir) : ""); php_info_print_table_end(); } /* }}} */ /* {{{ proto mixed inclued_get_data(void) */ PHP_FUNCTION(inclued_get_data) { if(INCLUED_G(enabled)) { pack_output(return_value); return; } else { RETURN_FALSE; } } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/viewvc.cgi/pecl/inclued/inclued.h?view=markup&rev=1.1 Index: pecl/inclued/inclued.h +++ pecl/inclued/inclued.h /* +----------------------------------------------------------------------+ | Inclued | +----------------------------------------------------------------------+ | Copyright (c) 2007 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: | | 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 | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Gopal Vijayaraghavan <gopalv@php.net> | +----------------------------------------------------------------------+ */ /* $Id: inclued.h,v 1.1 2008/01/23 20:05:28 gopalv Exp $ */ #ifndef PHP_INCLUED_H #define PHP_INCLUED_H #include "php.h" #include "php_ini.h" #include "zend_globals.h" #include "ext/standard/php_var.h" #include "ext/standard/php_smart_str.h" extern zend_module_entry inclued_module_entry; #define phpext_inclued_ptr &inclued_module_entry #ifdef PHP_WIN32 #define PHP_INCLUED_API __declspec(dllexport) #else #define PHP_INCLUED_API #endif #ifdef ZTS #include "TSRM.h" #endif PHP_MINIT_FUNCTION(inclued); PHP_MSHUTDOWN_FUNCTION(inclued); PHP_RINIT_FUNCTION(inclued); PHP_RSHUTDOWN_FUNCTION(inclued); PHP_MINFO_FUNCTION(inclued); /* {{{ zend_inclued_globals */ ZEND_BEGIN_MODULE_GLOBALS(inclued) /* configuration parameters */ zend_bool enabled; /* defaults to false */ int counter; /* increment per request */ char* dumpdir; /* dump dir */ zval* includes_hash; /* hash storing the includes */ zval* inh_hash; /* hash storing inheritance operations */ ZEND_END_MODULE_GLOBALS(inclued) /* }}} */ /* {{{ extern inclued_globals */ ZEND_EXTERN_MODULE_GLOBALS(inclued) /* }}} */ #ifdef ZTS #define INCLUED_G(v) TSRMG(inclued_globals_id, zend_inclued_globals *, v) #else #define INCLUED_G(v) (inclued_globals.v) #endif #endif /* PHP_INCLUED_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/viewvc.cgi/pecl/inclued/inclued_zend.c?view=markup&rev=1.1 Index: pecl/inclued/inclued_zend.c +++ pecl/inclued/inclued_zend.c /* +----------------------------------------------------------------------+ | Inclued | +----------------------------------------------------------------------+ | Copyright (c) 2007 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: | | 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 | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Gopal Vijayaraghavan <gopalv@php.net> | +----------------------------------------------------------------------+ */ /* $Id: inclued_zend.c,v 1.1 2008/01/23 20:05:28 gopalv Exp $ */ #include "inclued.h" #include "inclued_zend.h" #define INCLUED_EX_T(offset) (*(temp_variable *)((char*)execute_data->Ts + offset)) static zval *inclued_get_zval_ptr(znode *node, zval **freeval, zend_execute_data *execute_data TSRMLS_DC) { *freeval = NULL; switch (node->op_type) { case IS_CONST: return &(node->u.constant); case IS_VAR: return INCLUED_EX_T(node->u.var).var.ptr; case IS_TMP_VAR: return (*freeval = &INCLUED_EX_T(node->u.var).tmp_var); #ifdef ZEND_ENGINE_2_1 case IS_CV: { zval ***ret = &execute_data->CVs[node->u.var]; if (!*ret) { zend_compiled_variable *cv = &EG(active_op_array)->vars[node->u.var]; if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void**)ret)==FAILURE) { zend_error(E_NOTICE, "Undefined variable: %s", cv->name); return &EG(uninitialized_zval); } } return **ret; } #endif case IS_UNUSED: default: return NULL; } } static int add_include(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = execute_data->opline; zval * includes_hash = INCLUED_G(includes_hash); char * operation; zval * include_entry; php_stream_wrapper *wrapper; zval *inc_filename = NULL, tmp_inc_filename; zval *freeop1 = NULL; char *path_for_open; zend_file_handle file_handle; int op_type = opline->op2.u.constant.value.lval; assert(includes_hash != NULL); switch(op_type) { case ZEND_INCLUDE: { operation = "include"; } break; case ZEND_REQUIRE: { operation = "require"; } break; case ZEND_REQUIRE_ONCE: { operation = "require_once"; } break; case ZEND_INCLUDE_ONCE: { operation = "include_once"; } break; case ZEND_EVAL: { operation = "eval"; } break; } if(op_type == ZEND_EVAL) { MAKE_STD_ZVAL(include_entry); array_init(include_entry); add_assoc_string(include_entry, "operation", operation, 1); add_assoc_long(include_entry, "op_type", op_type); add_assoc_string(include_entry, "fromfile", execute_data->op_array->filename, 1); add_assoc_long(include_entry, "fromline", opline->lineno); if(execute_data->op_array->function_name) { add_assoc_string(include_entry, "function", (char*)execute_data->op_array->function_name, 1); } add_next_index_zval(includes_hash, include_entry); return; } inc_filename = inclued_get_zval_ptr(&opline->op1, &freeop1, execute_data TSRMLS_CC); if(Z_TYPE_P(inc_filename) != IS_STRING) { tmp_inc_filename = *inc_filename; zval_copy_ctor(&tmp_inc_filename); convert_to_string(&tmp_inc_filename); inc_filename = &tmp_inc_filename; } wrapper = php_stream_locate_url_wrapper(Z_STRVAL_P(inc_filename), &path_for_open, 0 TSRMLS_CC); if(SUCCESS == zend_stream_open(inc_filename->value.str.val, &file_handle TSRMLS_CC)) { /* sledgehammer ! */ if (!file_handle.opened_path) { file_handle.opened_path = estrndup(inc_filename->value.str.val, inc_filename->value.str.len); } /* fprintf(stderr, "%s%s('%s') from %s:%d\n", (op_type & (ZEND_INCLUDE_ONCE | ZEND_INCLUDE)) ? "include" : "require", (op_type & (ZEND_INCLUDE_ONCE | ZEND_REQUIRE_ONCE)) ? "_once" : "", file_handle.opened_path, execute_data->op_array->filename, opline->lineno); */ MAKE_STD_ZVAL(include_entry); array_init(include_entry); add_assoc_string(include_entry, "operation", operation, 1); add_assoc_long(include_entry, "op_type", op_type); add_assoc_string(include_entry, "filename", Z_STRVAL_P(inc_filename), 1); add_assoc_string(include_entry, "opened_path", file_handle.opened_path, 1); if(zend_hash_exists(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1)) { add_assoc_bool(include_entry, "duplicate", 1); } add_assoc_string(include_entry, "fromfile", execute_data->op_array->filename, 1); add_assoc_long(include_entry, "fromline", opline->lineno); if(execute_data->op_array->function_name) { add_assoc_string(include_entry, "function", (char*)execute_data->op_array->function_name, 1); } if(opline->op1.op_type != IS_CONST) { add_assoc_bool(include_entry, "variable_include", 1); } if(wrapper != &php_plain_files_wrapper) { add_assoc_string(include_entry, "streamwrapper", (char*)wrapper->wops->label, 1); } add_next_index_zval(includes_hash, include_entry); zend_file_handle_dtor(&file_handle); } if(inc_filename==&tmp_inc_filename) { zval_dtor(&tmp_inc_filename); } } static int inclued_op_ZEND_INCLUDE_OR_EVAL(ZEND_OPCODE_HANDLER_ARGS) { add_include(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); return ZEND_USER_OPCODE_DISPATCH; } #define INCLUED_ZCE(entry, ce) do { \ MAKE_STD_ZVAL(entry); \ array_init(entry); \ add_assoc_stringl(entry, "name", ce->name, ce->name_length, 1); \ if(ce->type == ZEND_INTERNAL_CLASS) { \ add_assoc_bool(entry, "internal", 1); \ } else { \ add_assoc_string(entry, "filename", ce->filename, 1); \ add_assoc_long(entry, "line", ce->line_start); \ } \ }while(0) static void add_class(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = execute_data->opline; zval *inh_hash = INCLUED_G(inh_hash); zval *class_entry = NULL; zend_uchar opcode = opline->opcode; zend_class_entry* parent_ce = NULL; char *operation = NULL; assert(inh_hash != NULL); MAKE_STD_ZVAL(class_entry); array_init(class_entry); assert(opcode == ZEND_DECLARE_CLASS || opcode == ZEND_DECLARE_INHERITED_CLASS); /* TODO: class flags - public, private, abstract etc ... */ add_assoc_string(class_entry, "operation", (opcode == ZEND_DECLARE_CLASS) ? "declare_class" : "declare_inherited_class", 1); add_assoc_string(class_entry, "filename", execute_data->op_array->filename, 1); add_assoc_long(class_entry, "line", opline->lineno); add_assoc_stringl(class_entry,"name", Z_STRVAL_P(&opline->op2.u.constant), Z_STRLEN_P(&opline->op2.u.constant), 1); add_assoc_stringl(class_entry,"mangled", Z_STRVAL_P(&opline->op1.u.constant), Z_STRLEN_P(&opline->op1.u.constant), 1); if(opcode == ZEND_DECLARE_INHERITED_CLASS && (parent_ce = INCLUED_EX_T(opline->extended_value).class_entry)) { zval *parent_entry = NULL; INCLUED_ZCE(parent_entry, parent_ce); add_assoc_zval(class_entry, "parent", parent_entry); } if(execute_data->op_array->function_name) { add_assoc_string(class_entry, "function", (char*)execute_data->op_array->function_name, 1); } add_next_index_zval(inh_hash, class_entry); } static int inclued_op_ZEND_DECLARE_CLASS(ZEND_OPCODE_HANDLER_ARGS) { add_class(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); return ZEND_USER_OPCODE_DISPATCH; } #define inclued_op_ZEND_DECLARE_INHERITED_CLASS inclued_op_ZEND_DECLARE_CLASS static void add_interface(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = execute_data->opline; zval *inh_hash = INCLUED_G(inh_hash); zend_class_entry *ce = INCLUED_EX_T(opline->op1.u.var).class_entry; zend_class_entry *ice = INCLUED_EX_T(opline->op2.u.var).class_entry; zval *iface_entry, *iface; assert(inh_hash != NULL); MAKE_STD_ZVAL(iface_entry); array_init(iface_entry); add_assoc_string(iface_entry, "operation", "add_interface", 1); add_assoc_string(iface_entry, "filename", execute_data->op_array->filename, 1); add_assoc_long(iface_entry, "line", opline->lineno); add_assoc_stringl(iface_entry, "class_name", ce->name, ce->name_length, 1); if(execute_data->op_array->function_name) { add_assoc_string(iface_entry, "function", (char*)execute_data->op_array->function_name, 1); } INCLUED_ZCE(iface, ice); add_assoc_zval(iface_entry, "interface", iface); add_next_index_zval(inh_hash, iface_entry); } static int inclued_op_ZEND_ADD_INTERFACE(ZEND_OPCODE_HANDLER_ARGS) { add_interface(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); return ZEND_USER_OPCODE_DISPATCH; } void inclued_zend_init(TSRMLS_D) { if(INCLUED_G(enabled)) { if(zend_set_user_opcode_handler(ZEND_INCLUDE_OR_EVAL, inclued_op_ZEND_INCLUDE_OR_EVAL) == FAILURE) { zend_error(E_NOTICE, "cannot install inclued opcode overrides"); INCLUED_G(enabled) = 0; } if((zend_set_user_opcode_handler(ZEND_DECLARE_CLASS, inclued_op_ZEND_DECLARE_CLASS) == FAILURE) || (zend_set_user_opcode_handler(ZEND_DECLARE_INHERITED_CLASS, inclued_op_ZEND_DECLARE_INHERITED_CLASS) == FAILURE)) { zend_error(E_NOTICE, "cannot install inclued class inheritance overrides"); } if(zend_set_user_opcode_handler(ZEND_ADD_INTERFACE, inclued_op_ZEND_ADD_INTERFACE) == FAILURE) { zend_error(E_NOTICE, "cannot install inclued interface overrides"); } } } void inclued_zend_shutdown(TSRMLS_D) { /* nothing */ } http://cvs.php.net/viewvc.cgi/pecl/inclued/inclued_zend.h?view=markup&rev=1.1 Index: pecl/inclued/inclued_zend.h +++ pecl/inclued/inclued_zend.h /* +----------------------------------------------------------------------+ | Inclued | +----------------------------------------------------------------------+ | Copyright (c) 2007 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: | | 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 | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Gopal Vijayaraghavan <gopalv@php.net> | +----------------------------------------------------------------------+ */ /* $Id: inclued_zend.h,v 1.1 2008/01/23 20:05:28 gopalv Exp $ */ #ifndef PHP_INCLUED_ZEND_H #define PHP_INCLUED_ZEND_H #include "php.h" #include "zend.h" #include "zend_API.h" #include "zend_compile.h" #include "zend_hash.h" #include "zend_extensions.h" #if ZEND_MODULE_API_NO > 20050922 #define ZEND_ENGINE_2_2 #endif #if ZEND_MODULE_API_NO > 20050921 #define ZEND_ENGINE_2_1 #endif #ifdef ZEND_ENGINE_2_1 #include "zend_vm.h" #endif #ifndef ZEND_VM_KIND_CALL /* Not currently defined by any ZE version */ # define ZEND_VM_KIND_CALL 1 #endif #ifndef ZEND_VM_KIND /* Indicates PHP < 5.1 */ # define ZEND_VM_KIND ZEND_VM_KIND_CALL #endif #if !defined(ZEND_ENGINE_2_1) #error "Zend Engine2 (php 5.1 or greater) is required to use this extension" #endif #if (ZEND_VM_KIND != ZEND_VM_KIND_CALL) #error "Features only available to Call dispatch VM cores (should be default)" #endif void inclued_zend_init(TSRMLS_D); #endif /* PHP_INCLUED_ZEND_H */
« previous php.pecl.cvs (#9583) next »