# include <sapi/embed/php_embed.h> |
#ifdef ZTS |
void ***tsrm_ls; |
# endif |
/* Extension bits */ |
zend_module_entry php_mymod_module_entry = { |
STANDARD_MODULE_HEADER, |
"mymod" , /* extension name */ |
NULL, /* function entries */ |
NULL, /* MINIT */ |
NULL, /* MSHUTDOWN */ |
NULL, /* RINIT */ |
NULL, /* RSHUTDOWN */ |
NULL, /* MINFO */ |
"1.0" , /* version */ |
STANDARD_MODULE_PROPERTIES |
}; |
/* Embedded bits */ |
static void startup_php(void) |
{ |
int argc = 1; |
char *argv[2] = { "embed5" , NULL }; |
php_embed_init(argc, argv PTSRMLS_CC); |
zend_startup_module(&php_mymod_module_entry); |
} |
static void execute_php(char *filename) |
{ |
zend_first_try { |
char *include_script; |
spprintf(&include_script, 0, "include '%s'" , filename); |
zend_eval_string(include_script, NULL, filename TSRMLS_CC); |
efree(include_script); |
} zend_end_try(); |
} |
int main(int argc, char *argv[]) |
{ |
if (argc <= 1) { |
printf( "Usage: embed4 scriptfile" ;); |
return -1; |
} |
startup_php(); |
execute_php(argv[1]); |
php_embed_shutdown(TSRMLS_CC); |
return 0; |
} |