Page 1 of 1

source code: eval()

Posted: Fri Apr 10, 2009 11:41 am
by erinus
Hi,
I wanna add some c code into eval(string) let it can check string's syntax.
But I don't know which file(*.c) has the source code of eval().
Please give me some guidance or direction.
Thanks!

Re: source code: eval()

Posted: Fri Apr 10, 2009 11:45 am
by Benjamin
You can use php_check_syntax() for this:

http://us3.php.net/manual/en/function.p ... syntax.php

Re: source code: eval()

Posted: Fri Apr 10, 2009 11:53 am
by erinus
Thank you, astions.

I wanna do another work in eval(), like certificate, etc..
I know PHP has openssl_private_encrypt, php_check_syntax(), ... functions.
But I must modify the source code of eval().
So, can you tell me which file I need modify?
Thank you for you.

Re: source code: eval()

Posted: Fri Apr 10, 2009 11:54 am
by Benjamin
I'm not sure what file it is in, but I have downloaded the source and it is quite organized. It's most likely in a file called eval.c or close to that at least.

Re: source code: eval()

Posted: Fri Apr 10, 2009 12:08 pm
by erinus
There is no file name like "*eval*".

PHP is a interprete lanaguage, I think eval will be extractd from *.php by php syntax analyzer.
So, I use UltraEdit to find "eval" in all *.c.
But the result is large as mountain. I can't identify which section is used for eval().

Re: source code: eval()

Posted: Fri Apr 10, 2009 12:30 pm
by erinus
I find the eval in source files (php-5.2.9.tar.gz).
I filtered the result and list:
========================================================================
ext/pcre/php_pcre.c (line 854):
static int preg_do_eval(char *eval_str, int eval_str_len, char *subject,
int *offsets, int count, char **result TSRMLS_DC)
{
......
}


main/main.c (line 598):
switch (EG(current_execute_data)->opline->op2.u.constant.value.lval)
{
case ZEND_EVAL:
function = "eval";
is_function = 1;
break;
......
}


Zend/zend_builtin_functions.c (line 1828):
switch (Z_LVAL(ptr->opline->op2.u.constant))
{
case ZEND_EVAL:
function_name = "eval";
build_filename_arg = 0;
break;
......
}


Zend/zend_vm_def.c (line 2896):
case ZEND_EVAL:
{
char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
new_op_array = zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
efree(eval_desc);
}
break;


Zend/zend_vm_execute.c (line 2060):
case ZEND_EVAL:
{
char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC);
new_op_array = zend_compile_string(inc_filename, eval_desc TSRMLS_CC);
efree(eval_desc);
}
break;
========================================================================

And, are these files right?

Re: source code: eval()

Posted: Fri Apr 10, 2009 12:54 pm
by erinus
Well...

I found it.

ext/pcre/php_pcre.c

before line 921.

Thanks everybody.