fix missing bold for your account item
[brisk.git] / test / stream_filter_test.php
1 #!/usr/bin/php
2 <?php
3 $max = 1024 * 1024 * 2;
4 /* if (($fp = gzopen("php://memory/maxmemory:$max", "wb")) == FALSE) { */
5 /*     printf("Open file failed\n"); */
6 /* } */
7
8 /* printf("Open ok\n"); */
9 /* exit(123); */
10
11
12
13 print_r(stream_get_filters());
14
15 $pipe = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
16
17 for ($i = 0 ; $i < 2 ; $i++)
18     stream_set_blocking  ( $pipe[$i], 0);
19
20 $params = array('level' => 6, 'window' => -15, 'memory' => 9);
21
22 if (($filter = stream_filter_append($pipe[1], "zlib.deflate", STREAM_FILTER_READ)) == FALSE) {
23     printf("filter append fails\n");
24 }
25
26 $cont = array( "pippo", "pluto", "paperino");
27
28 $fwrite_pos = 0;
29 $fread_pos = 0;
30
31 $head = "\037\213\010\000\000\000\000\000\000\003";
32
33 if (($fout = fopen("fout.gz", "wb")) == FALSE) {
34     exit(1);
35 }
36
37 fwrite($fout, $head);
38
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");
44     }
45     if (($s_out = fread($pipe[1], 1024)) != FALSE) { 
46         printf("SUCCESS [%s]\n", $s_out);
47     }
48     fwrite($fout, $s_out);
49
50     fprintf(STDERR, "PRE FLUSH\n");
51     fflush($pipe[0]);
52     if (($s_out = fread($pipe[1], 1024)) != FALSE) { 
53         printf("SUCCESS [%s]\n", $s_out);
54     }
55     fwrite($fout, $s_out);
56
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);
61     }
62     fwrite($fout, $s_out);
63
64     fprintf(STDERR, "POS VOID\n");
65     // else {
66     // printf("fread fails\n");
67     // }
68     fprintf(STDERR, "\n");
69     sleep(5);
70 }
71
72 fclose($pipe[0]);
73 if (($s_out = fread($pipe[1], 1024)) != FALSE) { 
74     printf("SUCCESS [%s]\n", $s_out);
75 }
76 fwrite($fout, $s_out);
77 fclose($pipe[1]);
78 fclose($fout);
79
80 ?>