3 $max = 1024 * 1024 * 2;
4 /* if (($fp = gzopen("php://memory/maxmemory:$max", "wb")) == FALSE) { */
5 /* printf("Open file failed\n"); */
8 /* printf("Open ok\n"); */
13 print_r(stream_get_filters());
15 $pipe = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
17 for ($i = 0 ; $i < 2 ; $i++)
18 stream_set_blocking ( $pipe[$i], 0);
20 $params = array('level' => 6, 'window' => -15, 'memory' => 9);
22 if (($filter = stream_filter_append($pipe[1], "zlib.deflate", STREAM_FILTER_READ)) == FALSE) {
23 printf("filter append fails\n");
26 $cont = array( "pippo", "pluto", "paperino");
31 $head = "\037\213\010\000\000\000\000\000\000\003";
33 if (($fout = fopen("fout.gz", "wb")) == FALSE) {
39 for ($i = 0 ; $i < 9 ; $i++) {
40 fprintf(STDERR, "Start loop\n");
41 $s_in = $cont[$i % 3];
42 if (($ct = fwrite($pipe[0], $s_in)) == FALSE) {
43 printf("fwrite fails\n");
45 if (($s_out = fread($pipe[1], 1024)) != FALSE) {
46 printf("SUCCESS [%s]\n", $s_out);
48 fwrite($fout, $s_out);
50 fprintf(STDERR, "PRE FLUSH\n");
52 if (($s_out = fread($pipe[1], 1024)) != FALSE) {
53 printf("SUCCESS [%s]\n", $s_out);
55 fwrite($fout, $s_out);
57 fprintf(STDERR, "POS FLUSH\n");
58 fwrite($pipe[0], "1");
59 if (($s_out = fread($pipe[1], 1024)) != FALSE) {
60 printf("SUCCESS [%s]\n", $s_out);
62 fwrite($fout, $s_out);
64 fprintf(STDERR, "POS VOID\n");
66 // printf("fread fails\n");
68 fprintf(STDERR, "\n");
73 if (($s_out = fread($pipe[1], 1024)) != FALSE) {
74 printf("SUCCESS [%s]\n", $s_out);
76 fwrite($fout, $s_out);