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
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.17 $ -->
<reference id="ref.zlib">
<title>zlib圧縮関数</title>
<titleabbrev>Zlib</titleabbrev>
<partintro>
<para>
このモジュールは、Jean-loup Gailly および Mark Adler による
透過的に gzip (.gz) で圧縮されたファイルを読み書きするための
<ulink url="&url.zlib;">zlib</ulink> の関数を使用します。
このモジュールを使用するには、zlib バージョン 1.0.9 以上を
使用する必要があります。
</para>
<para>
このモジュールは、gzip で圧縮されたファイルで動作する版の多くの
<link linkend="ref.filesystem">filesystem</link> 関数を含んでいます。
(非圧縮のファイルも使用可能ですが、ソケットは使用できません)
</para>
<note>
<para>
バージョン4.0.4-devで.gzファイルに対応したfopen-wrapperを導入しました。
これにより<function>fopen</function>に'zlib:'をプレフィクスとした
ファイル名又はパス名を渡すことで、通常のf*()関数で圧縮されたファイルに
透過的にアクセスすることが出来ます。
</para>
<para>
この機能を利用するには<literal>fopencookie()</literal>関数を提供する
Cのランタイムライブラリが必要です。現在私の知る限りでは、GNU libcが
この機能を提供する唯一のライブラリです。
</para>
</note>
<sect1 id="zlib-example">
<title>簡単なコードの例</title>
<para>
テンポラリファイルをオープンし、テスト用文字列を書きこみ、
続いて、このファイルの内容を2回出力します。
</para>
<example>
<title>簡単な Zlib の例</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";
// 最大限の圧縮を指定して書きこみ用にファイルをオープン
$zp = gzopen ($filename, "w9");
// 文字列をファイルに書きこむ
gzwrite ($zp, $s);
// ファイルを閉じる
gzclose ($zp);
// 読みこみ用にファイルをオープン
$zp = gzopen ($filename, "r");
// 3文字読みこむ
print gzread ($zp, 3);
// ファイルの終端まで読み、閉じる
gzpassthru ($zp);
print "\n";
// ファイルをオープンし、内容を出力する (2回目)。
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>開かれたgzファイルへのポインタを閉じる</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>int</type><methodname>gzclose</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
ポインタzpが指すgzファイルを閉じます。
</para>
<para>
成功した場合に&true;、失敗した場合に&false;を返します。
</para>
<para>
gzファイルポインタは、有効なファイルポインタであり、かつ、
<function>gzopen</function>
によりオープンできたファイルを指している必要があります。
</para>
</refsect1>
</refentry>
<refentry id="function.gzeof">
<refnamediv>
<refname>gzeof</refname>
<refpurpose>gz ファイルポインタにおいてファイル終端を調べる</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>int</type><methodname>gzeof</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
gzファイルポインタがEOFを指す時またはエラーが生じた場合に&true;、
その他の場合に&false;を返します。
</para>
<para>
gzファイルポインタは、有効なファイルポインタであり、かつ、
<function>gzopen</function>によりオープンできたファイルを指している
必要があります。
</para>
</refsect1>
</refentry>
<refentry id="function.gzfile">
<refnamediv>
<refname>gzfile</refname>
<refpurpose>gzファイル全体を配列に読み込む</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>array</type><methodname>gzfile</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>use_include_path</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
<function>gzfile</function> は、ファイルを配列にして返すこと以外は
<function>readgzfile</function> と同じです。
</para>
<para>
オプションの2番目のパラメータを"1"にすることにより、
<link linkend="ini.include-path">include_path</link> にあるファイルも
検索することができます。
</para>
<para>
<function>readgzfile</function>および
<function>gzopen</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzgetc">
<refnamediv>
<refname>gzgetc</refname>
<refpurpose>gz ファイルへのポインタから文字を得る</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>string</type><methodname>gzgetc</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
zpが指すファイルの中から (非圧縮の)1文字を読み込み、これを含む
文字列を返します。
(<function>gzeof</function>と同様に)EOFの場合に&false;を返します。
</para>
<para>
gzファイルポインタは、有効なファイルポインタであり、かつ、
<function>gzopen</function>
によりオープンできたファイルを指している必要があります。
</para>
<para>
<function>gzopen</function>および
<function>gzgets</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzgets">
<refnamediv>
<refname>gzgets</refname>
<refpurpose>ファイルポインタから 1 行を得る</refpurpose>
</refnamediv>
<refsect1>
<title>説明</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>
fpが指すファイルから最大length-1バイトの文字を読み込み、
これを含む (非圧縮の)文字列を返します。
length-1バイトを読み込むか、改行または EOF になった場合、
(どれかが最初にきた時点で) 読み込みを終了します。
</para>
<para>
エラーが発生した場合、&false;を返します。
</para>
<para>
ファイルポインタは、有効なファイルポインタであり、かつ、
<function>gzopen</function>
によりオープンできたファイルを指している必要があります。
</para>
<para>
<function>gzopen</function>,
<function>gzgetc</function>, <function>fgets</function>
も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzgetss">
<refnamediv>
<refname>gzgetss</refname>
<refpurpose>
gzファイルへのポインタから1行を得て、HTMLタグを取り除く
</refpurpose>
</refnamediv>
<refsect1>
<title>説明</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><type>string</type><parameter>
<replaceable><optional>allowable_tags</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
<function>gzgetss</function>は読み込んだテキストからHTMLおよびPHPタグを全て
取り除こうとすることを除いて、<function>gzgets</function>と同じです。
</para>
<para>
オプションの3番目のパラメータにより、取り除かないタグを指定することが
できます。
</para>
<note>
<para>
<parameter>allowable_tags</parameter> は PHP 3.0.13, PHP4B3
で追加されました。
</para>
</note>
<para>
<function>gzgets</function>,
<function>gzopen</function>, <function>strip_tags</function>
も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzopen">
<refnamediv>
<refname>gzopen</refname>
<refpurpose>gz ファイルを開く</refpurpose>
</refnamediv>
<refsect1>
<title>説明</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>
読み込みまたは書き込み用にgzip(.gz)ファイルをオープンします。
パラメータmodeは、
<function>fopen</function>と同じ("rb" または "wb")ですが、
圧縮レベル("wb9")または圧縮の方策、つまり、"wb6f"のようにフィルターを
通したデータを'f'で指定したり、'h'でハフマン圧縮のみを行うことを
指定したりすることができます。
(方策に関するパラメータの詳細については、zlib.h の中の deflateInit2 の
説明を参照下さい。)
</para>
<para>
gzopen は、gzipフォーマットでないファイルの読み込みについても
使用することができます。
この場合、<function>gzread</function>は、ファイルを解凍せずに直接読み
込まれます。
</para>
<para>
<function>gzopen</function>は、開いたファイルへのファイルポインタを
返します。この後、このファイル記述子から読み込んだデータは全て
透過的に解凍され、書き込んだデータは圧縮されます。
</para>
<para>
開くことに失敗した場合、この関数は&false;を返します。
</para>
<para>
オプションの3番目のパラメータを"1"にすることにより、
<link linkend="ini.include-path">include_path</link>にあるファイルも
検索することができます。
</para>
<para>
<example>
<title><function>gzopen</function>の例</title>
<programlisting role="php">
<![CDATA[
$fp = gzopen ("/tmp/file.gz", "r");
]]>
</programlisting>
</example>
</para>
<para>
<function>gzclose</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzpassthru">
<refnamediv>
<refname>gzpassthru</refname>
<refpurpose>
gzファイルへのポインタから残りのデータ全部を出力する
</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>int</type><methodname>gzpassthru</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
gzファイルポインタについてEOFまでデータを読み込み、
標準出力に(解凍された)結果を書き込みます。
</para>
<para>
エラーが発生した場合、&false;を返します。
</para>
<para>
ファイルポインタは、有効なファイルポインタであり、かつ、
<function>gzopen</function>
によりオープンできたファイルを指している必要があります。
</para>
<para>
gzファイルは、<function>gzpassthru</function>による読込が完了した時点で
閉じられます。(<parameter>zp</parameter>は使用されなくなります)
</para>
</refsect1>
</refentry>
<refentry id="function.gzputs">
<refnamediv>
<refname>gzputs</refname>
<refpurpose>gz ファイルへのポインタに書き込む</refpurpose>
</refnamediv>
<refsect1>
<title>説明</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><type>int</type><parameter>
<replaceable><optional>length</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
<function>gzputs</function>は、<function>gzwrite</function>の別名であり、
完全に同じものです。
</para>
</refsect1>
</refentry>
<refentry id="function.gzread">
<refnamediv>
<refname>gzread</refname>
<refpurpose>バイナリ対応のgzファイル読み込み</refpurpose>
</refnamediv>
<refsect1>
<title>説明</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>は、最大<parameter>length</parameter>
バイトのデータを<parameter>zp</parameter>が指すgzファイルポインタ
から読み込みます。(解凍された)
<parameter>length</parameter>バイトのデータが読み込まれたか、
EOFに達したとき、読み込みは終了します。
</simpara>
<para>
<informalexample>
<programlisting role="php">
<![CDATA[
// gz ファイルの内容を文字列に読み込みます
$filename = "/usr/local/something.txt.gz";
$zd = gzopen ($filename, "r");
$contents = gzread ($zd, 10000);
gzclose ($zd);
]]>
</programlisting>
</informalexample>
</para>
<simpara>
<function>gzwrite</function>、<function>gzopen</function>、
<function>gzgets</function>、 <function>gzgetss</function>、
<function>gzfile</function>、<function>gzpassthru</function>
も参照下さい。
</simpara>
</refsect1>
</refentry>
<refentry id="function.gzrewind">
<refnamediv>
<refname>gzrewind</refname>
<refpurpose>gz ファイルポインタの示す位置を元に戻す</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>int</type><methodname>gzrewind</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
zpが指すファイルのファイル位置記述子をファイルストリームの最初に
セットします。
</para>
<para>
エラーが生じた場合、0を返します。
</para>
<para>
ファイルポインタは有効なファイルポインタであり、かつ、
<function>gzopen</function>によりオープンできたファイルを指している
必要があります。
</para>
<para>
<function>gzseek</function>および<function>gztell</function>
も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzseek">
<refnamediv>
<refname>gzseek</refname>
<refpurpose>gz ファイルポインタの位置を移動する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</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>
zpが指すファイルのファイル位置記述子をファイルストリームにおいて
offset バイトにセットします。<literal>gzseek( zp, offset,
SEEK_SET )</literal> を(C 言語において)コールするのと同じです。
</para>
<para>
ファイルが読み込み用にオープンされた場合、この関数は、エミュレー
ションされますが、極端に遅くなる可能性があります。
ファイルを書き込み用にオープンした場合、前方への移動のみがサポー
トされます。この場合、gzseek は、新しい開始位置までゼロの並びのデー
タを圧縮します。
</para>
<para>
成功した場合、0を返します。それ以外の場合は、-1を返します。
移動がEOFを超える場合にもエラーは発生しないことに注意してください。
</para>
<para>
<function>gztell</function>および<function>gzrewind</function>
も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gztell">
<refnamediv>
<refname>gztell</refname>
<refpurpose>gzファイルポインタの読み込み/書き込み位置を返します</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>int</type><methodname>gztell</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
zpが指すファイルポインタの位置、つまり、
ファイルストリームにおけるオフセット値を返します。
</para>
<para>
エラーが発生した場合、&false;を返します。
</para>
<para>
ファイルポインタは、有効なファイルポインタであり、かつ、
<function>gzopen</function>
によりオープンできたファイルを指している必要があります。
</para>
<para>
<function>gzopen</function> 、
<function>gzseek</function>および<function>gzrewind</function>
も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzwrite">
<refnamediv>
<refname>gzwrite</refname>
<refpurpose>バイナリ対応のgzファイル書き込み</refpurpose>
</refnamediv>
<refsect1>
<title>説明</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><type>int</type><parameter>
<replaceable><optional>length</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<simpara>
<function>gzwrite</function>は
<parameter>string</parameter>の中身をzpが指す
gzファイルストリームに書き込みます。
引数<parameter>length</parameter>が指定され場合、(解凍された)
<parameter>length</parameter>バイトのデータが書き込まれたか、
<parameter>string</parameter>の終わりに達した時に
書き込みは終了します。
</simpara>
<simpara>
引数<parameter>length</parameter>が指定された場合、
<link linkend="ini.magic-quotes-runtime">magic_quotes_runtime</link>
設定オプションは無視されて <parameter>string</parameter> から
スラッシュが取り除かれなくなることに注意してください。
</simpara>
<simpara>
<function>gzread</function>、<function>gzopen</function>、
および <function>gzputs</function> も参照下さい。
</simpara>
</refsect1>
</refentry>
<refentry id="function.readgzfile">
<refnamediv>
<refname>readgzfile</refname>
<refpurpose>gz ファイルを出力する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>int</type><methodname>readgzfile</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>use_include_path</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
ファイルを読み込み、解凍し、標準出力に書き込みます。
</para>
<para>
<function>readgzfile</function>は、gzipフォーマットでないファイル
の読込にも使用可能です。この場合、<function>readgzfile</function>
はファイルを解凍せずに直接読込みます。
</para>
<para>
ファイルから読み込んだ(解凍された)データのバイト数を返します。エラーが
発生した場合、&false;が返され、@readgzfileとしてコールされている場
合を除き、エラーメッセージが出力されます。
</para>
<para>
ファイル<parameter>filename</parameter>は、ファイルシステムから
オープンされ、その内容が標準出力に書き込まれます。
</para>
<para>
<link linkend="ini.include-path">include_path</link>にあるファイル
を検索したい場合には、オプションの2番目のパラメータを使用して
これを設定することが可能です。
</para>
<para>
<function>gzpassthru</function>、
<function>gzfile</function>および<function>gzopen</function>
も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzcompress">
<refnamediv>
<refname>gzcompress</refname>
<refpurpose>文字列をdeflate圧縮する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>string</type><methodname>gzcompress</methodname>
<methodparam><type>string</type><parameter>data</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>level</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
この関数は、入力<parameter>data</parameter>をZLIBデータフォーマッ
トを持いてcompress圧縮されたものを返し、エラーの場合に&false;を返し
ます。オプションのパラメータ<parameter>level</parameter>には、0で
圧縮無し、9で最大限の圧縮を指定できます。
</para>
<note>
<para>
これは、いくつかのヘッダデータを有する gzip 圧縮と同じではありま
せん。gzip圧縮については、<function>gzencode</function>を参照下
さい。
</para>
</note>
<para>
<function>gzuncompress</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzuncompress">
<refnamediv>
<refname>gzuncompress</refname>
<refpurpose>deflate圧縮された文字列を解凍する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</title>
<methodsynopsis>
<type>string</type><methodname>gzuncompress</methodname>
<methodparam><type>string</type><parameter>data</parameter></methodparam>
<methodparam><type>int</type><parameter>
<replaceable><optional>length</optional></replaceable>
</parameter></methodparam>
</methodsynopsis>
<para>
この関数は、<function>gzcompress</function>で圧縮されたデータ
<parameter>data</parameter>を引数とし解凍された元のデータを返します。
エラーの場合に&false;を返します。
この関数は、解凍したデータが圧縮された入力の長さの256倍または
オプションのパラメータ<parameter>length</parameter>を越える場合に
場合にエラーを返します。
</para>
<para>
<function>gzcompress</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzdeflate">
<refnamediv>
<refname>gzdeflate</refname>
<refpurpose>文字列を deflate 圧縮する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</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>
この関数は、入力 <parameter>data</parameter> をDEFLATEデータフォー
マットを用いて圧縮したものを返します。エラーの場合には&false;を返し
ます。オプションのパラメータ<parameter>level</parameter>には、圧
縮しない場合に0、最大限の圧縮をする場合に9を指定可能です。
</para>
<para>
DEFLATE圧縮アルゴリズムの詳細については、ドキュメント
"<ulink url="&url.rfc1951;">DEFLATE Compressed Data Format
Specification version 1.3</ulink>" (RFC 1951)を参照下さい。
</para>
<para>
<function>gzinflate</function>,
<function>gzcompress</function>,
<function>gzuncompress</function>,
<function>gzencode</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzinflate">
<refnamediv>
<refname>gzinflate</refname>
<refpurpose>deflate圧縮された文字列を解凍する</refpurpose>
</refnamediv>
<refsect1>
<title>説明</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>
この関数は、<function>gzdeflate</function>により圧縮された
<parameter>data</parameter> を引数とし、圧縮前の元のデータを返し
ます。エラーの場合には&false;を返します。この関数は、解凍されたデー
タが圧縮された入力 <parameter>data</parameter> の長さの256倍、ま
たはオプションのパラメータ<parameter>length</parameter>以上の長さ
である場合にエラーを返します。
</para>
<para>
<function>gzcompress</function>.
<function>gzuncompress</function>,
<function>gzdeflate</function>,
<function>gzencode</function>も参照下さい。
</para>
</refsect1>
</refentry>
<refentry id="function.gzencode">
<refnamediv>
<refname>gzencode</refname>
<refpurpose>gzip 圧縮された文字列を作成</refpurpose>
</refnamediv>
<refsect1>
<title>説明</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>
この関数は、入力 <parameter>data</parameter>を
<command>gzip</command> プログラムの出力と互換性のある形式で圧縮
して返します。エラーが発生した場合は、&false;を返します。オプション
のパラメータ<parameter>level</parameter> には、圧縮をしない場合に
0、最大限の圧縮を行う場合に9を指定可能です。指定されない場合のデ
フォルト圧縮レベルは1になります。
</para>
<para>
返されるデータには、標準的な.gzファイルとするために適当なヘッダと
データ構造が含まれます。例を以下に示します。
<example>
<title>gzipファイルを作成する</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>
GZIPファイルフォーマットに関する詳細な情報については、次のドキュ
メントを参照下さい。
<ulink url="&url.rfc1952;">GZIP file format specification
version 4.3</ulink> (RFC 1952)
</para>
<para>
<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:
-->
|