From: Matteo Nastasi Date: Mon, 10 Jul 2017 09:53:21 +0000 (+0200) Subject: support for php5.6.30 X-Git-Tag: v0.6.0 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=7b289394d65cf1c4d67c6d714e3a70bf4f9ffb40;p=php-ancillary.git support for php5.6.30 --- diff --git a/README b/README index 6d85e24..e1fb464 100644 --- a/README +++ b/README @@ -5,3 +5,28 @@ $ ./configure $ make $ su # make install-modules + + +How to test it +============== + +configure PHP: +add /etc/php5/cli/conf.d/30-ancillary.ini with content: + +vvvvv +; configuration for php ancillary module +; priority=30 +extension=ancillary.so +^^^^^ + +configure apache2: +----------------- + +In /etc/apache2/sites-enabled edit http default configuration: +ProxyPass /php-ancillary/test001.php fd:///tmp/test001.sock keepalive=Off connectiontimeout=5 timeout=3 + +run test daemon with: +./test001.php + +and browse the web page: +http:///php-ancillary/test001.php diff --git a/php-ancillary.c b/php-ancillary.c index 9ca16fd..b79a92a 100644 --- a/php-ancillary.c +++ b/php-ancillary.c @@ -149,7 +149,13 @@ PHP_FUNCTION(ancillary_getstream); // list of custom PHP functions provided by this extension // set {NULL, NULL, NULL} as the last record to mark the end of list -static function_entry ancillary_getstream[] = { +static +#if ZEND_MODULE_API_NO >= 20131226 + zend_function_entry +#elif ZEND_MODULE_API_NO >= 20010901 + function_entry +#endif + ancillary_getstream[] = { PHP_FE(ancillary_getstream, NULL) {NULL, NULL, NULL} }; @@ -236,6 +242,10 @@ PHP_FUNCTION(ancillary_getstream) } shutdown(fd_out[1], SHUT_RDWR); close(fd_out[1]); + write(1, "HEADERS[", 8); + write(1, headers, curpos); + headers[curpos] = '\0'; + write(1, "]\n", 2); ZVAL_STRING(zheaders, headers, 1); free(headers); @@ -263,7 +273,7 @@ PHP_FUNCTION(ancillary_getstream) if (stream == NULL) { pefree(sock, 0); - return NULL; + return; } php_stream_to_zval(stream, return_value); } diff --git a/test001.php b/test001.php index fd2e1f4..4a829b5 100755 --- a/test001.php +++ b/test001.php @@ -15,17 +15,33 @@ umask($old_umask); $new_socket = stream_socket_accept($list); -$fp = ancillary_getstream($new_socket); +$stream_info = ""; + +$fp = ancillary_getstream($new_socket, $stream_info); printf("FP: %d\n", $fp); +stream_set_blocking ($fp, FALSE); if ($fp == FALSE) printf("ERROR\n"); else printf("GOOD\n"); -fwrite($fp, "DI QUI CI PASSO2"); +$from = fread($fp, 4096); +printf("FROM: [%s]\n", $from); + +$body = "Ancillary Test 001HERE I AM\n"; + +fwrite($fp, "HTTP/1.0 200 OK\r\n"); +fwrite($fp, "Content-type: text/html\r\n"); +fwrite($fp, "X-Savannah: rapatal\r\n"); +// fwrite($fp, sprintf("Content-length: %d\r\n", strlen($body))); +fwrite($fp, "\r\n"); + +fwrite($fp, $body); + fflush($fp); fclose($fp); -?> \ No newline at end of file +print_r($stream_info); +?>