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
|
<?xml version="1.0" encoding="utf-8"?>
<reference id="ref.zlib">
<title>Zlib Compression Functions</title>
<titleabbrev>Zlib</titleabbrev>
<partintro>
<para>
이 모듈은 Jean-loup Gailly 과 Mark Adler 의 <ulink url="&url.zlib;">zlib</ulink> 사용하며 gzip(.gz)로 압축된 파일을 잘 읽고 쓸수 있다. 이 모듈은 zlib 1.0.9버젼 이상과 사용할 수 있다.
</para>
<para>
이 모듈은 gzip 압축된 파일과 연동하는 대부분의 <link linkend="ref.filesystem">filesystem</link> 함수 버젼을 포함하고 있다. (and uncompressed files, too, but not
with sockets).
</para>
<note>
<para>
현재 CVS 4.0.4-dev 버젼은 .gz-files를 위한 fopen-wrapper를 소개하고 있다. 압축된 파일을
다루는 특별한 'zlib:'URL을 사용할 수 있기 위하여 일반적인 f*() 파일 제어 함수가 사용되며 <function>fopen</function>함수 호출 전에 이미 알고 있는 파일명이나 경로가 'zlib:'와 함께 선행되어야 한다.
</para>
<para>
이 경우 <literal>fopencookie()</literal> 함수를 제공하는 C 런타임 라이브러리가 필요하다. 현재 이것을 제공하는 라이브러리는 GNU libc가 유일하다.
</para>
</note>
<sect1 id="zlib-example">
<title>Small code example</title>
<para>
임시 파일을 열어 테스트 문자를 기록하고, 그 내용을 두번 출력한다 .
</para>
<example>
<title>Small Zlib Example</title>
<programlisting role="php">
<?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>지정된 .gz 파일을 닫는다.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>gzclose</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
zp에의해 지정된 .gz 파일이 닫혀진다.
</para>
<para>
성공시 &true;를 실패시 failure를 반환한다.
</para>
<para>
.gz파일의 지정은 정확해야 하고, <function>gzopen</function>에 의해 성공적으로 열린 파일을 지정해야 한다.
</para>
</refsect1>
</refentry>
<refentry id="function.gzeof">
<refnamediv>
<refname>gzeof</refname>
<refpurpose>지정된 .gz 파일의 끝을 테스트한다.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>gzeof</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
지정된 .gz 파일의 끝이거나 에러가 일어나면 &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>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>
<function>readgzfile</function>와 동일하나, <function>gzfile</function>은 파일을 배열로 반환한다.
</para>
<para>
만일 <link linkend="ini.include-path">include_path</link>안의 파일을 검색하기 원한다면, 두번째 옵션의 파라미터에 "1"을 넣으면 된다.
</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>Description</title>
<methodsynopsis>
<type>string</type><methodname>gzgetc</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
zp에 의해 지정된 파일로부터 문자열에 포함된 단문자(압축되지 않은)를 반환한다. EOF의 경우 &false;를 반환한다(마치 <function>gzeof</function>처럼).
</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>지정된 파일로 부터 라인을 읽어 들인다.</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>
fp에 의해 지정된 파일로부터 length - 1 bytes의 문장을 리턴한다. length - 1 bytes를 읽거나, 새로운 라인을 만나거나, 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 파일로부터 HTML 태그를 제외하고 한 라인을 읽는다,
</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>
<function>gzgets</function>와 동일하나, <function>gzgetss</function>은 읽은 문자에서 HTML과 PHP
태그를 제외한다.
</para>
<para>
세번째 옵션의 파라미터를 사용하여 명시한 태그를 제외하지 않을 수 있다.You can use the optional third parameter to specify tags which
should not be stripped.
<note>
<para>
<parameter>Allowable_tags</parameter>는 PHP 3.0.13,
PHP4B3에 포함되었다.
</para>
</note>
</para>
<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>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>
gzip (.gz)파일을 읽기 또는 쓰기위해 연다. mode 파라미터는 <function>fopen</function> ("rb" or "wb")와 같고, 또한 압축레벨 ("wb9") 또는 stategy를 포함한다: 'f'
for filtered data as in "wb6f", 'h' for Huffman only compression
as in "wb1h". (strategy parameter에 관한 보다 많은 정보를 원한다면 the description of deflateInit2 in zlib.h보라.)
</para>
<para>
<function>gzopen</function>은 gzip 포멧이 아닌 파일을 읽는데 사용될 수 있다.; 이 경우 <function>gzread</function>로 압축해제 없이 바로 파일로 부터 읽을 수 있다.
</para>
<para>
<function>gzopen</function>은 열고자 지정한 파일을 리턴 한다. 그리고는 읽고자 하는 모든것을 압축해제하고, 기록하고 압축할 수 있다.
</para>
<para>
만일 열기에 실패하면 &false;를 리턴한다.
</para>
<para>
세번째 옵션의 파라미터에 "1"을 넣으면 <link linkend="ini.include-path">include_path</link>안의 파일을 검색 할수 있다.
</para>
<para>
<example>
<title>
<function>gzopen</function> Example</title>
<programlisting role="php">
$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>
지정된 파일의 남아있는 모든 데이타를 출력한다.
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>gzpassthru</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
지정된 .gz파일의 EOF을 읽으면 standard output으로 결과(압축되지 않은) 결과를 출력한다.
</para>
<para>
에러가 나면 &false;를 리턴한다.
</para>
<para>
파일의 지정은 정확해야하고, <function>gzopen</function>의해 성공적으로 열린 파일이어야 한다.
</para>
<para>
<function>gzpassthru</function>가 읽는것을 마치면 .gz파일은 닫힌다.(leaving <parameter>zp</parameter>는 불필요하다).
</para>
</refsect1>
</refentry>
<refentry id="function.gzputs">
<refnamediv>
<refname>gzputs</refname>
<refpurpose>지정된 .gz 파일에 기록한다.</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>은 <function>gzwrite</function>와 모든면에서 동일하다.
</para>
</refsect1>
</refentry>
<refentry id="function.gzread">
<refnamediv>
<refname>gzread</refname>
<refpurpose>.gz로부터 바이트값을 읽어들인다</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>은 <parameter>zp</parameter>로부터 참조된 지정된 .gz 파일로부터 <parameter>length</parameter>만큼의 byte값을 읽어들인다. <parameter>length</parameter> (압축되지 않은)만큼의 byte를 읽거나 EOF에 다다르면 읽기를 멈춘다. (처음으로 돌아가는것 포함)
</simpara>
<para>
<informalexample>
<programlisting role="php">
// 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>
참고 <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>Description</title>
<methodsynopsis>
<type>int</type><methodname>gzrewind</methodname>
<methodparam><type>int</type><parameter>zp</parameter></methodparam>
</methodsynopsis>
<para>
zp를 지시자로 파일스트림의 시작위치로 파일 포지션을 둔다.
</para>
<para>
error가 발생하면 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>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>
파일 스트림 내부에서 zp참조로 지정된 파일 포지션을 offset으로 이동한다. C에서 <literal>gzseek( zp, offset, SEEK_SET )</literal>의 호출과 동일하다.
</para>
<para>
만약 파일이 읽기속성으로 열린 경우, 이 함수는 에뮬레이트 될 수 있지만 매우 느릴수도 있다. 만일 쓰기 속성으로 열린경우에는, 오직 순차검색만을 지원한다.
:gzseek는 새 시작위치까지 0의 연속으로 압축한다.(이상해서 원문을 포함합니다.) 원문: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>
성공할 경우 0을 반환하고; 그렇지 않은 경우 -1을 반환한다. EOF를 지나는 검색은 error을 고려하지 않는다.
</para>
<para>
참고 <function>gztell</function>, <function>gzrewind</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.gztell">
<refnamediv>
<refname>gztell</refname>
<refpurpose>지정된 .gz 파일의 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>
<parameter>zp</parameter>에의해 참조된 파일위치의 포인터를 반환한다; 즉, 파일스트림 내부의 offset
</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>지정된 string을 .gz파일 스트림에 기록한다.</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>는 <parameter>zp</parameter>에 의해 지정된 .gz파일스트림에 <parameter>string</parameter>을 기록한다.
만일 <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>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>
파일을 읽고, 압축해제를하고 standard output으로 출력한다.
</para>
<para>
<function>readgzfile</function>은 gzip format이 아니더라도 읽을 수 있다.; 이 경우 <function>readgzfile</function>은 바로 압축해제없이 파일을 읽어들이 수 있다.
</para>
<para>
파일로부터 읽어들인 바이트수(압축되지 않은)를 리턴한다. 만일 에러가 발생하면, -<literal>@readgzfile</literal>라고 불리우는 경우가 아닌한- &false;를 반환하고, 에러메세지를 출력한다.
</para>
<para>
<parameter>filename</parameter>은 파일시스템으로부터 열려지고, 그 내용은 standard output으로 출력된다.
</para>
<para>
<link linkend="ini.include-path">include_path</link>안의 파일을 검색하고자 원한다면, 두번째 옵션의 파라미터를 "1"을 넣으면 된다.
</para>
<para>
참고 <function>gzpassthru</function>,
<function>gzfile</function>, <function>gzopen</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.gzcompress">
<refnamediv>
<refname>gzcompress</refname>
<refpurpose>.gz로 문자를 압축한다.</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>
이 함수는 입력된<parameter>data</parameter>의 gzip압축버젼을 리턴하거나 에러발생시 &false;를 반환한다. 옵션의 파라미터인 <parameter>level</parameter>은 압축률이 0인 0부터 최대압축률인 9까지 주어진다.
</para>
<para>
참고 <function>gzuncompress</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.gzuncompress">
<refnamediv>
<refname>gzuncompress</refname>
<refpurpose>gz로 압축된 문자를 압축해제 한다.</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>
이 함수는 <function>gzcompress</function>로 압축된 <parameter>data</parameter>를 취하여, 압축되지않은 원본데이터를 반환하거나 에러의 경우 &false;를 반환한다. 만일 압축해제된 데이타가 압축되어 입력된 <parameter>data</parameter>보다 256배 이상이거나 옵션의 파라미터의 <parameter>length</parameter>이상인 경우 에러를 반환한다.
</para>
<para>
참고 <function>gzcompress</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:
-->
|