X-Git-Url: https://mop.ddnsfree.com/gitweb/?p=php-ancillary.git;a=blobdiff_plain;f=php-ancillary.c;fp=php-ancillary.c;h=49078127036b2f45a73808f3578eb73f2b3f7302;hp=115221a9dca142774f850dd810793e003d5d571f;hb=14be27b93ea230a1c3dd702ae33e366bb11be728;hpb=d01d2155a49053f403e038b05ff7623d8efd3ea7 diff --git a/php-ancillary.c b/php-ancillary.c index 115221a..4907812 100644 --- a/php-ancillary.c +++ b/php-ancillary.c @@ -3,6 +3,10 @@ #endif #include "php.h" #include + +#include +#include +#include #define PHP_ANCILLARY_VERSION "1.0" #define PHP_ANCILLARY_EXTNAME "ancillary" @@ -45,7 +49,12 @@ PHP_FUNCTION(ancillary_getstream) { zval *zstream; php_stream *stream; - int fd_in, fd_out; + int fd_in, fd_out[2]; + char *headers; + + if ((headers = calloc(8*1024, 1)) == NULL) { + return; + } if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream)) return; @@ -56,11 +65,25 @@ PHP_FUNCTION(ancillary_getstream) RETURN_FALSE; } - if(ancil_recv_fd(fd_in, &fd_out)) { + if(ancil_recv_fds(fd_in, fd_out, 2) == 0) { RETURN_FALSE; } + { + char bf[2048]; + + sprintf(bf, "zero: [%d] uno: [%d]\n", fd_out[0], fd_out[1]); + write(1, bf, strlen(bf)); + } + { + int fh; + + if ((fh = open("/tmp/out_php-anc.txt", O_WRONLY | O_CREAT | O_APPEND)) > -1) { + // write(fh, headers, 8*1024); + close(fh); + } + } - if ((stream = php_stream_fopen_from_fd(fd_out, "r+b", NULL)) == NULL) { + if ((stream = php_stream_fopen_from_fd(fd_out[0], "r+b", NULL)) == NULL) { RETURN_FALSE; }