Hi I'm trying to write the php processing part of a small httpd. I want to use the SAPI Embed for interpreting php scripts. But I can't find a way to specify the content of variables like $_COOKIE, $_REQUEST, $_SERVER etc.
Is there any function to initalize the SAPI header with all this stuff? That's what my little programm looks like at the moment: <cpp> #include <php_embed.h> #include <iostream> #include <string> using namespace std; string output = ""; int store_string (const char *str, unsigned int str_length TSRMLS_DC) { if(strlen > 0) output += str; return SUCCESS; } int main(int argc, char* argv[]) { // pass output of script to store_string() instead of printing it to stdout php_embed_module.ub_write = store_string; PHP_EMBED_START_BLOCK(argc, argv) // php_request_startup(TSRMLS_C); sapi_header_struct *h; zend_llist_position pos; zval retval; // return value // execute script zend_eval_string("include 'test.php';", &retval, "script" TSRMLS_CC); cout << "\nscript output:\n" << output << endl; // convert retval to long convert_to_long(&retval); cout << "\nretval: " << Z_LVAL(retval) << endl; // free memory zval_dtor(&retval); cout << "\nreading header:" << endl; // get header (SG = SAPI Globals) sapi_headers_struct *sapi_headers = &(SG(sapi_headers)); // read first element (= header line) h = (sapi_header_struct*)zend_llist_get_first_ex(&sapi_headers->headers, &pos); // while existing elements while (h) { // print them cout << h->header << endl; // get next element h = (sapi_header_struct*)zend_llist_get_next_ex(&sapi_headers->headers, &pos); } PHP_EMBED_END_BLOCK() return 0; } </cpp> Before calling zend_eval_string() to interpret the script there has to be some way to pass all the client information like Cookies and stuff to the SAPI, but I can't find a way to do this. Unfortunately there is no documentation at all for this API. Is there anyone who could give me some hints, or a small code snippet? Regards, Alex -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php