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.

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
>
>-- 
>PHP Internals - PHP Runtime Development Mailing List
>To unsubscribe, visit: http://www.php.net/unsub.php

Roberto Fichera. 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to