#include <direct.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include "php_embed2.h" #define F_IN "test.php" long pe_write( const char * str, unsigned long len, void * data ) { return fwrite( str, sizeof(char), len, stdout ); } long pe_write_header( const char * str, int dup, void * data ) { /* default */ if( str==NULL ) return printf("\n"); return printf("%s\n", str); } const char * pe_read_cookies( void * data ) { return "foo_cookie=bar;foo_cookie2=bar"; } int main( int argc, char ** argv ) { char buffer[_MAX_PATH]= ""; char *dummy_argv[]= { "first_args", "second_arg", "third_arg" }; long exit_status; char * result; PHP_EMBED2_START_BLOCK( 0, NULL ); php_embed2_exec( F_IN, &exit_status ); PHP_EMBED2_END_BLOCK(); return 0; /* // Banner printf( "%s\n", php_embed2_version(-1) ); php_embed2_global_startup(PHP_EMBED2_CLI_MODE, NULL, 0); /* K * / php_embed2_global_set_write_cb(pe_write, 1); php_embed2_global_set_write_header_cb(pe_write_header, 1); php_embed2_global_set_read_post_cb(NULL); php_embed2_global_set_read_cookies_cb(pe_read_cookies); php_embed2_main("", 0, NULL, NULL); printf( "\nExit status=%d\n\n", php_embed2_get_exit_status() ); return 1; */ //php_embed2_global_set_ini("variables_order", "gpc"); // K //php_embed2_global_set_ini("register_globals", "off"); //php_embed2_global_load_extension(""); //php_embed2_global_define("HAVE_BLA", NULL); // K //php_embed2_global_define("BLA_VAL", "What's up ?"); // K //php_embed2_global_set_ini("include_path", "."); // K /* Normal Startup * / php_embed2_startup(F_IN, 3, dummy_argv, NULL); // Argv: K; Data: ??; Header: NO // php_embed2_set_ini("include_path", getcwd(buffer, _MAX_PATH)); // php_embed2_define_var("my_server_var", "value"); // php_embed2_set_var("$my_global_var", "value", 0); // Doesn't work //php_embed2_eval("echo \"Evaled hello !\\n\";", &exit_status); //php_embed2_exec_string("<? echo \"exec_string hello !\\n\"; ?>", &exit_status); //php_embed2_exec(F_IN, &exit_status); //php_embed2_eval("phpinfo();", &exit_status); //php_embed2_eval("echo GlobalVar= $my_global_var;", &exit_status); //php_embed2_eval( "phpinfo();", NULL ); // php_embed2_exec(F_IN, &exit_status); printf( "TEST: Exit status=%d\n", php_embed2_get_exit_status() ); result= php_embed2_get_var("$a_var", NULL); // K printf( "TEST: Result: %s\n\n", result ); php_embed2_shutdown(); /**/ /* WS Startup */ php_embed2_handle_request(F_IN, "GET", "/file.php", "yop=yip&youp=yep", NULL, NULL); printf( "TEST: HTTP response=%d\n\n", php_embed2_get_http_response() ); /* Special * / php_embed2_startup(0, NULL, NULL); php_embed2_write("DIRECT: Hello World\n\n", 22); php_embed2_putc('\t'); php_embed2_puts("DIRECT: Hello World\n\n"); php_embed2_syntax_check(F_IN); php_embed2_syntax_highlight(F_IN); php_embed2_syntax_strip(F_IN); php_embed2_shutdown(); /* Shutdown */ php_embed2_global_shutdown(); }