E D R S I H C RSS
ID
Password
Join
행복한 결혼ì´ì•¼ë§ë¡œ ì´ ì„¸ìƒì—서 가장 ê°’ì§„ 계약ì´ë‹¤. ―O.A.바티스타

 * ë©”ì¸ì‚¬ì´íЏë§í¬ : [http]http://www.gzip.org/zlib/
  • 메뉴얼 : [http]http://www.gzip.org/zlib/manual.html
  • 간단한 í•¨ìˆ˜ì„¤ëª…ì„ ë²ˆì—­í•´ë³´ì•˜ìŠµë‹ˆë‹¤.
  • 최신 버전 : 1.2.1

Contents

1 개요
2 ì¼ë°˜ 함수 설명
2.1 int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
2.2 int compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level);
2.3 int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
2.4 gzFile gzopen (const char *path, const char *mode);
2.5 gzFile gzdopen (int fd, const char *mode);
2.6 int gzsetparams (gzFile file, int level, int strategy);
2.7 int gzread (gzFile file, voidp buf, unsigned len);
2.8 int gzwrite (gzFile file, const voidp buf, unsigned len);
2.9 int VA gzprintf (gzFile file, const char *format, ...);
2.10 int gzputs (gzFile file, const char *s);
2.11 char * gzgets (gzFile file, char *buf, int len);
2.12 int gzputc (gzFile file, int c);
2.13 int gzgetc (gzFile file);
2.14 int gzflush (gzFile file, int flush);
2.15 z_off_t gzseek (gzFile file, z_off_t offset, int whence);
2.16 int gzrewind (gzFile file);
2.17 z_off_t gztell (gzFile file);
2.18 int gzeof (gzFile file);
2.19 int gzclose (gzFile file);
2.20 const char * gzerror (gzFile file, int *errnum);

1 개요 #

'zlib' ì••ì¶• ë¼ì´ë¸ŒëŸ¬ë¦¬ëŠ” 메모리ìƒì—ì„œì˜ ì••ì¶• ë° ì••ì¶•í•´ì œ 함수들과 ì••ì¶•í•´ì œëœ ë°ì´íƒ€ì˜ 무결성 ê²€ì‚¬ê¸°ëŠ¥ì„ ì œê³µí•©ë‹ˆë‹¤. ì´ ë¼ì´ë¸ŒëŸ¬ë¦¬ ë²„ì „ì€ ë‹¨ì§€ í•˜ë‚˜ì˜ ì••ì¶• 메소드(deflation)ì„ ì œê³µí•˜ì§€ë§Œ, 다른 ì•Œê³ ë¦¬ì¦˜ë„ ì°¨í›„ ì¶”ê°€ë  ìˆ˜ ìžˆì„ ê²ƒì´ê³  역시 ê°™ì€ ìŠ¤íŠ¸ë¦¼ ì¸í„°íŽ˜ì´ìŠ¤ë¥¼ 가질 것입니다. ì••ì¶•ì€ ë²„í¼ê°€ 충분하다면(예를 들어 입력화ì¼ì´ 메모리 ë§µì²˜ë¦¬ëœ ìƒíƒœë¼ë©´) í•œë²ˆì— ì‹¤í–‰ë  ê²ƒìž…ë‹ˆë‹¤. 그렇지않으면 ì••ì¶• 함수를 여러번 호출함으로서 ìž‘ì—…ì„ ì™„ë£Œí•  수 있습니다. 후ìžì˜ 경우, 어플리케ì´ì…˜ì€ ê°ê°ì˜ 호출ì´ì „ì— ë” ë§Žì€ ìž…ë ¥ 버í¼ë¥¼ 제공하거나 (ë”ë§Žì€ ì¶œë ¥ë²„í¼ë¥¼ 제공함으로서) ì¶œë ¥ê³µê°„ì„ ì†Œë¹„í•´ì•¼ë§Œ í•  것입니다.

ë˜í•œ ë¼ì´ë¸ŒëŸ¬ë¦¬ëŠ” 표준 입출력과 비슷한 ì¸í„°íŽ˜ì´ìŠ¤ë¥¼ 가진 gzip(.gz) í¬ë§· í™”ì¼ì„ ì½ê³  기ë¡í•˜ëŠ” ê¸°ëŠ¥ì„ ì œê³µí•©ë‹ˆë‹¤.

ë¼ì´ë¸ŒëŸ¬ë¦¬ëŠ” 어떠한 ì‹œê·¸ë„ í•¸ë“¤ëŸ¬ë„ ì„¤ì¹˜í•˜ì§€ 않습니다. 압축해제기(decoder)는 ì••ì¶•ëœ ë°ì´íƒ€ì˜ ì¼ê´€ì„±ì„ 검사하므로, ë¼ì´ë¸ŒëŸ¬ë¦¬ëŠ” ë§ê°€ì§„ ìž…ë ¥ì˜ ê²½ìš°ì¼ ë•Œì¡°ì°¨ë„ ê²°ì½” 다운ë˜ëŠ” ì¼ì€ 없습니다.

2 ì¼ë°˜ 함수 설명 #

2.1 int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); #

ì›ë³¸ 버í¼ì˜ ë‚´ìš©ì„ ì••ì¶•í•˜ì—¬ ê²°ê³¼ 버í¼ë¡œ 저장합니다. sourceLenì€ source 버í¼ì˜ ë°”ì´íŠ¸ë‹¨ìœ„ 길ì´ë¥¼ ì˜ë¯¸í•©ë‹ˆë‹¤. 실행전ì—는 destLenì€ ê²°ê³¼ 버í¼ì˜ ì „ì²´ 길ì´ë¥¼ ë‹´ê³  있어야하며, ì´ëŠ” sourceLen보다 12ë°”ì´íЏ ë” ê¸¸ì–´ì•¼í•˜ë¯€ë¡œ ì ì–´ë„ 0.1%ì •ë„ ì¦ê°€í•œ ìƒíƒœë¡œ ì§€ì •ë  ìˆ˜ 있어야합니다. 실행후ì—는 destLenì€ ì••ì¶•ëœ ê²°ê³¼ 버í¼ì˜ 실제 길ì´ë¥¼ ë‹´ê³  있습니다. ì´ í•¨ìˆ˜ëŠ” 입력화ì¼ì´ 메모리 맵처리ë˜ì–´ìžˆë‹¤ë©´ ì „ì²´ í™”ì¼ì„ í•œë²ˆì— ì••ì¶•í•˜ëŠ”ë° ì‚¬ìš©ë  ìˆ˜ 있습니다.

모든 ì••ì¶•ì´ ì„±ê³µì ìœ¼ë¡œ 처리ë˜ì—ˆë‹¤ë©´ Z_OKê°€ 반환ë˜ë©°, 충분한 메모리가 확보ë˜ì§€ 않았다면 Z_MEM_ERROR, ê²°ê³¼ 버í¼ì˜ 길ì´ê°€ 충분하지 ì•Šì„ ê²½ìš°ì—는 Z_BUF_ERROR를 반환합니다.

2.2 int compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level); #

level 매개변수가 deflateInit()ì—서와 ê°™ì€ ì˜ë¯¸ë¥¼ 가진다는 ê²ƒì„ ì œì™¸í•˜ê³ ëŠ” compress() 함수와 ë™ì¼í•œ ê¸°ëŠ¥ì„ í•©ë‹ˆë‹¤.

ë°˜í™˜ê°’ë„ compress()와 같으며, level 매개변수가 부정확한 경우ì—는 Z_STREAM_ERROR를 반환한다는 것만 다릅니다.

2.3 int uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); #

Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen is the actual size of the compressed buffer. This function can be used to decompress a whole file at once if the input file is mmap'ed.

uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted.

2.4 gzFile gzopen (const char *path, const char *mode); #

Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman only compression as in "wb1h". (See the description of deflateInit2 for more information about the strategy parameter.) gzopen can be used to read a file which is not in gzip format ; in this case gzread will directly read from the file without decompression.

gzopen returns NULL if the file could not be opened or if there was insufficient memory to allocate the (de)compression state ; errno can be checked to distinguish the two cases (if errno is zero, the zlib error is Z_MEM_ERROR).

2.5 gzFile gzdopen (int fd, const char *mode); #

gzdopen() associates a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or fileno (in the file has been previously opened with fopen). The mode parameter is as in gzopen. The next call of gzclose on the returned gzFile will also close the file descriptor fd, just like fclose(fdopen(fd), mode) closes the file descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).

gzdopen returns NULL if there was insufficient memory to allocate the (de)compression state.

2.6 int gzsetparams (gzFile file, int level, int strategy); #

Dynamically update the compression level or strategy. See the description of deflateInit2 for the meaning of these parameters. gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not opened for writing.

2.7 int gzread (gzFile file, voidp buf, unsigned len); #

Reads the given number of uncompressed bytes from the compressed file. If the input file was not in gzip format, gzread copies the given number of bytes into the buffer. gzread returns the number of uncompressed bytes actually read (0 for end of file, -1 for error).

2.8 int gzwrite (gzFile file, const voidp buf, unsigned len); #

Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of uncompressed bytes actually written (0 in case of error).

2.9 int VA gzprintf (gzFile file, const char *format, ...); #

Converts, formats, and writes the args to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of uncompressed bytes actually written (0 in case of error).

2.10 int gzputs (gzFile file, const char *s); #

Writes the given null-terminated string to the compressed file, excluding the terminating null character. gzputs returns the number of characters written, or -1 in case of error.

2.11 char * gzgets (gzFile file, char *buf, int len); #

Reads bytes from the compressed file until len-1 characters are read, or a newline character is read and transferred to buf, or an end-of-file condition is encountered. The string is then terminated with a null character. gzgets returns buf, or Z_NULL in case of error.

2.12 int gzputc (gzFile file, int c); #

Writes c, converted to an unsigned char, into the compressed file. gzputc returns the value that was written, or -1 in case of error.

2.13 int gzgetc (gzFile file); #

Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error.

2.14 int gzflush (gzFile file, int flush); #

Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. The return value is the zlib error number (see function gzerror below). gzflush returns Z_OK if the flush parameter is Z_FINISH and all output could be flushed. gzflush should be called only when strictly necessary because it can degrade compression.

2.15 z_off_t gzseek (gzFile file, z_off_t offset, int whence); #

Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported. 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.

gzseek returns the resulting offset location as measured in bytes from the beginning of the uncompressed stream, or -1 in case of error, in particular if the file is opened for writing and the new starting position would be before the current position.

2.16 int gzrewind (gzFile file); #

Rewinds the given file. This function is supported only for reading. gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)

2.17 z_off_t gztell (gzFile file); #

Returns the starting position for the next gzread or gzwrite on the given compressed file. This position represents a number of bytes in the uncompressed data stream. gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)

2.18 int gzeof (gzFile file); #

Returns 1 when EOF has previously been detected reading the given input stream, otherwise zero.

2.19 int gzclose (gzFile file); #

Flushes all pending output if necessary, closes the compressed file and deallocates all the (de)compression state. The return value is the zlib error number (see function gzerror below).

2.20 const char * gzerror (gzFile file, int *errnum); #

Returns the error message for the last error which occurred on the given compressed file. errnum is set to zlib error number. If an error occurred in the file system and not in the compression library, errnum is set to Z_ERRNO and the application may consult errno to get the exact error code.

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2010-10-28 12:42:54
Processing time 0.4655 sec