? inclued.lo ? inclued_zend.lo Index: config.m4 =================================================================== RCS file: /repository/pecl/inclued/config.m4,v retrieving revision 1.1 diff -u -r1.1 config.m4 --- config.m4 23 Jan 2008 20:05:28 -0000 1.1 +++ config.m4 23 Jan 2008 21:56:24 -0000 @@ -5,46 +5,6 @@ [ --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" Index: inclued.c =================================================================== RCS file: /repository/pecl/inclued/inclued.c,v retrieving revision 1.1 diff -u -r1.1 inclued.c --- inclued.c 23 Jan 2008 20:05:28 -0000 1.1 +++ inclued.c 23 Jan 2008 21:56:24 -0000 @@ -23,24 +23,20 @@ #endif #include "inclued.h" +#include "inclued_zend.h" + +#define INCLUED_VERSION "0.0.1" /* {{{ stupid stringifcation */ #if DEFAULT_SLASH == '/' - #define DEFAULT_SLASH_STRING "/" +# define DEFAULT_SLASH_STRING "/" #elif DEFAULT_SLASH == '\\' - #define DEFAULT_SLASH_STRING "\\" +# define DEFAULT_SLASH_STRING "\\" #else - #error "Unknown value for DEFAULT_SLASH" +# 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) /* }}} */ @@ -65,43 +61,11 @@ /* {{{ 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) + STD_PHP_INI_BOOLEAN("inclued.enabled", "0", PHP_INI_SYSTEM, OnUpdateBool, enabled, zend_inclued_globals, inclued_globals) + STD_PHP_INI_ENTRY("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 @@ -138,30 +102,30 @@ MAKE_STD_ZVAL(class_entry); array_init(class_entry); - add_assoc_stringl(class_entry, "name", ce->name, ce->name_length, 1); + add_assoc_stringl_ex(class_entry, "name", sizeof("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_stringl_ex(class_entry, "mangled_name", sizeof("mangled_name"), key, keylen-1, 1); } - add_assoc_string(class_entry, "filename", ce->filename, 1); - add_assoc_long(class_entry, "line", ce->line_start); + add_assoc_string_ex(class_entry, "filename", sizeof("filename"), ce->filename, 1); + add_assoc_long_ex(class_entry, "line", sizeof("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); + add_assoc_stringl_ex(parent_entry, "name", sizeof("name"), ce->parent->name, ce->parent->name_length, 1); if(ce->parent->type == ZEND_INTERNAL_CLASS) { - add_assoc_bool(parent_entry, "internal", 1); + add_assoc_bool_ex(parent_entry, "internal", sizeof("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_string_ex(parent_entry, "filename", sizeof("filename"), ce->parent->filename, 1); + add_assoc_long_ex(parent_entry, "line", sizeof("line"), ce->parent->line_start); } - add_assoc_zval(class_entry, "parent", parent_entry); + add_assoc_zval_ex(class_entry, "parent", sizeof("parent"), parent_entry); } add_next_index_zval(class_table, class_entry); @@ -187,6 +151,7 @@ MAKE_STD_ZVAL(h); \ *h = *INCLUED_G(h);\ zval_copy_ctor(h); \ + INIT_PZVAL(h); \ }\ while(0) @@ -204,13 +169,14 @@ MAKE_STD_ZVAL(copy_zval);\ *copy_zval = *data[0];\ zval_copy_ctor(copy_zval);\ - add_assoc_zval(request_hash, #name, copy_zval);\ + INIT_PZVAL(copy_zval); \ + add_assoc_zval_ex(request_hash, #name, sizeof(#name), copy_zval);\ }\ } while(0); - PULL_ZVAL(&EG(symbol_table),PHP_SELF); - PULL_ZVAL(&EG(symbol_table),_REQUEST); - PULL_ZVAL(&EG(symbol_table),_COOKIE); + 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) { @@ -224,10 +190,10 @@ 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); + add_assoc_zval_ex(return_value, "request", sizeof("request"), request_hash); + add_assoc_zval_ex(return_value, "includes", sizeof("includes"), includes_hash); + add_assoc_zval_ex(return_value, "inheritance", sizeof("inheritance"), inh_hash); + add_assoc_zval_ex(return_value, "classes", sizeof("classes"), class_table); return; } @@ -253,7 +219,6 @@ * */ PHP_MSHUTDOWN_FUNCTION(inclued) { - if(INCLUED_G(enabled)) { inclued_zend_shutdown(TSRMLS_C); @@ -272,9 +237,7 @@ /* {{{ PHP_RINIT_FUNCTION(inclued) */ PHP_RINIT_FUNCTION(inclued) { - zval **data = NULL; - - if(INCLUED_G(enabled)) { + if(INCLUED_G(enabled)) { /* allocate new info table */ ALLOC_INIT_ZVAL(INCLUED_G(includes_hash)); array_init(INCLUED_G(includes_hash)); @@ -298,7 +261,7 @@ zval retval; zval *pretval = &retval; - if(INCLUED_G(enabled) && INCLUED_G(dumpdir)) { + if(INCLUED_G(enabled) && INCLUED_G(dumpdir) && INCLUED_G(dumpdir)[0] != '\0') { snprintf(path, MAXPATHLEN, "%s" DEFAULT_SLASH_STRING "inclued.%05d.%d", INCLUED_G(dumpdir), getpid(), INCLUED_G(counter)); @@ -306,6 +269,7 @@ if(!(dumpfile = fopen(path, "w"))) { zend_error(E_WARNING, "cannot write to %s" DEFAULT_SLASH_STRING, INCLUED_G(dumpdir)); + return SUCCESS; } pack_output(pretval); @@ -320,14 +284,14 @@ zval_dtor(pretval); } - if(INCLUED_G(enabled)) { + if(INCLUED_G(enabled)) { /* free allocated stuff */ - zval_dtor(INCLUED_G(includes_hash)); + zval_ptr_dtor(&INCLUED_G(includes_hash)); INCLUED_G(includes_hash) = NULL; - zval_dtor(INCLUED_G(inh_hash)); + zval_ptr_dtor(&INCLUED_G(inh_hash)); INCLUED_G(inh_hash) = NULL; - } - return SUCCESS; + } + return SUCCESS; } /* }}} */ @@ -335,14 +299,11 @@ */ 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_row(2, "inclued support", "enabled"); php_info_print_table_end(); + + DISPLAY_INI_ENTRIES(); } /* }}} */ @@ -362,6 +323,32 @@ } /* }}} */ +/* {{{ inclued_functions[] + */ +zend_function_entry inclued_functions[] = { + PHP_FE(inclued_get_data, NULL) + {NULL, NULL, NULL} +}; +/* }}} */ + +/* {{{ 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 + INCLUED_VERSION, +#endif + STANDARD_MODULE_PROPERTIES +}; +/* }}} */ + /* * Local variables: * tab-width: 4 Index: inclued.h =================================================================== RCS file: /repository/pecl/inclued/inclued.h,v retrieving revision 1.1 diff -u -r1.1 inclued.h --- inclued.h 23 Jan 2008 20:05:28 -0000 1.1 +++ inclued.h 23 Jan 2008 21:56:24 -0000 @@ -23,6 +23,7 @@ #include "php.h" #include "php_ini.h" +#include "ext/standard/info.h" #include "zend_globals.h" #include "ext/standard/php_var.h" #include "ext/standard/php_smart_str.h" Index: inclued_zend.c =================================================================== RCS file: /repository/pecl/inclued/inclued_zend.c,v retrieving revision 1.1 diff -u -r1.1 inclued_zend.c --- inclued_zend.c 23 Jan 2008 20:05:28 -0000 1.1 +++ inclued_zend.c 23 Jan 2008 21:56:24 -0000 @@ -23,7 +23,7 @@ #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) +static zval *inclued_get_zval_ptr(znode *node, zval **freeval, zend_execute_data *execute_data TSRMLS_DC) /* {{{ */ { *freeval = NULL; @@ -55,8 +55,9 @@ return NULL; } } +/* }}} */ -static int add_include(ZEND_OPCODE_HANDLER_ARGS) +static void add_include(ZEND_OPCODE_HANDLER_ARGS) /* {{{ */ { zend_op *opline = execute_data->opline; zval * includes_hash = INCLUED_G(includes_hash); @@ -108,14 +109,14 @@ 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); + add_assoc_string_ex(include_entry, "operation", sizeof("operation"), operation, 1); + add_assoc_long_ex(include_entry, "op_type", sizeof("op_type"), op_type); + add_assoc_string_ex(include_entry, "fromfile", sizeof("fromfile"), execute_data->op_array->filename, 1); + add_assoc_long_ex(include_entry, "fromline", sizeof("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_assoc_string_ex(include_entry, "function", sizeof("function"), (char*)execute_data->op_array->function_name, 1); } add_next_index_zval(includes_hash, include_entry); @@ -129,6 +130,7 @@ { tmp_inc_filename = *inc_filename; zval_copy_ctor(&tmp_inc_filename); + INIT_PZVAL(&tmp_inc_filename); convert_to_string(&tmp_inc_filename); inc_filename = &tmp_inc_filename; } @@ -157,32 +159,32 @@ 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); + add_assoc_string_ex(include_entry, "operation", sizeof("operation"), operation, 1); + add_assoc_long_ex(include_entry, "op_type", sizeof("op_type"), op_type); + add_assoc_string_ex(include_entry, "filename", sizeof("filename"), Z_STRVAL_P(inc_filename), 1); + add_assoc_string_ex(include_entry, "opened_path", sizeof("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_bool_ex(include_entry, "duplicate", sizeof("duplicate"), 1); } - add_assoc_string(include_entry, "fromfile", execute_data->op_array->filename, 1); - add_assoc_long(include_entry, "fromline", opline->lineno); + add_assoc_string_ex(include_entry, "fromfile", sizeof("fromfile"), execute_data->op_array->filename, 1); + add_assoc_long_ex(include_entry, "fromline", sizeof("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_assoc_string_ex(include_entry, "function", sizeof("function"), (char*)execute_data->op_array->function_name, 1); } if(opline->op1.op_type != IS_CONST) { - add_assoc_bool(include_entry, "variable_include", 1); + add_assoc_bool_ex(include_entry, "variable_include", sizeof("variable_include"), 1); } if(wrapper != &php_plain_files_wrapper) { - add_assoc_string(include_entry, "streamwrapper", (char*)wrapper->wops->label, 1); + add_assoc_string_ex(include_entry, "streamwrapper", sizeof("streamwrapper"), (char*)wrapper->wops->label, 1); } add_next_index_zval(includes_hash, include_entry); @@ -195,13 +197,15 @@ zval_dtor(&tmp_inc_filename); } } +/* }}} */ -static int inclued_op_ZEND_INCLUDE_OR_EVAL(ZEND_OPCODE_HANDLER_ARGS) +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); \ @@ -215,7 +219,7 @@ } \ }while(0) -static void add_class(ZEND_OPCODE_HANDLER_ARGS) +static void add_class(ZEND_OPCODE_HANDLER_ARGS) /* {{{ */ { zend_op *opline = execute_data->opline; zval *inh_hash = INCLUED_G(inh_hash); @@ -223,8 +227,6 @@ zend_uchar opcode = opline->opcode; zend_class_entry* parent_ce = NULL; - char *operation = NULL; - assert(inh_hash != NULL); MAKE_STD_ZVAL(class_entry); @@ -256,17 +258,19 @@ add_next_index_zval(inh_hash, class_entry); } +/* }}} */ -static int inclued_op_ZEND_DECLARE_CLASS(ZEND_OPCODE_HANDLER_ARGS) +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) +static void add_interface(ZEND_OPCODE_HANDLER_ARGS) /* {{{ */ { zend_op *opline = execute_data->opline; zval *inh_hash = INCLUED_G(inh_hash); @@ -295,15 +299,17 @@ add_next_index_zval(inh_hash, iface_entry); } +/* }}} */ -static int inclued_op_ZEND_ADD_INTERFACE(ZEND_OPCODE_HANDLER_ARGS) +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) +void inclued_zend_init(TSRMLS_D) /* {{{ */ { if(INCLUED_G(enabled)) { @@ -328,8 +334,19 @@ } } } +/* }}} */ -void inclued_zend_shutdown(TSRMLS_D) +void inclued_zend_shutdown(TSRMLS_D) /* {{{ */ { /* nothing */ } +/* }}} */ + +/* + * 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 + */ Index: inclued_zend.h =================================================================== RCS file: /repository/pecl/inclued/inclued_zend.h,v retrieving revision 1.1 diff -u -r1.1 inclued_zend.h --- inclued_zend.h 23 Jan 2008 20:05:28 -0000 1.1 +++ inclued_zend.h 23 Jan 2008 21:56:24 -0000 @@ -55,5 +55,6 @@ #endif void inclued_zend_init(TSRMLS_D); +void inclued_zend_shutdown(TSRMLS_D); #endif /* PHP_INCLUED_ZEND_H */