1.\" $NetBSD: zlib.3,v 1.11 2017/07/03 21:32:51 wiz Exp $ 2.\" $OpenBSD: zlib.3,v 1.1 2003/09/25 09:12:09 jmc Exp $ 3.\" 4.\" Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler 5.\" 6.\" This software is provided 'as-is', without any express or implied 7.\" warranty. In no event will the authors be held liable for any damages 8.\" arising from the use of this software. 9.\" 10.\" Permission is granted to anyone to use this software for any purpose, 11.\" including commercial applications, and to alter it and redistribute it 12.\" freely, subject to the following restrictions: 13.\" 14.\" The origin of this software must not be misrepresented; you must not 15.\" claim that you wrote the original software. If you use this software 16.\" in a product, an acknowledgment in the product documentation would be 17.\" appreciated but is not required. 18.\" Altered source versions must be plainly marked as such, and must not be 19.\" misrepresented as being the original software. 20.\" This notice may not be removed or altered from any source distribution. 21.\" 22.\" Converted to mdoc format for the OpenBSD project 23.\" by Jason McIntyre <jmc@openbsd.org> 24.\" 25.Dd May 1, 2004 26.Dt ZLIB 3 27.Os 28.Sh NAME 29.Nm zlib 30.Nd general purpose compression library 31.Sh SYNOPSIS 32.In zlib.h 33.Ss Basic functions 34.Ft const char * 35.Fn zlibVersion "void" 36.Ft int 37.Fn deflateInit "z_streamp strm" "int level" 38.Ft int 39.Fn deflate "z_streamp strm" "int flush" 40.Ft int 41.Fn deflateEnd "z_streamp strm" 42.Ft int 43.Fn inflateInit "z_streamp strm" 44.Ft int 45.Fn inflate "z_streamp strm" "int flush" 46.Ft int 47.Fn inflateEnd "z_streamp strm" 48.Ss Advanced functions 49.Ft int 50.Fn deflateInit2 "z_streamp strm" "int level" "int method" \ 51"int windowBits" "int memLevel" "int strategy" 52.Ft int 53.Fn deflateSetDictionary "z_streamp strm" "const Bytef *dictionary" \ 54"uInt dictLength" 55.Ft int 56.Fn deflateCopy "z_streamp dest" "z_streamp source" 57.Ft int 58.Fn deflateReset "z_streamp strm" 59.Ft int 60.Fn deflateParams "z_streamp strm" "int level" "int strategy" 61.Ft int 62.Fn inflateInit2 "z_streamp strm" "int windowBits" 63.Ft int 64.Fn inflateSetDictionary "z_streamp strm" "const Bytef *dictionary" "uInt dictLength" 65.Ft int 66.Fn inflateSync "z_streamp strm" 67.Ft int 68.Fn inflateReset "z_streamp strm" 69.Ss Utility functions 70.Fd typedef voidp gzFile ; 71.Pp 72.Ft int 73.Fn compress "Bytef *dest" "uLongf *destLen" "const Bytef *source" "uLong sourceLen" 74.Ft int 75.Fn compress2 "Bytef *dest" "uLongf *destLen" "const Bytef *source" "uLong sourceLen" "int level" 76.Ft int 77.Fn uncompress "Bytef *dest" "uLongf *destLen" "const Bytef *source" "uLong sourceLen" 78.Ft gzFile 79.Fn gzopen "const char *path" "const char *mode" 80.Ft gzFile 81.Fn gzdopen "int fd" "const char *mode" 82.Ft int 83.Fn gzsetparams "gzFile file" "int level" "int strategy" 84.Ft int 85.Fn gzread "gzFile file" "voidp buf" "unsigned len" 86.Ft int 87.Fn gzwrite "gzFile file" "const voidp buf" "unsigned len" 88.Ft int 89.Fn gzprintf "gzFile file" "const char *format" "..." 90.Ft int 91.Fn gzputs "gzFile file" "const char *s" 92.Ft char * 93.Fn gzgets "gzFile file" "char *buf" "int len" 94.Ft int 95.Fn gzputc "gzFile file" "int c" 96.Ft int 97.Fn gzgetc "gzFile file" 98.Ft int 99.Fn gzflush "gzFile file" "int flush" 100.Ft z_off_t 101.Fn gzseek "gzFile file" "z_off_t offset" "int whence" 102.Ft int 103.Fn gzrewind "gzFile file" 104.Ft z_off_t 105.Fn gztell "gzFile file" 106.Ft int 107.Fn gzeof "gzFile file" 108.Ft int 109.Fn gzclose "gzFile file" 110.Ft const char * 111.Fn gzerror "gzFile file" "int *errnum" 112.Ss Checksum functions 113.Ft uLong 114.Fn adler32 "uLong adler" "const Bytef *buf" "uInt len" 115.Ft uLong 116.Fn crc32 "uLong crc" "const Bytef *buf" "uInt len" 117.Sh DESCRIPTION 118This manual page describes the 119.Nm 120general purpose compression library, version 1.1.4. 121.Pp 122The 123.Nm 124compression library provides in-memory compression and decompression functions, 125including integrity checks of the uncompressed data. 126This version of the library supports only one compression method 127.Pq deflation 128but other algorithms will be added later and will have the same 129stream interface. 130.Pp 131Compression can be done in a single step if the buffers are large enough 132.Pq for example if an input file is mmap'ed , 133or can be done by repeated calls of the compression function. 134In the latter case, the application must provide more input 135and/or consume the output 136.Pq providing more output space 137before each call. 138.Pp 139The library also supports reading and writing files in 140.Xr gzip 1 141.Pq .gz 142format with an interface similar to that of 143.Xr stdio 3 . 144.Pp 145The library does not install any signal handler. 146The decoder checks the consistency of the compressed data, 147so the library should never crash even in case of corrupted input. 148.Pp 149The functions within the library are divided into the following sections: 150.Pp 151.Bl -dash -offset indent -compact 152.It 153Basic functions 154.It 155Advanced functions 156.It 157Utility functions 158.It 159Checksum functions 160.El 161.Sh BASIC FUNCTIONS 162.Bl -tag -width Ds 163.It Fa const char * Fn zlibVersion "void" ; 164.Pp 165The application can compare 166.Fn zlibVersion 167and 168.Dv ZLIB_VERSION 169for consistency. 170If the first character differs, the library code actually used is 171not compatible with the 172.In zlib.h 173header file used by the application. 174This check is automatically made by 175.Fn deflateInit 176and 177.Fn inflateInit . 178.It Fa int Fn deflateInit "z_streamp strm" "int level" ; 179.Pp 180The 181.Fn deflateInit 182function initializes the internal stream state for compression. 183The fields 184.Fa zalloc , 185.Fa zfree , 186and 187.Fa opaque 188must be initialized before by the caller. 189If 190.Fa zalloc 191and 192.Fa zfree 193are set to 194.Dv Z_NULL , 195.Fn deflateInit 196updates them to use default allocation functions. 197.Pp 198The compression level must be 199.Dv Z_DEFAULT_COMPRESSION , 200or between 0 and 9: 2011 gives best speed, 9 gives best compression, 0 gives no compression at all 202(the input data is simply copied a block at a time). 203.Pp 204.Dv Z_DEFAULT_COMPRESSION 205requests a default compromise between speed and compression 206.Pq currently equivalent to level 6 . 207.Pp 208.Fn deflateInit 209returns 210.Dv Z_OK 211if successful, 212.Dv Z_MEM_ERROR 213if there was not enough memory, 214.Dv Z_STREAM_ERROR 215if level is not a valid compression level, 216.Dv Z_VERSION_ERROR 217if the 218.Nm 219library version 220.Pq zlib_version 221is incompatible with the version assumed by the caller 222.Pq ZLIB_VERSION . 223.Fa msg 224is set to null if there is no error message. 225.Fn deflateInit 226does not perform any compression: this will be done by 227.Fn deflate . 228.It Fa int Fn deflate "z_streamp strm" "int flush" ; 229.Pp 230.Fn deflate 231compresses as much data as possible, and stops when the input 232buffer becomes empty or the output buffer becomes full. 233It may introduce some output latency 234.Pq reading input without producing any output 235except when forced to flush. 236.Pp 237The detailed semantics are as follows. 238.Fn deflate 239performs one or both of the following actions: 240.Pp 241Compress more input starting at 242.Fa next_in 243and update 244.Fa next_in 245and 246.Fa avail_in 247accordingly. 248If not all input can be processed 249(because there is not enough room in the output buffer), 250.Fa next_in 251and 252.Fa avail_in 253are updated and processing will resume at this point for the next call to 254.Fn deflate . 255.Pp 256Provide more output starting at 257.Fa next_out 258and update 259.Fa next_out 260and 261.Fa avail_out 262accordingly. 263This action is forced if the parameter 264.Fa flush 265is non-zero. 266Forcing 267.Fa flush 268frequently degrades the compression ratio, 269so this parameter should be set only when necessary 270.Pq in interactive applications . 271Some output may be provided even if 272.Fa flush 273is not set. 274.Pp 275Before the call to 276.Fn deflate , 277the application should ensure that at least 278one of the actions is possible, by providing more input and/or consuming 279more output, and updating 280.Fa avail_in 281or 282.Fa avail_out 283accordingly; 284.Fa avail_out 285should never be zero before the call. 286The application can consume the compressed output when it wants, 287for example when the output buffer is full 288.Pq avail_out == 0 , 289or after each call to 290.Fn deflate . 291If 292.Fn deflate 293returns 294.Dv Z_OK 295and with zero 296.Fa avail_out , 297it must be called again after making room in the 298output buffer because there might be more output pending. 299.Pp 300If the parameter 301.Fa flush 302is set to 303.Dv Z_SYNC_FLUSH , 304all pending output is flushed to the output buffer and the output 305is aligned on a byte boundary, so that the decompressor can get all 306input data available so far. 307(In particular, 308.Fa avail_in 309is zero after the call if enough output space 310has been provided before the call.) 311Flushing may degrade compression for some compression algorithms 312and so it should be used only when necessary. 313.Pp 314If 315.Fa flush 316is set to 317.Dv Z_FULL_FLUSH , 318all output is flushed as with 319.Dv Z_SYNC_FLUSH , 320and the compression state is reset so that decompression can restart from this 321point if previous compressed data has been damaged or if random access 322is desired. 323Using 324.Dv Z_FULL_FLUSH 325too often can seriously degrade the compression. 326.Pp 327If 328.Fn deflate 329returns with avail_out == 0, this function must be called again 330with the same value of the flush parameter and more output space 331(updated 332.Fa avail_out ) , 333until the flush is complete 334.Pf ( Fn deflate 335returns with non-zero 336.Fa avail_out ) . 337.Pp 338If the parameter 339.Fa flush 340is set to 341.Dv Z_FINISH , 342pending input is processed, pending output is flushed and 343.Fn deflate 344returns with 345.Dv Z_STREAM_END 346if there was enough output space; if 347.Fn deflate 348returns with 349.Dv Z_OK , 350this function must be called again with 351.Dv Z_FINISH 352and more output space 353(updated 354.Fa avail_out 355but no more input data, until it returns with 356.Dv Z_STREAM_END 357or an error. 358After 359.Fn deflate 360has returned 361.Dv Z_STREAM_END , 362the only possible operations on the stream are 363.Fn deflateReset 364or 365.Fn deflateEnd . 366.Pp 367.Dv Z_FINISH 368can be used immediately after 369.Fn deflateInit 370if all the compression is to be done in a single step. 371In this case, 372.Fa avail_out 373must be at least 0.1% larger than 374.Fa avail_in 375plus 12 bytes. 376If 377.Fn deflate 378does not return 379.Dv Z_STREAM_END , 380then it must be called again as described above. 381.Pp 382.Fn deflate 383sets strm->adler to the Adler-32 checksum of all input read so far 384(that is, 385.Fa total_in 386bytes). 387.Pp 388.Fn deflate 389may update 390.Fa data_type 391if it can make a good guess about the input data type 392.Pq Z_ASCII or Z_BINARY . 393If in doubt, the data is considered binary. 394This field is only for information purposes and does not affect 395the compression algorithm in any manner. 396.Pp 397.Fn deflate 398returns 399.Dv Z_OK 400if some progress has been made 401.Pq more input processed or more output produced , 402.Dv Z_STREAM_END 403if all input has been consumed and all output has been produced 404(only when 405.Fa flush 406is set to 407.Dv Z_FINISH ) , 408.Dv Z_STREAM_ERROR 409if the stream state was inconsistent 410(for example, if 411.Fa next_in 412or 413.Fa next_out 414was 415.Dv NULL ) , 416.Dv Z_BUF_ERROR 417if no progress is possible 418(for example, 419.Fa avail_in 420or 421.Fa avail_out 422was zero). 423.It Fa int Fn deflateEnd "z_streamp strm" ; 424.Pp 425All dynamically allocated data structures for this stream are freed. 426This function discards any unprocessed input and does not flush any 427pending output. 428.Pp 429.Fn deflateEnd 430returns 431.Dv Z_OK 432if successful, 433.Dv Z_STREAM_ERROR 434if the stream state was inconsistent, 435.Dv Z_DATA_ERROR 436if the stream was freed prematurely 437.Pq some input or output was discarded . 438In the error case, 439.Fa msg 440may be set but then points to a static string 441.Pq which must not be deallocated . 442.It Fa int Fn inflateInit "z_streamp strm" ; 443The 444.Fn inflateInit 445function initializes the internal stream state for decompression. 446The fields 447.Fa next_in , 448.Fa avail_in , 449.Fa zalloc , 450.Fa zfree , 451and 452.Fa opaque 453must be initialized before by the caller. 454If 455.Fa next_in 456is not 457.Dv Z_NULL 458and 459.Fa avail_in 460is large enough 461.Pq the exact value depends on the compression method , 462.Fn inflateInit 463determines the compression method from the 464.Nm 465header and allocates all data structures accordingly; 466otherwise the allocation will be deferred to the first call to 467.Fn inflate . 468If 469.Fa zalloc 470and 471.Fa zfree 472are set to 473.Dv Z_NULL , 474.Fn inflateInit 475updates them to use default allocation functions. 476.Pp 477.Fn inflateInit 478returns 479.Dv Z_OK 480if successful, 481.Dv Z_MEM_ERROR 482if there was not enough memory, 483.Dv Z_VERSION_ERROR 484if the 485.Nm 486library version is incompatible with the version assumed by the caller. 487.Fa msg 488is set to null if there is no error message. 489.Fn inflateInit 490does not perform any decompression apart from reading the 491.Nm 492header if present: this will be done by 493.Fn inflate . 494(So 495.Fa next_in 496and 497.Fa avail_in 498may be modified, 499but 500.Fa next_out 501and 502.Fa avail_out 503are unchanged.) 504.It Fa int Fn inflate "z_streamp strm" "int flush" ; 505.Fn inflate 506decompresses as much data as possible, and stops when the input 507buffer becomes empty or the output buffer becomes full. 508It may introduce some output latency 509.Pq reading input without producing any output 510except when forced to flush. 511.Pp 512The detailed semantics are as follows. 513.Fn inflate 514performs one or both of the following actions: 515.Pp 516Decompress more input starting at 517.Fa next_in 518and update 519.Fa next_in 520and 521.Fa avail_in 522accordingly. 523If not all input can be processed 524(because there is not enough room in the output buffer), 525.Fa next_in 526is updated and processing will resume at this point for the next call to 527.Fn inflate . 528.Pp 529Provide more output starting at 530.Fa next_out 531and update 532.Fa next_out 533and 534.Fa avail_out 535accordingly. 536.Fn inflate 537provides as much output as possible, 538until there is no more input data or no more space in the output buffer 539.Pq see below about the flush parameter . 540.Pp 541Before the call to 542.Fn inflate , 543the application should ensure that at least one of the actions is possible, 544by providing more input and/or consuming more output, 545and updating the next_* and avail_* values accordingly. 546The application can consume the uncompressed output when it wants, 547for example when the output buffer is full (avail_out == 0), 548or after each call to 549.Fn inflate . 550If 551.Fn inflate 552returns 553.Dv Z_OK 554and with zero 555.Fa avail_out , 556it must be called again after making room 557in the output buffer because there might be more output pending. 558.Pp 559If the parameter 560.Fa flush 561is set to 562.Dv Z_SYNC_FLUSH , 563.Fn inflate 564flushes as much output as possible to the output buffer. 565The flushing behavior of 566.Fn inflate 567is not specified for values of the flush parameter other than 568.Dv Z_SYNC_FLUSH 569and 570.Dv Z_FINISH , 571but the current implementation actually flushes as much output 572as possible anyway. 573.Pp 574.Fn inflate 575should normally be called until it returns 576.Dv Z_STREAM_END 577or an error. 578However if all decompression is to be performed in a single step 579.Pq a single call to inflate , 580the parameter 581.Fa flush 582should be set to 583.Dv Z_FINISH . 584In this case all pending input is processed and all pending output is flushed; 585.Fa avail_out 586must be large enough to hold all the uncompressed data. 587(The size of the uncompressed data may have been saved 588by the compressor for this purpose.) 589The next operation on this stream must be 590.Fn inflateEnd 591to deallocate the decompression state. 592The use of 593.Dv Z_FINISH 594is never required, but can be used to inform 595.Fn inflate 596that a faster routine may be used for the single 597.Fn inflate 598call. 599.Pp 600If a preset dictionary is needed at this point (see 601.Fn inflateSetDictionary 602below), 603.Fn inflate 604sets strm->adler to the Adler-32 checksum of the dictionary 605chosen by the compressor and returns 606.Dv Z_NEED_DICT ; 607otherwise it sets strm->adler to the Adler-32 checksum of all output produced 608so far 609(that is, 610.Fa total_out 611bytes) 612and returns 613.Dv Z_OK , 614.Dv Z_STREAM_END , 615or an error code as described below. 616At the end of the stream, 617.Fn inflate 618checks that its computed Adler-32 checksum is equal to that saved by the 619compressor and returns 620.Dv Z_STREAM_END 621only if the checksum is correct. 622.Pp 623.Fn inflate 624returns 625.Dv Z_OK 626if some progress has been made 627.Pq more input processed or more output produced , 628.Dv Z_STREAM_END 629if the end of the compressed data has been reached and all uncompressed output 630has been produced, 631.Dv Z_NEED_DICT 632if a preset dictionary is needed at this point, 633.Dv Z_DATA_ERROR 634if the input data was corrupted (input stream not conforming to the 635.Nm 636format or incorrect Adler-32 checksum), 637.Dv Z_STREAM_ERROR 638if the stream structure was inconsistent 639(for example, if 640.Fa next_in 641or 642.Fa next_out 643was 644.Dv NULL ) , 645.Dv Z_MEM_ERROR 646if there was not enough memory, 647.Dv Z_BUF_ERROR 648if no progress is possible or if there was not enough room in the output buffer 649when 650.Dv Z_FINISH 651is used. 652In the 653.Dv Z_DATA_ERROR 654case, the application may then call 655.Fn inflateSync 656to look for a good compression block. 657.It Fa int Fn inflateEnd "z_streamp strm" ; 658All dynamically allocated data structures for this stream are freed. 659This function discards any unprocessed input and does not flush any 660pending output. 661.Pp 662.Fn inflateEnd 663returns 664.Dv Z_OK 665if successful, or 666.Dv Z_STREAM_ERROR 667if the stream state was inconsistent. 668In the error case, 669.Fa msg 670may be set but then points to a static string 671.Pq which must not be deallocated . 672.El 673.Sh ADVANCED FUNCTIONS 674The following functions are needed only in some special applications. 675.Bl -tag -width Ds 676.It Fa int Fn deflateInit2 "z_streamp strm" "int level" "int method" \ 677"int windowBits" "int memLevel" "int strategy" ; 678.Pp 679This is another version of 680.Fn deflateInit 681with more compression options. 682The fields 683.Fa next_in , 684.Fa zalloc , 685.Fa zfree , 686and 687.Fa opaque 688must be initialized before by the caller. 689.Pp 690The 691.Fa method 692parameter is the compression method. 693It must be 694.Dv Z_DEFLATED 695in this version of the library. 696.Pp 697The 698.Fa windowBits 699parameter is the base two logarithm of the window size 700.Pq the size of the history buffer . 701It should be in the range 8..15 for this version of the library. 702Larger values of this parameter result in better compression 703at the expense of memory usage. 704The default value is 15 if 705.Fn deflateInit 706is used instead. 707.Pp 708The 709.Fa memLevel 710parameter specifies how much memory should be allocated 711for the internal compression state. 712memLevel=1 uses minimum memory but is slow and reduces compression ratio; 713memLevel=9 uses maximum memory for optimal speed. 714The default value is 8. 715See 716.In zconf.h 717for total memory usage as a function of 718.Fa windowBits 719and 720.Fa memLevel . 721.Pp 722The 723.Fa strategy 724parameter is used to tune the compression algorithm. 725Use the value 726.Dv Z_DEFAULT_STRATEGY 727for normal data; 728.Dv Z_FILTERED 729for data produced by a filter 730.Pq or predictor ; 731or 732.Dv Z_HUFFMAN_ONLY 733to force Huffman encoding only 734.Pq no string match . 735Filtered data consists mostly of small values with a 736somewhat random distribution. 737In this case, the compression algorithm is tuned to compress them better. 738The effect of 739.Dv Z_FILTERED 740is to force more Huffman coding and less string matching; 741it is somewhat intermediate between 742.Dv Z_DEFAULT 743and 744.Dv Z_HUFFMAN_ONLY . 745The 746.Fa strategy 747parameter only affects the compression ratio but not the correctness of the 748compressed output, even if it is not set appropriately. 749.Pp 750.Fn deflateInit2 751returns 752.Dv Z_OK 753if successful, 754.Dv Z_MEM_ERROR 755if there was not enough memory, 756.Dv Z_STREAM_ERROR 757if a parameter is invalid 758.Pq such as an invalid method . 759.Fa msg 760is set to null if there is no error message. 761.Fn deflateInit2 762does not perform any compression: this will be done by 763.Fn deflate . 764.It Fa int Fn deflateSetDictionary "z_streamp strm" \ 765"const Bytef *dictionary" "uInt dictLength" ; 766.Pp 767Initializes the compression dictionary from the given byte sequence 768without producing any compressed output. 769This function must be called immediately after 770.Fn deflateInit , 771.Fn deflateInit2 , 772or 773.Fn deflateReset , 774before any call to 775.Fn deflate . 776The compressor and decompressor must use exactly the same dictionary 777(see 778.Fn inflateSetDictionary ) . 779.Pp 780The dictionary should consist of strings 781.Pq byte sequences 782that are likely to be encountered later in the data to be compressed, 783with the most commonly used strings preferably put towards 784the end of the dictionary. 785Using a dictionary is most useful when the data to be compressed is short 786and can be predicted with good accuracy; 787the data can then be compressed better than with the default empty dictionary. 788.Pp 789Depending on the size of the compression data structures selected by 790.Fn deflateInit 791or 792.Fn deflateInit2 , 793a part of the dictionary may in effect be discarded, 794for example if the dictionary is larger than the window size in 795.Fn deflate 796or 797.Fn deflate2 . 798Thus the strings most likely to be useful should be 799put at the end of the dictionary, not at the front. 800.Pp 801Upon return of this function, strm->adler is set to the Adler-32 value 802of the dictionary; the decompressor may later use this value to determine 803which dictionary has been used by the compressor. 804(The Adler-32 value applies to the whole dictionary even if only a subset 805of the dictionary is actually used by the compressor.) 806.Pp 807.Fn deflateSetDictionary 808returns 809.Dv Z_OK 810if successful, 811or 812.Dv Z_STREAM_ERROR 813if a parameter is invalid 814.Pq such as NULL dictionary 815or the stream state is inconsistent 816(for example if 817.Fn deflate 818has already been called for this stream or if the compression method is bsort). 819.Fn deflateSetDictionary 820does not perform any compression: this will be done by 821.Fn deflate . 822.It Fa int Fn deflateCopy "z_streamp dest" "z_streamp source" ; 823.Pp 824The 825.Fn deflateCopy 826function sets the destination stream as a complete copy of the source stream. 827.Pp 828This function can be useful when several compression strategies will be 829tried, for example when there are several ways of pre-processing the input 830data with a filter. 831The streams that will be discarded should then be freed by calling 832.Fn deflateEnd . 833Note that 834.Fn deflateCopy 835duplicates the internal compression state which can be quite large, 836so this strategy is slow and can consume lots of memory. 837.Pp 838.Fn deflateCopy 839returns 840.Dv Z_OK 841if successful, 842.Dv Z_MEM_ERROR 843if there was not enough memory, 844.Dv Z_STREAM_ERROR 845if the source stream state was inconsistent 846(such as 847.Fa zalloc 848being NULL). 849.Fa msg 850is left unchanged in both source and destination. 851.It Fa int Fn deflateReset "z_streamp strm" ; 852.Pp 853This function is equivalent to 854.Fn deflateEnd 855followed by 856.Fn deflateInit , 857but does not free and reallocate all the internal compression state. 858The stream will keep the same compression level and any other attributes 859that may have been set by 860.Fn deflateInit2 . 861.Pp 862.Fn deflateReset 863returns 864.Dv Z_OK 865if successful, or 866.Dv Z_STREAM_ERROR 867if the source stream state was inconsistent 868(such as 869.Fa zalloc 870or 871.Fa state 872being NULL). 873.It Fa int Fn deflateParams "z_streamp strm" "int level" "int strategy" ; 874.Pp 875The 876.Fn deflateParams 877function dynamically updates the compression level and compression strategy. 878The interpretation of level and strategy is as in 879.Fn deflateInit2 . 880This can be used to switch between compression and straight copy 881of the input data, or to switch to a different kind of input data 882requiring a different strategy. 883If the compression level is changed, the input available so far 884is compressed with the old level 885.Pq and may be flushed ; 886the new level will take effect only at the next call to 887.Fn deflate . 888.Pp 889Before the call to 890.Fn deflateParams , 891the stream state must be set as for a call to 892.Fn deflate , 893since the currently available input may have to be compressed and flushed. 894In particular, strm->avail_out must be non-zero. 895.Pp 896.Fn deflateParams 897returns 898.Dv Z_OK 899if successful, 900.Dv Z_STREAM_ERROR 901if the source stream state was inconsistent or if a parameter was invalid, or 902.Dv Z_BUF_ERROR 903if strm->avail_out was zero. 904.It Fa int Fn inflateInit2 "z_streamp strm" "int windowBits" ; 905.Pp 906This is another version of 907.Fn inflateInit 908with an extra parameter. 909The fields 910.Fa next_in , 911.Fa avail_in , 912.Fa zalloc , 913.Fa zfree , 914and 915.Fa opaque 916must be initialized before by the caller. 917.Pp 918The 919.Fa windowBits 920parameter is the base two logarithm of the maximum window size 921.Pq the size of the history buffer . 922It should be in the range 8..15 for this version of the library. 923The default value is 15 if 924.Fn inflateInit 925is used instead. 926If a compressed stream with a larger window size is given as input, 927.Fn inflate 928will return with the error code 929.Dv Z_DATA_ERROR 930instead of trying to allocate a larger window. 931.Pp 932.Fn inflateInit2 933returns 934.Dv Z_OK 935if successful, 936.Dv Z_MEM_ERROR 937if there was not enough memory, 938.Dv Z_STREAM_ERROR 939if a parameter is invalid 940(such as a negative 941.Fa memLevel ) . 942.Fa msg 943is set to null if there is no error message. 944.Fn inflateInit2 945does not perform any decompression apart from reading the 946.Nm 947header if present: this will be done by 948.Fn inflate . 949(So 950.Fa next_in 951and 952.Fa avail_in 953may be modified, but 954.Fa next_out 955and 956.Fa avail_out 957are unchanged.) 958.It Fa int Fn inflateSetDictionary "z_streamp strm" \ 959"const Bytef *dictionary" "uInt dictLength" ; 960.Pp 961Initializes the decompression dictionary from the given uncompressed byte 962sequence. 963This function must be called immediately after a call to 964.Fn inflate 965if this call returned 966.Dv Z_NEED_DICT . 967The dictionary chosen by the compressor can be determined from the 968Adler-32 value returned by this call to 969.Fn inflate . 970The compressor and decompressor must use exactly the same dictionary 971(see 972.Fn deflateSetDictionary ) . 973.Pp 974.Fn inflateSetDictionary 975returns 976.Dv Z_OK 977if successful, 978.Dv Z_STREAM_ERROR 979if a parameter is invalid 980.Pq such as NULL dictionary 981or the stream state is inconsistent, 982.Dv Z_DATA_ERROR 983if the given dictionary doesn't match the expected one 984.Pq incorrect Adler-32 value . 985.Fn inflateSetDictionary 986does not perform any decompression: this will be done by subsequent calls of 987.Fn inflate . 988.It Fa int Fn inflateSync "z_streamp strm" ; 989.Pp 990Skips invalid compressed data until a full flush point 991(see above the description of 992.Fn deflate 993with 994.Dv Z_FULL_FLUSH ) 995can be found, or until all available input is skipped. 996No output is provided. 997.Pp 998.Fn inflateSync 999returns 1000.Dv Z_OK 1001if a full flush point has been found, 1002.Dv Z_BUF_ERROR 1003if no more input was provided, 1004.Dv Z_DATA_ERROR 1005if no flush point has been found, or 1006.Dv Z_STREAM_ERROR 1007if the stream structure was inconsistent. 1008In the success case, the application may save the current value of 1009.Fa total_in 1010which indicates where valid compressed data was found. 1011In the error case, the application may repeatedly call 1012.Fn inflateSync , 1013providing more input each time, until success or end of the input data. 1014.It Fa int Fn inflateReset "z_streamp strm" ; 1015.Pp 1016This function is equivalent to 1017.Fn inflateEnd 1018followed by 1019.Fn inflateInit , 1020but does not free and reallocate all the internal decompression state. 1021The stream will keep attributes that may have been set by 1022.Fn inflateInit2 . 1023.Pp 1024.Fn inflateReset 1025returns 1026.Dv Z_OK 1027if successful, or 1028.Dv Z_STREAM_ERROR 1029if the source stream state was inconsistent 1030(such as 1031.Fa zalloc 1032or 1033.Fa state 1034being NULL). 1035.El 1036.Sh UTILITY FUNCTIONS 1037The following utility functions are implemented on top of the 1038basic stream-oriented functions. 1039To simplify the interface, 1040some default options are assumed (compression level and memory usage, 1041standard memory allocation functions). 1042The source code of these utility functions can easily be modified 1043if you need special options. 1044.Bl -tag -width Ds 1045.It Fa int Fn compress "Bytef *dest" "uLongf *destLen" \ 1046"const Bytef *source" "uLong sourceLen" ; 1047.Pp 1048The 1049.Fn compress 1050function compresses the source buffer into the destination buffer. 1051.Fa sourceLen 1052is the byte length of the source buffer. 1053Upon entry, 1054.Fa destLen 1055is the total size of the destination buffer, 1056which must be at least 0.1% larger than 1057.Fa sourceLen 1058plus 12 bytes. 1059Upon exit, 1060.Fa destLen 1061is the actual size of the compressed buffer. 1062This function can be used to compress a whole file at once if the 1063input file is mmap'ed. 1064.Pp 1065.Fn compress 1066returns 1067.Dv Z_OK 1068if successful, 1069.Dv Z_MEM_ERROR 1070if there was not enough memory, or 1071.Dv Z_BUF_ERROR 1072if there was not enough room in the output buffer. 1073.It Fa int Fn compress2 "Bytef *dest" "uLongf *destLen" \ 1074"const Bytef *source" "uLong sourceLen" "int level" ; 1075.Pp 1076The 1077.Fn compress2 1078function compresses the source buffer into the destination buffer. 1079The 1080.Fa level 1081parameter has the same meaning as in 1082.Fn deflateInit . 1083.Fa sourceLen 1084is the byte length of the source buffer. 1085Upon entry, 1086.Fa destLen 1087is the total size of the destination buffer, 1088which must be at least 0.1% larger than 1089.Fa sourceLen 1090plus 12 bytes. 1091Upon exit, 1092.Fa destLen 1093is the actual size of the compressed buffer. 1094.Pp 1095.Fn compress2 1096returns 1097.Dv Z_OK 1098if successful, 1099.Dv Z_MEM_ERROR 1100if there was not enough memory, 1101.Dv Z_BUF_ERROR 1102if there was not enough room in the output buffer, or 1103.Dv Z_STREAM_ERROR 1104if the level parameter is invalid. 1105.It Fa int Fn uncompress "Bytef *dest" "uLongf *destLen" \ 1106"const Bytef *source" "uLong sourceLen" ; 1107.Pp 1108The 1109.Fn uncompress 1110function decompresses the source buffer into the destination buffer. 1111.Fa sourceLen 1112is the byte length of the source buffer. 1113Upon entry, 1114.Fa destLen 1115is the total size of the destination buffer, 1116which must be large enough to hold the entire uncompressed data. 1117(The size of the uncompressed data must have been saved previously 1118by the compressor and transmitted to the decompressor 1119by some mechanism outside the scope of this compression library.) 1120Upon exit, 1121.Fa destLen 1122is the actual size of the compressed buffer. 1123This function can be used to decompress a whole file at once if the 1124input file is mmap'ed. 1125.Pp 1126.Fn uncompress 1127returns 1128.Dv Z_OK 1129if successful, 1130.Dv Z_MEM_ERROR 1131if there was not enough memory, 1132.Dv Z_BUF_ERROR 1133if there was not enough room in the output buffer, or 1134.Dv Z_DATA_ERROR 1135if the input data was corrupted. 1136.It Fa gzFile Fn gzopen "const char *path" "const char *mode" ; 1137.Pp 1138The 1139.Fn gzopen 1140function opens a gzip 1141.Pq .gz 1142file for reading or writing. 1143The mode parameter is as in 1144.Xr fopen 3 1145.Po 1146.Qq rb 1147or 1148.Qq wb 1149.Pc 1150but can also include a compression level 1151.Pq Qq wb9 1152or a strategy: 1153.Sq f 1154for filtered data, as in 1155.Qq wb6f ; 1156.Sq h 1157for Huffman only compression, as in 1158.Qq wb1h . 1159(See the description of 1160.Fn deflateInit2 1161for more information about the strategy parameter.) 1162.Pp 1163.Fn gzopen 1164can be used to read a file which is not in gzip format; 1165in this case 1166.Fn gzread 1167will directly read from the file without decompression. 1168.Pp 1169.Fn gzopen 1170returns 1171.Dv NULL 1172if the file could not be opened or if there was 1173insufficient memory to allocate the (de)compression state; 1174errno can be checked to distinguish the two cases (if errno is zero, the 1175.Nm 1176error is 1177.Dv Z_MEM_ERROR ) . 1178.It Fa gzFile Fn gzdopen "int fd" "const char *mode" ; 1179.Pp 1180The 1181.Fn gzdopen 1182function associates a gzFile with the file descriptor 1183.Fa fd . 1184File descriptors are obtained from calls like 1185.Xr open 2 , 1186.Xr dup 2 , 1187.Xr creat 3 , 1188.Xr pipe 2 , 1189or 1190.Xr fileno 3 1191(if the file has been previously opened with 1192.Xr fopen 3 ) . 1193The 1194.Fa mode 1195parameter is as in 1196.Fn gzopen . 1197.Pp 1198The next call to 1199.Fn gzclose 1200on the returned gzFile will also close the file descriptor fd, 1201just like fclose(fdopen(fd), mode) closes the file descriptor fd. 1202If you want to keep fd open, use gzdopen(dup(fd), mode). 1203.Pp 1204.Fn gzdopen 1205returns 1206.Dv NULL 1207if there was insufficient memory to allocate the (de)compression state. 1208.It Fa int Fn gzsetparams "gzFile file" "int level" "int strategy" ; 1209.Pp 1210The 1211.Fn gzsetparams 1212function dynamically updates the compression level or strategy. 1213See the description of 1214.Fn deflateInit2 1215for the meaning of these parameters. 1216.Pp 1217.Fn gzsetparams 1218returns 1219.Dv Z_OK 1220if successful, or 1221.Dv Z_STREAM_ERROR 1222if the file was not opened for writing. 1223.It Fa int Fn gzread "gzFile file" "voidp buf" "unsigned len" ; 1224.Pp 1225The 1226.Fn gzread 1227function reads the given number of uncompressed bytes from the compressed file. 1228If the input file was not in gzip format, 1229.Fn gzread 1230copies the given number of bytes into the buffer. 1231.Pp 1232.Fn gzread 1233returns the number of uncompressed bytes actually read 1234(0 for end of file, \-1 for error). 1235.It Fa int Fn gzwrite "gzFile file" "const voidp buf" "unsigned len" ; 1236.Pp 1237The 1238.Fn gzwrite 1239function writes the given number of uncompressed bytes into the compressed file. 1240.Fn gzwrite 1241returns the number of uncompressed bytes actually written 1242.Pq 0 in case of error . 1243.It Fa int Fn gzprintf "gzFile file" "const char *format" "..." ; 1244.Pp 1245The 1246.Fn gzprintf 1247function converts, formats, and writes the args to the compressed file 1248under control of the format string, as in 1249.Xr fprintf 3 . 1250.Fn gzprintf 1251returns the number of uncompressed bytes actually written 1252.Pq 0 in case of error . 1253.It Fa int Fn gzputs "gzFile file" "const char *s" ; 1254.Pp 1255The 1256.Fn gzputs 1257function writes the given null-terminated string to the compressed file, 1258excluding the terminating null character. 1259.Pp 1260.Fn gzputs 1261returns the number of characters written, or \-1 in case of error. 1262.It Fa char * Fn gzgets "gzFile file" "char *buf" "int len" ; 1263.Pp 1264The 1265.Fn gzgets 1266function reads bytes from the compressed file until len\-1 characters are read, 1267or a newline character is read and transferred to 1268.Fa buf , 1269or an end-of-file condition is encountered. 1270The string is then terminated with a null character. 1271.Pp 1272.Fn gzgets 1273returns 1274.Fa buf , 1275or 1276.Dv Z_NULL 1277in case of error. 1278.It Fa int Fn gzputc "gzFile file" "int c" ; 1279.Pp 1280The 1281.Fn gzputc 1282function writes 1283.Fa c , 1284converted to an unsigned char, into the compressed file. 1285.Fn gzputc 1286returns the value that was written, or \-1 in case of error. 1287.It Fa int Fn gzgetc "gzFile file" ; 1288.Pp 1289The 1290.Fn gzgetc 1291function reads one byte from the compressed file. 1292.Fn gzgetc 1293returns this byte or \-1 in case of end of file or error. 1294.It Fa int Fn gzflush "gzFile file" "int flush" ; 1295.Pp 1296The 1297.Fn gzflush 1298function flushes all pending output into the compressed file. 1299The parameter 1300.Fa flush 1301is as in the 1302.Fn deflate 1303function. 1304The return value is the 1305.Nm 1306error number (see function 1307.Fn gzerror 1308below). 1309.Fn gzflush 1310returns 1311.Dv Z_OK 1312if the flush parameter is 1313.Dv Z_FINISH 1314and all output could be flushed. 1315.Pp 1316.Fn gzflush 1317should be called only when strictly necessary because it can 1318degrade compression. 1319.It Fa z_off_t Fn gzseek "gzFile file" "z_off_t offset" "int whence" ; 1320.Pp 1321Sets the starting position for the next 1322.Fn gzread 1323or 1324.Fn gzwrite 1325on the given compressed file. 1326The offset represents a number of bytes in the uncompressed data stream. 1327The whence parameter is defined as in 1328.Xr lseek 2 ; 1329the value 1330.Dv SEEK_END 1331is not supported. 1332.Pp 1333If the file is opened for reading, this function is emulated but can be 1334extremely slow. 1335If the file is opened for writing, only forward seeks are supported; 1336.Fn gzseek 1337then compresses a sequence of zeroes up to the new starting position. 1338.Pp 1339.Fn gzseek 1340returns the resulting offset location as measured in bytes from 1341the beginning of the uncompressed stream, or \-1 in case of error, 1342in particular if the file is opened for writing and the new starting position 1343would be before the current position. 1344.It Fa int Fn gzrewind "gzFile file" ; 1345.Pp 1346The 1347.Fn gzrewind 1348function rewinds the given 1349.Fa file . 1350This function is supported only for reading. 1351.Pp 1352gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). 1353.It Fa z_off_t Fn gztell "gzFile file" ; 1354.Pp 1355The 1356.Fn gztell 1357function returns the starting position for the next 1358.Fn gzread 1359or 1360.Fn gzwrite 1361on the given compressed file. 1362This position represents a number of bytes in the uncompressed data stream. 1363.Pp 1364gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR). 1365.It Fa int Fn gzeof "gzFile file" ; 1366.Pp 1367The 1368.Fn gzeof 1369function returns 1 when 1370.Dv EOF 1371has previously been detected reading the given input stream, otherwise zero. 1372.It Fa int Fn gzclose "gzFile file" ; 1373.Pp 1374The 1375.Fn gzclose 1376function flushes all pending output if necessary, closes the compressed file 1377and deallocates all the (de)compression state. 1378The return value is the 1379.Nm 1380error number (see function 1381.Fn gzerror 1382below). 1383.It Fa const char * Fn gzerror "gzFile file" "int *errnum" ; 1384.Pp 1385The 1386.Fn gzerror 1387function returns the error message for the last error which occurred on the 1388given compressed 1389.Fa file . 1390.Fa errnum 1391is set to the 1392.Nm 1393error number. 1394If an error occurred in the file system and not in the compression library, 1395.Fa errnum 1396is set to 1397.Dv Z_ERRNO 1398and the application may consult errno to get the exact error code. 1399.El 1400.Sh CHECKSUM FUNCTIONS 1401These functions are not related to compression but are exported 1402anyway because they might be useful in applications using the 1403compression library. 1404.Bl -tag -width Ds 1405.It Fa uLong Fn adler32 "uLong adler" "const Bytef *buf" "uInt len" ; 1406The 1407.Fn adler32 1408function updates a running Adler-32 checksum with the bytes buf[0..len-1] 1409and returns the updated checksum. 1410If 1411.Fa buf 1412is 1413.Dv NULL , 1414this function returns the required initial value for the checksum. 1415.Pp 1416An Adler-32 checksum is almost as reliable as a CRC32 but can be computed 1417much faster. 1418Usage example: 1419.Bd -literal -offset indent 1420uLong adler = adler32(0L, Z_NULL, 0); 1421 1422while (read_buffer(buffer, length) != EOF) { 1423adler = adler32(adler, buffer, length); 1424} 1425if (adler != original_adler) error(); 1426.Ed 1427.It Fa uLong Fn crc32 "uLong crc" "const Bytef *buf" "uInt len" ; 1428The 1429.Fn crc32 1430function updates a running CRC with the bytes buf[0..len-1] 1431and returns the updated CRC. 1432If 1433.Fa buf 1434is 1435.Dv NULL , 1436this function returns the required initial value for the CRC. 1437Pre- and post-conditioning 1438.Pq one's complement 1439is performed within this function so it shouldn't be done by the application. 1440Usage example: 1441.Bd -literal -offset indent 1442uLong crc = crc32(0L, Z_NULL, 0); 1443 1444while (read_buffer(buffer, length) != EOF) { 1445crc = crc32(crc, buffer, length); 1446} 1447if (crc != original_crc) error(); 1448.Ed 1449.El 1450.Sh STRUCTURES 1451.Bd -literal 1452struct internal_state; 1453 1454typedef struct z_stream_s { 1455 Bytef *next_in; /* next input byte */ 1456 uInt avail_in; /* number of bytes available at next_in */ 1457 uLong total_in; /* total nb of input bytes read so far */ 1458 1459 Bytef *next_out; /* next output byte should be put there */ 1460 uInt avail_out; /* remaining free space at next_out */ 1461 uLong total_out; /* total nb of bytes output so far */ 1462 1463 char *msg; /* last error message, NULL if no error */ 1464 struct internal_state FAR *state; /* not visible by applications */ 1465 1466 alloc_func zalloc; /* used to allocate the internal state */ 1467 free_func zfree; /* used to free the internal state */ 1468 voidpf opaque; /* private data object passed to zalloc and zfree*/ 1469 1470 int data_type; /*best guess about the data type: ascii or binary*/ 1471 uLong adler; /* Adler-32 value of the uncompressed data */ 1472 uLong reserved; /* reserved for future use */ 1473} z_stream; 1474 1475typedef z_stream FAR * z_streamp; 1476.Ed 1477.Pp 1478The application must update 1479.Fa next_in 1480and 1481.Fa avail_in 1482when 1483.Fa avail_in 1484has dropped to zero. 1485It must update 1486.Fa next_out 1487and 1488.Fa avail_out 1489when 1490.Fa avail_out 1491has dropped to zero. 1492The application must initialize 1493.Fa zalloc , 1494.Fa zfree , 1495and 1496.Fa opaque 1497before calling the init function. 1498All other fields are set by the compression library 1499and must not be updated by the application. 1500.Pp 1501The 1502.Fa opaque 1503value provided by the application will be passed as the first 1504parameter for calls to 1505.Fn zalloc 1506and 1507.Fn zfree . 1508This can be useful for custom memory management. 1509The compression library attaches no meaning to the 1510.Fa opaque 1511value. 1512.Pp 1513.Fa zalloc 1514must return 1515.Dv Z_NULL 1516if there is not enough memory for the object. 1517If 1518.Nm 1519is used in a multi-threaded application, 1520.Fa zalloc 1521and 1522.Fa zfree 1523must be thread safe. 1524.Pp 1525On 16-bit systems, the functions 1526.Fa zalloc 1527and 1528.Fa zfree 1529must be able to allocate exactly 65536 bytes, 1530but will not be required to allocate more than this if the symbol MAXSEG_64K 1531is defined (see 1532.In zconf.h ) . 1533.Pp 1534WARNING: On MSDOS, pointers returned by 1535.Fa zalloc 1536for objects of exactly 65536 bytes *must* have their offset normalized to zero. 1537The default allocation function provided by this library ensures this (see 1538.Pa zutil.c ) . 1539To reduce memory requirements and avoid any allocation of 64K objects, 1540at the expense of compression ratio, 1541compile the library with -DMAX_WBITS=14 (see 1542.In zconf.h ) . 1543.Pp 1544The fields 1545.Fa total_in 1546and 1547.Fa total_out 1548can be used for statistics or progress reports. 1549After compression, 1550.Fa total_in 1551holds the total size of the uncompressed data and may be saved for use 1552in the decompressor 1553(particularly if the decompressor wants to decompress everything 1554in a single step). 1555.Sh CONSTANTS 1556.Bd -literal 1557#define Z_NO_FLUSH 0 1558#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ 1559#define Z_SYNC_FLUSH 2 1560#define Z_FULL_FLUSH 3 1561#define Z_FINISH 4 1562/* Allowed flush values; see deflate() below for details */ 1563 1564#define Z_OK 0 1565#define Z_STREAM_END 1 1566#define Z_NEED_DICT 2 1567#define Z_ERRNO (-1) 1568#define Z_STREAM_ERROR (-2) 1569#define Z_DATA_ERROR (-3) 1570#define Z_MEM_ERROR (-4) 1571#define Z_BUF_ERROR (-5) 1572#define Z_VERSION_ERROR (-6) 1573/* Return codes for the compression/decompression functions. 1574 * Negative values are errors, 1575 * positive values are used for special but normal events. 1576 */ 1577 1578#define Z_NO_COMPRESSION 0 1579#define Z_BEST_SPEED 1 1580#define Z_BEST_COMPRESSION 9 1581#define Z_DEFAULT_COMPRESSION (-1) 1582/* compression levels */ 1583 1584#define Z_FILTERED 1 1585#define Z_HUFFMAN_ONLY 2 1586#define Z_DEFAULT_STRATEGY 0 1587/* compression strategy; see deflateInit2() below for details */ 1588 1589#define Z_BINARY 0 1590#define Z_ASCII 1 1591#define Z_UNKNOWN 2 1592/* Possible values of the data_type field */ 1593 1594#define Z_DEFLATED 8 1595/* The deflate compression method 1596 * (the only one supported in this version) 1597*/ 1598 1599#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ 1600 1601#define zlib_version zlibVersion() 1602/* for compatibility with versions < 1.0.2 */ 1603.Ed 1604.Sh VARIOUS HACKS 1605deflateInit and inflateInit are macros to allow checking the 1606.Nm 1607version and the compiler's view of 1608.Fa z_stream . 1609.Bl -tag -width Ds 1610.It Fa int Fn deflateInit_ "z_stream strm" "int level" \ 1611"const char *version" "int stream_size" ; 1612.It Fa int Fn inflateInit_ "z_stream strm" "const char *version" \ 1613"int stream_size" ; 1614.It Fa int Fn deflateInit2_ "z_stream strm" "int level" "int method" \ 1615"int windowBits" "int memLevel" "int strategy" "const char *version" \ 1616"int stream_size" ; 1617.It Fa int Fn inflateInit2_ "z_stream strm" "int windowBits" \ 1618"const char *version" "int stream_size" ; 1619.It Fa const char * Fn zError "int err" ; 1620.It Fa int Fn inflateSyncPoint "z_streamp z" ; 1621.It Fa const uLongf * Fn "get_crc_table" "void" ; 1622.El 1623.Sh SEE ALSO 1624.Bl -tag -width 12n -compact 1625.It RFC 1950 1626ZLIB Compressed Data Format Specification. 1627.It RFC 1951 1628DEFLATE Compressed Data Format Specification. 1629.It RFC 1952 1630GZIP File Format Specification. 1631.El 1632.Pp 1633.Lk http://www.gzip.org/zlib/ "zlib" 1634.Sh HISTORY 1635This manual page is based on an HTML version of 1636.In zlib.h 1637converted by 1638.An piaip Aq Mt piaip@csie.ntu.edu.tw 1639and was converted to mdoc format by the 1640.Ox 1641project. 1642.Sh AUTHORS 1643.An Jean-loup Gailly Aq Mt jloup@gzip.org 1644.An Mark Adler Aq Mt madler@alumni.caltech.edu 1645