File: zlib.xml

package info (click to toggle)
phpdoc 20020310-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 35,272 kB
  • ctags: 354
  • sloc: xml: 799,767; php: 1,395; cpp: 500; makefile: 200; sh: 140; awk: 51
file content (782 lines) | stat: -rw-r--r-- 25,996 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.23 $ -->
 <reference id="ref.zlib">
  <title>Zlib Compression Functions</title>
  <titleabbrev>Zlib</titleabbrev>
  <partintro>
  <para>
   This module uses the functions of <ulink
   url="&url.zlib;">zlib</ulink> by Jean-loup Gailly and Mark Adler to
   transparently read and write gzip (.gz) compressed files. You have
   to use a zlib version >= 1.0.9 with this module.
  </para>
  <para>
   This module contains versions of most of the <link
   linkend="ref.filesystem">filesystem</link> functions which work
   with gzip-compressed files (and uncompressed files, too, but not
   with sockets).
  </para>
  <note>
   <para>
    The current CVS version 4.0.4-dev introduces a fopen-wrapper
    for .gz-files, so that you can use a special 'zlib:' URL to
    access compressed files transparently using the normal 
    f*() file access functions if you prepend the filename or path
    with a 'zlib:' prefix when calling <function>fopen</function>.
   </para>
   <para>
    This feature requires a C runtime library that provides the
    <literal>fopencookie()</literal> function. To my current
    knowledge the GNU libc is the only library that provides
    this feature.
   </para>
  </note>

   <sect1 id="zlib-example">
    <title>Small code example</title>
    <para>
     Opens a temporary file and writes a test string to it, then it
     prints out the content of this file twice.
    </para>
    <example>
     <title>Small Zlib Example</title>
     <programlisting role="php">
<![CDATA[
<?php

$filename = tempnam ('/tmp', 'zlibtest').'.gz';
print "<html>\n<head></head>\n<body>\n<pre>\n";
$s = "Only a test, test, test, test, test, test, test, test!\n";

// open file for writing with maximum compression
$zp = gzopen($filename, "w9");

// write string to file
gzwrite($zp, $s);

// close file
gzclose($zp);

// open file for reading
$zp = gzopen($filename, "r");

// read 3 char
print gzread($zp, 3);

// output until end of the file and close it.
gzpassthru($zp);

print "\n";

// open file and print content (the 2nd time).
if (readgzfile($filename) != strlen($s)) {
        echo "Error with zlib functions!";
}
unlink($filename);
print "</pre>\n</h1></body>\n</html>\n";

?>
]]>
     </programlisting>
    </example>
   </sect1>
  </partintro>

  <refentry id="function.gzclose">
   <refnamediv>
    <refname>gzclose</refname>
    <refpurpose>Close an open gz-file pointer</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>gzclose</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
     </methodsynopsis>
    <para>
     The gz-file pointed to by zp is closed.
    </para>
    <para>
     Returns &true; on success and &false; on failure.
    </para>
    <para>
     The gz-file pointer must be valid, and must point to a file
     successfully opened by <function>gzopen</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzeof">
   <refnamediv>
    <refname>gzeof</refname>
    <refpurpose>Test for end-of-file on a gz-file pointer</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>gzeof</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
     </methodsynopsis>
    <para>
     Returns &true; if the gz-file pointer is at EOF or an error occurs;
     otherwise returns &false;.
    </para>
    <para>
     The gz-file pointer must be valid, and must point to a file
     successfully opened by <function>gzopen</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzfile">
   <refnamediv>
    <refname>gzfile</refname> 
    <refpurpose>Read entire gz-file into an array</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>array</type><methodname>gzfile</methodname>
      <methodparam><type>string</type><parameter>filename</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>use_include_path</parameter></methodparam>
     </methodsynopsis>
    <para> 
     Identical to <function>readgzfile</function>, except that
     <function>gzfile</function> returns the file in an array.
    </para>
    <para>
     You can use the optional second parameter and set it to "1", if
     you want to search for the file in the <link
     linkend="ini.include-path">include_path</link>, too.
    </para>
    <para> 
     See also <function>readgzfile</function>, and
     <function>gzopen</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzgetc">
   <refnamediv>
    <refname>gzgetc</refname>
    <refpurpose>Get character from gz-file pointer</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>gzgetc</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
     </methodsynopsis>
    <para>
     Returns a string containing a single (uncompressed) character
     read from the file pointed to by zp.  Returns &false; on EOF (as
     does <function>gzeof</function>).
    </para>
    <para>
     The gz-file pointer must be valid, and must point to a file
     successfully opened by <function>gzopen</function>.
    </para>
    <para> 
     See also <function>gzopen</function>, and
     <function>gzgets</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzgets">
   <refnamediv>
    <refname>gzgets</refname>
    <refpurpose>Get line from file pointer</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>gzgets</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
      <methodparam><type>int</type><parameter>length</parameter></methodparam>
     </methodsynopsis>
    <para>
     Returns a (uncompressed) string of up to length - 1 bytes read
     from the file pointed to by fp. Reading ends when length - 1
     bytes have been read, on a newline, or on EOF (whichever comes
     first).
    </para>
    <para> 
     If an error occurs, returns &false;.
    </para>
    <para> 
     The file pointer must be valid, and must point to a file
     successfully opened by <function>gzopen</function>.
    </para>
    <para> 
     See also <function>gzopen</function>,
     <function>gzgetc</function>, and <function>fgets</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzgetss">
   <refnamediv>
    <refname>gzgetss</refname>
    <refpurpose>
     Get line from gz-file pointer and strip HTML tags
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>gzgetss</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
      <methodparam><type>int</type><parameter>length</parameter></methodparam>
      <methodparam choice="opt"><type>string</type><parameter>allowable_tags</parameter></methodparam>
     </methodsynopsis>
    <para>
     Identical to <function>gzgets</function>, except that
     <function>gzgetss</function> attempts to strip any HTML and PHP
     tags from the text it reads.
    </para>
    <para>
     You can use the optional third parameter to specify tags which
     should not be stripped.
     <note>
      <para>
       <parameter>Allowable_tags</parameter> was added in PHP 3.0.13,
       PHP4B3.
      </para> 
     </note>
    </para>
    <para>
     See also <function>gzgets</function>,
     <function>gzopen</function>, and <function>strip_tags</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzopen">
   <refnamediv>
    <refname>gzopen</refname>
    <refpurpose>Open gz-file</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>gzopen</methodname>
      <methodparam><type>string</type><parameter>filename</parameter></methodparam>
      <methodparam><type>string</type><parameter>mode</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>use_include_path</parameter></methodparam>
     </methodsynopsis>
    <para>
     Opens a gzip (.gz) file for reading or writing. The mode
     parameter is as in <function>fopen</function> ("rb" or "wb") but
     can also include a compression level ("wb9") or a strategy: 'f'
     for filtered data as in "wb6f", 'h' for Huffman only compression
     as in "wb1h". (See the description of deflateInit2 in zlib.h for
     more information about the strategy parameter.)
    </para>
    <para>
     <function>gzopen</function> can be used to read a file which is
     not in gzip format; in this case <function>gzread</function> will
     directly read from the file without decompression.
    </para>
    <para>
     <function>gzopen</function> returns a file pointer to the file
     opened, after that, everything you read from this file descriptor
     will be transparently decompressed and what you write gets
     compressed.
    </para>
    <para>
     If the open fails, the function returns &false;.
    </para>
    <para>
     You can use the optional third parameter and set it to "1", if
     you want to search for the file in the <link
     linkend="ini.include-path">include_path</link>, too.
    </para>
    <para>
     <example>
      <title><function>gzopen</function> Example</title>
      <programlisting role="php">
<![CDATA[
$fp = gzopen ("/tmp/file.gz", "r");
]]>
      </programlisting>
     </example>
    </para>
    <para>
     See also <function>gzclose</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzpassthru">
   <refnamediv>
    <refname>gzpassthru</refname>
    <refpurpose>
     Output all remaining data on a gz-file pointer
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>gzpassthru</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
     </methodsynopsis>
    <para>
     Reads to EOF on the given gz-file pointer and writes the
     (uncompressed) results to standard output.
    </para>
    <para>
     If an error occurs, returns &false;.
    </para>
    <para>
     The file pointer must be valid, and must point to a file
     successfully opened by <function>gzopen</function>.
    </para>
    <para>
     The gz-file is closed when <function>gzpassthru</function> is
     done reading it (leaving <parameter>zp</parameter> useless).
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzputs">
   <refnamediv>
    <refname>gzputs</refname>
    <refpurpose>Write to a gz-file pointer</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>gzputs</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
      <methodparam><type>string</type><parameter>str</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>gzputs</function> is an alias to
     <function>gzwrite</function>, and is identical in every way.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzread">
   <refnamediv>
    <refname>gzread</refname>
    <refpurpose>Binary-safe gz-file read</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>gzread</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
      <methodparam><type>int</type><parameter>length</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     <function>gzread</function> reads up to
     <parameter>length</parameter> bytes from the gz-file pointer
     referenced by <parameter>zp</parameter>. Reading stops when
     <parameter>length</parameter> (uncompressed) bytes have been read
     or EOF is reached, whichever comes first.
    </simpara>
    <para>
    <informalexample>
      <programlisting role="php">
<![CDATA[
// get contents of a gz-file into a string
$filename = "/usr/local/something.txt.gz";
$zd = gzopen ($filename, "r");
$contents = gzread ($zd, 10000);
gzclose ($zd);
]]>
      </programlisting>
     </informalexample>
    </para>
    <simpara>
     See also <function>gzwrite</function>, <function>gzopen</function>,
     <function>gzgets</function>, <function>gzgetss</function>,
     <function>gzfile</function>, and <function>gzpassthru</function>.
    </simpara>
   </refsect1>
  </refentry>

  <refentry id="function.gzrewind">
   <refnamediv>
    <refname>gzrewind</refname>
    <refpurpose>Rewind the position of a gz-file pointer</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>gzrewind</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
     </methodsynopsis>
    <para>    
     Sets the file position indicator for zp to the beginning of the
     file stream.
    </para> 
    <para> 
     If an error occurs, returns 0.
    </para>
    <para> 
     The file pointer must be valid, and must point to a file
     successfully opened by <function>gzopen</function>.
    </para>
    <para>
     See also <function>gzseek</function> and
     <function>gztell</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzseek">
   <refnamediv>
    <refname>gzseek</refname>
    <refpurpose>Seek on a gz-file pointer</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>gzseek</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
      <methodparam><type>int</type><parameter>offset</parameter></methodparam>
     </methodsynopsis>
    <para>
     Sets the file position indicator for the file referenced by zp to
     offset bytes into the file stream. Equivalent to calling (in C)
     <literal>gzseek( zp, offset, SEEK_SET )</literal>.
    </para>
    <para>
     If the file is opened for reading, this function is emulated but
     can be extremely slow. If the file is opened for writing, only
     forward seeks are supported; gzseek then compresses a sequence of
     zeroes up to the new starting position.
    </para>
    <para>
     Upon success, returns 0; otherwise, returns -1. Note that seeking
     past EOF is not considered an error.
    </para>
    <para>
     See also <function>gztell</function> and
     <function>gzrewind</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gztell">
   <refnamediv>
    <refname>gztell</refname>
    <refpurpose>Tell gz-file pointer read/write position</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>gztell</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
     </methodsynopsis>
    <para>
     Returns the position of the file pointer referenced by
     <parameter>zp</parameter>; i.e., its offset into the file
     stream.
    </para>
    <para>
     If an error occurs, returns &false;.
    </para>
    <para>
     The file pointer must be valid, and must point to a file
     successfully opened by <function>gzopen</function>.
    </para>
    <para> 
     See also <function>gzopen</function>, <function>gzseek</function>
     and <function>gzrewind</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzwrite">
   <refnamediv>
    <refname>gzwrite</refname>
    <refpurpose>Binary-safe gz-file write</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>gzwrite</methodname>
      <methodparam><type>int</type><parameter>zp</parameter></methodparam>
      <methodparam><type>string</type><parameter>string</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     <function>gzwrite</function> writes the contents of
     <parameter>string</parameter> to the gz-file stream pointed to by
     <parameter>zp</parameter>. If the <parameter>length</parameter>
     argument is given, writing will stop after
     <parameter>length</parameter> (uncompressed) bytes have been
     written or the end of <parameter>string</parameter> is reached,
     whichever comes first.
    </simpara>
    <simpara>
     Note that if the <parameter>length</parameter> argument is given,
     then the <link
     linkend="ini.magic-quotes-runtime">magic_quotes_runtime</link>
     configuration option will be ignored and no slashes will be
     stripped from <parameter>string</parameter>.
    </simpara>
    <simpara>
     See also <function>gzread</function>, <function>gzopen</function>,
     and <function>gzputs</function>.
    </simpara>
   </refsect1>
  </refentry>

  <refentry id="function.readgzfile">
   <refnamediv>
    <refname>readgzfile</refname>
    <refpurpose>Output a gz-file</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>readgzfile</methodname>
      <methodparam><type>string</type><parameter>filename</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>use_include_path</parameter></methodparam>
     </methodsynopsis>
    <para> 
     Reads a file, decompresses it and writes it to standard
     output.
    </para>
    <para>
     <function>readgzfile</function> can be used to read a file which
     is not in gzip format; in this case
     <function>readgzfile</function> will directly read from the file
     without decompression.
    </para>
    <para> 
     Returns the number of (uncompressed) bytes read from the file. If
     an error occurs, &false; is returned and unless the function was
     called as <literal>@readgzfile</literal>, an error message is
     printed.
    </para>
    <para> 
     The file <parameter>filename</parameter> will be opened from the
     filesystem and its contents written to standard output.
    </para>
    <para>
     You can use the optional second parameter and set it to "1", if
     you want to search for the file in the <link
     linkend="ini.include-path">include_path</link>, too.
    </para>
    <para>
     See also <function>gzpassthru</function>,
     <function>gzfile</function>, and <function>gzopen</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzcompress">
   <refnamediv>
    <refname>gzcompress</refname>
    <refpurpose>Compress a string</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>gzcompress</methodname>
      <methodparam><type>string</type><parameter>data</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>level</parameter></methodparam>
     </methodsynopsis>
    <para>
     This function returns a compressed version of the input
     <parameter>data</parameter> using the ZLIB data format,
     or &false; if an error is encountered. The optional parameter
     <parameter>level</parameter> can be given as 0 for no
     compression up to 9 for maximum compression.
    </para>
    <para>
     For details on the ZLIB compression algorithm see the document
     "<ulink url="&url.rfc1950;">ZLIB Compressed Data Format
     Specification version 3.3</ulink>" (RFC 1950).
    </para>
    <note>
     <para>
      This is <emphasis>not</emphasis> the same as gzip compression,
      which includes some header data. See <function>gzencode</function>
      for gzip compression.
     </para>
    </note>
    <para>
     See also <function>gzdeflate</function>,
     <function>gzinflate</function>,
     <function>gzuncompress</function>,
     <function>gzencode</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzuncompress">
   <refnamediv>
    <refname>gzuncompress</refname>
    <refpurpose>Uncompress a deflated string</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>gzuncompress</methodname>
      <methodparam><type>string</type><parameter>data</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
     </methodsynopsis>
    <para>   
     This function takes <parameter>data</parameter> compressed by
     <function>gzcompress</function> and returns the original
     uncompressed data or &false; on error.  The function will return an
     error if the uncompressed data is more than 256 times the length
     of the compressed input <parameter>data</parameter> or more than
     the optional parameter <parameter>length</parameter>.
    </para>
    <para>
     See also <function>gzdeflate</function>, 
     <function>gzinflate</function>,
     <function>gzcompress</function>,
     <function>gzencode</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzdeflate">
   <refnamediv>
    <refname>gzdeflate</refname>
    <refpurpose>Deflate a string</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>gzdeflate</methodname>
      <methodparam><type>string</type><parameter>data</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>level</parameter></methodparam>
     </methodsynopsis>
    <para>
     This function returns a compressed version of the input
     <parameter>data</parameter> using the DEFLATE data format,
     or &false; if an error is encountered. The optional parameter
     <parameter>level</parameter> can be given as 0 for no
     compression up to 9 for maximum compression.
    </para>
    <para>
     For details on the DEFLATE compression algorithm see the document
     "<ulink url="&url.rfc1951;">DEFLATE Compressed Data Format
     Specification version 1.3</ulink>" (RFC 1951).
    </para>
    <para>
     See also 
     <function>gzinflate</function>,
     <function>gzcompress</function>,
     <function>gzuncompress</function>,
     <function>gzencode</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzinflate">
   <refnamediv>
    <refname>gzinflate</refname>
    <refpurpose>Inflate a deflated string</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>gzinflate</methodname>
      <methodparam><type>string</type><parameter>data</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
     </methodsynopsis>
    <para>   
     This function takes <parameter>data</parameter> compressed by
     <function>gzdeflate</function> and returns the original
     uncompressed data or &false; on error.  The function will return an
     error if the uncompressed data is more than 256 times the length
     of the compressed input <parameter>data</parameter> or more than
     the optional parameter <parameter>length</parameter>.
    </para>
    <para>
     See also <function>gzcompress</function>.
     <function>gzuncompress</function>,
     <function>gzdeflate</function>,
     <function>gzencode</function>.
    </para>
   </refsect1>
  </refentry>

  <refentry id="function.gzencode">
   <refnamediv>
    <refname>gzencode</refname>
    <refpurpose>Create a gzip compressed string</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>gzencode</methodname>
      <methodparam><type>string</type><parameter>data</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>level</parameter></methodparam>
     </methodsynopsis>
    <para>   
     This function returns a compressed version of the input
     <parameter>data</parameter> compatible with the output of
     the <command>gzip</command> program,
     or &false; if an error is encountered. The optional parameter
     <parameter>level</parameter> can be given as 0 for no
     compression up to 9 for maximum compression, if not given
     the default compression level will be 1.
    </para>
    <para>
     The resulting data contains the appropriate headers and data
     structure to make a standard .gz file, e.g.:
     <example>
      <title>Creating a gzip file</title>
      <programlisting role="php">
<![CDATA[
<?php
    $data = implode("", file("bigfile.txt"));
    $gzdata = gzencode($data, 9);
    $fp = fopen("bigfile.txt.gz", "w");
    fwrite($fp, $gzdata);
    fclose($fp);
?>
]]>
      </programlisting>
     </example>
    </para>
    <para>
     For more information on the GZIP file format, see the document:
     <ulink url="&url.rfc1952;">GZIP file format specification
     version 4.3</ulink> (RFC 1952).
    </para>
    <para>
     See also <function>gzcompress</function>.
     <function>gzuncompress</function>,
     <function>gzdeflate</function>,
     <function>gzinflate</function>.
    </para>
   </refsect1>
  </refentry>

 </reference>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->