At 12.33 05/01/2007, Roberto Fichera wrote: >At 12.18 05/01/2007, Johannes Schlüter wrote: > >>Hi Roberto, >> >>On Fri, 2007-01-05 at 11:33 +0100, Roberto Fichera wrote: >>> Now my problem is how to find declared functions in a context. Which >>hash table >>> I have to use? >> >>Just take a look at the structure behind the executor_globals EG struct: >>http://lxr.php.net/source/ZendEngine2/zend_globals.h#147 to see which >>HashTable might contain the function_table. In that structure you might >>find other useful elements )(maybe you need the class table or constants >>table, too?) ;-) > >Yep! I tried to following code but it seems not working as expected. I >don't know >also if the "data" is declared correctly but the zend_hash_find() >returns FAILURE.
Below there's the script with the correct func_ptr pointer for the zend_hash_find() but indeed still not working for me ;-)! test.php function myFunc() { echo "Hello"; } #include <php_embed.h> int main( int argc, char *argv[] ) { zend_file_handle script; zend_function *func_ptr = NULL; script.type = ZEND_HANDLE_FP; script.filename = ( argc > 1 ? argv[1] : "test.php" ); script.opened_path = NULL; script.free_filename = 0; script.handle.fp = fopen( script.filename, "rb" ); PHP_EMBED_START_BLOCK(argc,argv) zend_execute_scripts( ZEND_REQUIRE TSRMLS_CC, NULL, 1, &script ); if ( zend_hash_find( EG( function_table ), "myFunc", sizeof( "myFunc" ), (void **)&func_ptr) == FAILURE ) { fprintf( stderr, "%s(): Name not found\n", __func__ ); return -1; } if ( func_ptr == NULL ) { fprintf( stderr, "%s(): Value is NULL\n", __func__ ); return -1; } fprintf( stderr, "The function 'myFunc' has been found\n" ); PHP_EMBED_END_BLOCK() return 0; } > >int main( int argc, char *argv[] ) >{ > zend_file_handle script; > zval **data = NULL; > > script.type = ZEND_HANDLE_FP; > script.filename = ( argc > 1 ? argv[1] : "test.php" ); > script.opened_path = NULL; > script.free_filename = 0; > script.handle.fp = fopen( script.filename, "rb" ); > > PHP_EMBED_START_BLOCK(argc,argv) > > zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 1, &script); > > if ( zend_hash_find( EG(function_table), "myFunc", sizeof( >"myFunc" )+1, (void **)&data) == FAILURE ) > { > fprintf( stderr, "%s(): Name not found\n", __func__ ); > return -1; > } > > if ( data == NULL ) > { > fprintf( stderr, "%s(): Value is NULL\n", __func__ ); > return -1; > } > > fprintf( stderr, "The function 'myFunc' has been found\n" ); > > PHP_EMBED_END_BLOCK() > > return 0; >} > > > >> >>johannes Roberto Fichera. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php