Try this instead: request_rec *r = (request_rec *)(((SG(server_context) == NULL) ? NULL : ((php_struct*)SG(server_context))->r));
Apache 2.x server_context is not a request_rec, it is a struct with a request rec in it. Brian On Jan 16, 2010, at 7:25 PM, rwe rt wrote: > Hi all,I compiled php-5.3.1 with apache 2.2.14 as DSO and wanted to test how > to call Apache API from a PHP module:Run ./ext_skel --extname=helloModified > ext/hello.c and the function PHP_FUNCTION(confirm_hello_compiled) so that it > contains > > #include "SAPI.h" > #include "httpd.h" > #include "http_config.h" > #include "http_protocol.h" > #include "ap_config.h" > request_rec *hello_r;PHP_FUNCTION(confirm_hello_compiled) { hello_r = > (request_rec *)SG(server_context); ap_rprintf(hello_r, "Hello world\n"); > return SUCCESS; > }Under php root, run ./buildconf and ./configure > --with-apxs=/home/www/bin/apxs --enable-helloIt worked fine. But when I > furhter ran: > > makeI got an error like:....ext/hello/.libs/hello.o: In function > zif_confirm_hello_compiled': /home/www/php-5.3.1/ext/hello/hello.c:167: > undefined reference toap_rprintf'near the end of compiling.As far as I know, > PHP 5 can only be compiled as DSO and don't have access to compiled objects > in Apache 2 directly. How to modify config.m4 or other files so that I can > make compiling successful? Any help would be greatly appreciated!Rwe > > > __________________________________________________________________ > Be smarter than spam. See how smart SpamGuard is at giving junk email the > boot with the All-new Yahoo! Mail. Click on Options in Mail and switch to > New Mail today or register for free at http://mail.yahoo.ca -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php