2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2004-02-27 11:01:35 +00:00
|
|
|
<!-- $Revision: 1.14 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<reference id="ref.zlib">
|
2002-10-10 05:01:31 +00:00
|
|
|
<title>Zlib Compression Functions</title>
|
2002-04-15 00:12:54 +00:00
|
|
|
<titleabbrev>Zlib</titleabbrev>
|
2002-07-20 12:09:59 +00:00
|
|
|
|
2002-04-15 00:12:54 +00:00
|
|
|
<partintro>
|
2002-07-20 12:09:59 +00:00
|
|
|
<section id="zlib.intro">
|
|
|
|
&reftitle.intro;
|
|
|
|
<para>
|
2002-10-10 05:01:31 +00:00
|
|
|
This module enables you to transparently read and write
|
|
|
|
gzip (.gz) compressed files, through 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).
|
2002-07-20 12:09:59 +00:00
|
|
|
</para>
|
|
|
|
<note>
|
|
|
|
<para>
|
2002-10-10 05:01:31 +00:00
|
|
|
Version 4.0.4 introduced 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
|
2002-07-20 12:09:59 +00:00
|
|
|
<function>fopen</function>.
|
|
|
|
</para>
|
|
|
|
<para>
|
2002-10-10 05:01:31 +00:00
|
|
|
In version 4.3.0, this special prefix has been changed to 'zlib://'
|
|
|
|
to prevent ambiguities with filenames containing ':'.
|
2002-07-20 12:09:59 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2002-10-10 05:01:31 +00:00
|
|
|
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.
|
2002-07-20 12:09:59 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="zlib.requirements">
|
|
|
|
&reftitle.required;
|
|
|
|
<para>
|
2002-10-10 05:01:31 +00:00
|
|
|
This module uses the functions of <ulink url="&url.zlib;">zlib</ulink>
|
|
|
|
by Jean-loup Gailly and Mark Adler. You have to use a zlib
|
|
|
|
version >= 1.0.9 with this module.
|
2002-07-20 12:09:59 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
2002-12-02 12:55:46 +00:00
|
|
|
&reference.zlib.configure;
|
|
|
|
|
2002-09-16 20:46:37 +00:00
|
|
|
&reference.zlib.ini;
|
2002-07-20 12:26:06 +00:00
|
|
|
|
|
|
|
<section id="zlib.resources">
|
|
|
|
&reftitle.resources;
|
|
|
|
&no.resource;
|
|
|
|
</section>
|
|
|
|
|
2002-07-20 12:09:59 +00:00
|
|
|
&reference.zlib.constants;
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2002-07-20 12:09:59 +00:00
|
|
|
<section id="zlib.examples">
|
|
|
|
&reftitle.examples;
|
2002-04-15 00:12:54 +00:00
|
|
|
<para>
|
2002-10-10 05:01:31 +00:00
|
|
|
This example opens a temporary file and writes a test string
|
|
|
|
to it, then it prints out the content of this file twice.
|
2002-04-15 00:12:54 +00:00
|
|
|
</para>
|
|
|
|
<example>
|
2002-10-10 05:01:31 +00:00
|
|
|
<title>Small Zlib Example</title>
|
2002-04-15 00:12:54 +00:00
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
2004-02-27 11:01:35 +00:00
|
|
|
$filename = tempnam('/tmp', 'zlibtest') . '.gz';
|
2003-12-15 16:55:22 +00:00
|
|
|
echo "<html>\n<head></head>\n<body>\n<pre>\n";
|
2002-10-10 05:01:31 +00:00
|
|
|
$s = "Only a test, test, test, test, test, test, test, test!\n";
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2002-10-10 05:01:31 +00:00
|
|
|
// open file for writing with maximum compression
|
2002-04-15 00:12:54 +00:00
|
|
|
$zp = gzopen($filename, "w9");
|
|
|
|
|
2002-10-10 05:01:31 +00:00
|
|
|
// write string to file
|
2002-04-15 00:12:54 +00:00
|
|
|
gzwrite($zp, $s);
|
|
|
|
|
2002-10-10 05:01:31 +00:00
|
|
|
// close file
|
2002-04-15 00:12:54 +00:00
|
|
|
gzclose($zp);
|
|
|
|
|
2002-10-10 05:01:31 +00:00
|
|
|
// open file for reading
|
2002-04-15 00:12:54 +00:00
|
|
|
$zp = gzopen($filename, "r");
|
|
|
|
|
2002-10-10 05:01:31 +00:00
|
|
|
// read 3 char
|
2003-12-15 16:55:22 +00:00
|
|
|
echo gzread($zp, 3);
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2002-10-10 05:01:31 +00:00
|
|
|
// output until end of the file and close it.
|
2002-04-15 00:12:54 +00:00
|
|
|
gzpassthru($zp);
|
2003-11-24 23:37:49 +00:00
|
|
|
gzclose($zp);
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2003-12-15 16:55:22 +00:00
|
|
|
echo "\n";
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2002-10-10 05:01:31 +00:00
|
|
|
// open file and print content (the 2nd time).
|
2002-04-15 00:12:54 +00:00
|
|
|
if (readgzfile($filename) != strlen($s)) {
|
2002-10-10 05:01:31 +00:00
|
|
|
echo "Error with zlib functions!";
|
2002-04-15 00:12:54 +00:00
|
|
|
}
|
|
|
|
unlink($filename);
|
2004-02-27 11:01:35 +00:00
|
|
|
echo "</pre>\n</body>\n</html>\n";
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</section>
|
|
|
|
</partintro>
|
|
|
|
|
|
|
|
&reference.zlib.functions;
|
|
|
|
|
|
|
|
</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
|
|
|
|
-->
|
|
|
|
|