📄 manual_3.html
字号:
</pre></td></tr></table></P><P><HR SIZE="6"><A NAME="SEC27"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_3.html#SEC26"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_3.html#SEC28"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual.html#SEC_Top"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 3.4.2 <CODE>BZ2_bzRead</CODE> </H3><!--docid::SEC27::--><TABLE><tr><td> </td><td class=example><pre> int BZ2_bzRead ( int *bzerror, BZFILE *b, void *buf, int len );</pre></td></tr></table>Reads up to <CODE>len</CODE> (uncompressed) bytes from the compressed file <CODE>b</CODE> intothe buffer <CODE>buf</CODE>. If the read was successful, <CODE>bzerror</CODE> is set to <CODE>BZ_OK</CODE>and the number of bytes read is returned. If the logical end-of-streamwas detected, <CODE>bzerror</CODE> will be set to <CODE>BZ_STREAM_END</CODE>, and the numberof bytes read is returned. All other <CODE>bzerror</CODE> values denote an error.<P><CODE>BZ2_bzRead</CODE> will supply <CODE>len</CODE> bytes,unless the logical stream end is detectedor an error occurs. Because of this, it is possible to detect the stream end by observing when the number of bytes returned is less than the numberrequested. Nevertheless, this is regarded as inadvisable; you shouldinstead check <CODE>bzerror</CODE> after every call and watch out for<CODE>BZ_STREAM_END</CODE>.</P><P>Internally, <CODE>BZ2_bzRead</CODE> copies data from the compressed file in chunksof size <CODE>BZ_MAX_UNUSED</CODE> bytesbefore decompressing it. If the file contains more bytes than strictlyneeded to reach the logical end-of-stream, <CODE>BZ2_bzRead</CODE> will almost certainlyread some of the trailing data before signalling <CODE>BZ_SEQUENCE_END</CODE>.To collect the read but unused data once <CODE>BZ_SEQUENCE_END</CODE> has appeared, call <CODE>BZ2_bzReadGetUnused</CODE> immediately before <CODE>BZ2_bzReadClose</CODE>.</P><P>Possible assignments to <CODE>bzerror</CODE>:<TABLE><tr><td> </td><td class=display><pre style="font-family: serif"> <CODE>BZ_PARAM_ERROR</CODE> if <CODE>b</CODE> is <CODE>NULL</CODE> or <CODE>buf</CODE> is <CODE>NULL</CODE> or <CODE>len < 0</CODE> <CODE>BZ_SEQUENCE_ERROR</CODE> if <CODE>b</CODE> was opened with <CODE>BZ2_bzWriteOpen</CODE> <CODE>BZ_IO_ERROR</CODE> if there is an error reading from the compressed file <CODE>BZ_UNEXPECTED_EOF</CODE> if the compressed file ended before the logical end-of-stream was detected <CODE>BZ_DATA_ERROR</CODE> if a data integrity error was detected in the compressed stream <CODE>BZ_DATA_ERROR_MAGIC</CODE> if the stream does not begin with the requisite header bytes (ie, is not a <CODE>bzip2</CODE> data file). This is really a special case of <CODE>BZ_DATA_ERROR</CODE>. <CODE>BZ_MEM_ERROR</CODE> if insufficient memory was available <CODE>BZ_STREAM_END</CODE> if the logical end of stream was detected. <CODE>BZ_OK</CODE> otherwise.</pre></td></tr></table></P><P>Possible return values:<TABLE><tr><td> </td><td class=display><pre style="font-family: serif"> number of bytes read if <CODE>bzerror</CODE> is <CODE>BZ_OK</CODE> or <CODE>BZ_STREAM_END</CODE> undefined otherwise</pre></td></tr></table></P><P>Allowable next actions:<TABLE><tr><td> </td><td class=display><pre style="font-family: serif"> collect data from <CODE>buf</CODE>, then <CODE>BZ2_bzRead</CODE> or <CODE>BZ2_bzReadClose</CODE> if <CODE>bzerror</CODE> is <CODE>BZ_OK</CODE> collect data from <CODE>buf</CODE>, then <CODE>BZ2_bzReadClose</CODE> or <CODE>BZ2_bzReadGetUnused</CODE> if <CODE>bzerror</CODE> is <CODE>BZ_SEQUENCE_END</CODE> <CODE>BZ2_bzReadClose</CODE> otherwise</pre></td></tr></table></P><P><HR SIZE="6"><A NAME="SEC28"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_3.html#SEC27"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_3.html#SEC29"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual.html#SEC_Top"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 3.4.3 <CODE>BZ2_bzReadGetUnused</CODE> </H3><!--docid::SEC28::--><TABLE><tr><td> </td><td class=example><pre> void BZ2_bzReadGetUnused ( int* bzerror, BZFILE *b, void** unused, int* nUnused );</pre></td></tr></table>Returns data which was read from the compressed file but was not neededto get to the logical end-of-stream. <CODE>*unused</CODE> is set to the addressof the data, and <CODE>*nUnused</CODE> to the number of bytes. <CODE>*nUnused</CODE> willbe set to a value between <CODE>0</CODE> and <CODE>BZ_MAX_UNUSED</CODE> inclusive.<P>This function may only be called once <CODE>BZ2_bzRead</CODE> has signalled <CODE>BZ_STREAM_END</CODE> but before <CODE>BZ2_bzReadClose</CODE>.</P><P>Possible assignments to <CODE>bzerror</CODE>:<TABLE><tr><td> </td><td class=display><pre style="font-family: serif"> <CODE>BZ_PARAM_ERROR</CODE> if <CODE>b</CODE> is <CODE>NULL</CODE> or <CODE>unused</CODE> is <CODE>NULL</CODE> or <CODE>nUnused</CODE> is <CODE>NULL</CODE> <CODE>BZ_SEQUENCE_ERROR</CODE> if <CODE>BZ_STREAM_END</CODE> has not been signalled or if <CODE>b</CODE> was opened with <CODE>BZ2_bzWriteOpen</CODE> <CODE>BZ_OK</CODE> otherwise</pre></td></tr></table></P><P>Allowable next actions:<TABLE><tr><td> </td><td class=display><pre style="font-family: serif"> <CODE>BZ2_bzReadClose</CODE></pre></td></tr></table></P><P><HR SIZE="6"><A NAME="SEC29"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_3.html#SEC28"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_3.html#SEC30"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual.html#SEC_Top"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 3.4.4 <CODE>BZ2_bzReadClose</CODE> </H3><!--docid::SEC29::--><TABLE><tr><td> </td><td class=example><pre> void BZ2_bzReadClose ( int *bzerror, BZFILE *b );</pre></td></tr></table>Releases all memory pertaining to the compressed file <CODE>b</CODE>. <CODE>BZ2_bzReadClose</CODE> does not call <CODE>fclose</CODE> on the underlying filehandle, so you should do that yourself if appropriate.<CODE>BZ2_bzReadClose</CODE> should be called to clean up after all errorsituations.<P>Possible assignments to <CODE>bzerror</CODE>:<TABLE><tr><td> </td><td class=display><pre style="font-family: serif"> <CODE>BZ_SEQUENCE_ERROR</CODE> if <CODE>b</CODE> was opened with <CODE>BZ2_bzOpenWrite</CODE> <CODE>BZ_OK</CODE> otherwise</pre></td></tr></table></P><P>Allowable next actions:<TABLE><tr><td> </td><td class=display><pre style="font-family: serif"> none</pre></td></tr></table></P><P><HR SIZE="6"><A NAME="SEC30"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_3.html#SEC29"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_3.html#SEC31"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual.html#SEC_Top"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 3.4.5 <CODE>BZ2_bzWriteOpen</CODE> </H3><!--docid::SEC30::--><TABLE><tr><td> </td><td class=example><pre> BZFILE *BZ2_bzWriteOpen ( int *bzerror, FILE *f, int blockSize100k, int verbosity, int workFactor );</pre></td></tr></table>Prepare to write compressed data to file handle <CODE>f</CODE>. <CODE>f</CODE> should refer toa file which has been opened for writing, and for which the errorindicator (<CODE>ferror(f)</CODE>)is not set. <P>For the meaning of parameters <CODE>blockSize100k</CODE>,<CODE>verbosity</CODE> and <CODE>workFactor</CODE>, see<BR> <CODE>BZ2_bzCompressInit</CODE>.</P><P>All required memory is allocated at this stage, so if the callcompletes successfully, <CODE>BZ_MEM_ERROR</CODE> cannot be signalled by asubsequent call to <CODE>BZ2_bzWrite</CODE>.</P><P>Possible assignments to <CODE>bzerror</CODE>:<TABLE><tr><td> </td><td class=display><pre style="font-family: serif"> <CODE>BZ_CONFIG_ERROR</CODE> if the library has been mis-compiled <CODE>BZ_PARAM_ERROR</CODE> if <CODE>f</CODE> is <CODE>NULL</CODE> or <CODE>blockSize100k < 1</CODE> or <CODE>blockSize100k > 9</CODE> <CODE>BZ_IO_ERROR</CODE> if <CODE>ferror(f)</CODE> is nonzero <CODE>BZ_MEM_ERROR</CODE> if insufficient memory is available <CODE>BZ_OK</CODE> otherwise</pre></td></tr></table></P><P>Possible return values:<TABLE><tr><td> </td><td class=display><pre style="font-family: serif"> Pointer to an abstract <CODE>BZFILE</CODE> if <CODE>bzerror</CODE> is <CODE>BZ_OK</CODE> <CODE>NULL</CODE> otherwise</pre></td></tr></table></P><P>Allowable next actions:<TABLE><tr><td> </td><td class=display><pre style="font-family: serif"> <CODE>BZ2_bzWrite</CODE> if <CODE>bzerror</CODE> is <CODE>BZ_OK</CODE> (you could go directly to <CODE>BZ2_bzWriteClose</CODE>, but this would be pretty pointless) <CODE>BZ2_bzWriteClose</CODE> otherwise</pre></td></tr></table></P><P><HR SIZE="6"><A NAME="SEC31"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_3.html#SEC30"> < </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_3.html#SEC32"> > </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[ << ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual.html#SEC_Top"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[ >> ]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 3.4.6 <CODE>BZ2_bzWrite</CODE> </H3><!--docid::SEC31::--><TABLE><tr><td> </td><td class=example><pre> void BZ2_bzWrite ( int *bzerror, BZFILE *b, void *buf, int len );</pre></td></tr></table>Absorbs <CODE>len</CODE> bytes from the buffer <CODE>buf</CODE>, eventually to becompressed and written to the file.<P>Possible assignments to <CODE>bzerror</CODE>:<TABLE><tr><td> </td><td class=display><pre style="font-family: serif"> <CODE>BZ_PARAM_ERROR</CODE> if <CODE>b</CODE> is <CODE>NULL</CODE> or <CODE>buf</CODE> is <CODE>NULL</CODE> or <CODE>len < 0</CODE> <CODE>BZ_SEQUENCE_ERROR</CODE> if b was opened with <CODE>BZ2_bzReadOpen</CODE> <CODE>BZ_IO_ERROR</CODE> if there is an error writing the compressed file. <CODE>BZ_OK</CODE> otherwise</pre></td></tr></table></P><P><HR SIZE=
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -