Exemple #1
0
 /// <summary>
 /// <para>This method decompresses as much data as possible, and stops when the input buffer (<see cref="next_in" />) becomes empty or the output buffer (<see cref="next_out" />) becomes full. It may some introduce some output latency (reading input without producing any output) except when forced to flush. </para>
 /// <para>The detailed semantics are as follows. <see cref="inflate" /> performs one or both of the following actions: </para>
 /// <para>
 /// <list type="bullet">
 /// <item>Decompress more input starting at <see cref="ZStream.next_in" /> and update <see cref="ZStream.next_in" /> and <see cref="ZStream.avail_in" /> accordingly. If not all input can be processed (because there is not enough room in the output buffer), <see cref="next_in" /> is updated and processing will resume at this point for the next call of <see cref="inflate" />. </item>
 /// <item>Provide more output starting at <see cref="next_out" /> and update <see cref="ZStream.next_out" /> and <see cref="ZStream.avail_out" /> accordingly. <see cref="ZStream.inflate" /> provides as much output as possible, until there is no more input data or no more space in the output buffer (see below about the <paramref name="flush" /> parameter).</item>
 /// </list>
 /// </para>
 /// </summary>
 /// <param name="flush"><see cref="FlushStrategy">Flush strategy</see> to use.</param>
 /// <remarks>
 /// <para>Before the call of <see cref="inflate" />, the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating the next_* and avail_* values accordingly. The application can consume the uncompressed output when it wants, for example when the output buffer is full (<c>avail_out == 0</c>), or after each call of <see cref="inflate" />. If <see cref="inflate" /> returns <see cref="ZLibResultCode.Z_OK" /> and with zero <see cref="avail_out" />, it must be called again after making room in the <see cref="next_out">output buffer</see> because there might be more output pending. </para>
 /// <para>If the parameter <paramref name="flush" /> is set to <see cref="FlushStrategy.Z_SYNC_FLUSH" />, <see cref="inflate" /> flushes as much output as possible to the output buffer. The flushing behavior of <see cref="inflate" /> is not specified for values of the <paramref name="flush" /> parameter other than <see cref="FlushStrategy.Z_SYNC_FLUSH" /> and <see cref="FlushStrategy.Z_FINISH" />, but the current implementation actually flushes as much output as possible anyway. </para>
 /// <para><see cref="inflate" /> should normally be called until it returns <see cref="ZLibResultCode.Z_STREAM_END" /> or an error. However if all decompression is to be performed in a single step (a single call of inflate), the parameter <paramref name="flush" /> should be set to <see cref="FlushStrategy.Z_FINISH" />. In this case all pending input is processed and all pending output is flushed ; <see cref="avail_out" /> must be large enough to hold all the uncompressed data. (The size of the uncompressed data may have been saved by the compressor for this purpose.) The next operation on this stream must be <see cref="inflateEnd" /> to deallocate the decompression state. The use of <see cref="FlushStrategy.Z_FINISH" /> is never required, but can be used to inform <see cref="inflate" /> that a faster routine may be used for the single <see cref="inflate" /> call. </para>
 /// <para>If a preset dictionary is needed at this point (see <see cref = "inflateSetDictionary" />), <see cref="inflate" /> sets strm-adler to the adler32 checksum of the dictionary chosen by the compressor and returns <see cref="ZLibResultCode.Z_NEED_DICT" /> ; otherwise it sets strm->adler to the adler32 checksum of all output produced so far (that is, <see cref="total_out" /> bytes) and returns <see cref="ZLibResultCode.Z_OK" />, <see cref="ZLibResultCode.Z_STREAM_END" /> or an error code as described below. At the end of the stream, <see cref="inflate" />) checks that its computed adler32 checksum is equal to that saved by the compressor and returns <see cref="ZLibResultCode.Z_STREAM_END" /> only if the checksum is correct.</para>
 /// </remarks>
 /// <returns>
 /// <see cref="inflate" /> returns <see cref="ZLibResultCode.Z_OK" /> if some progress has been made (more input processed or more output produced), <see cref="ZLibResultCode.Z_STREAM_END" /> if the end of the compressed data has been reached and all uncompressed output has been produced, <see cref="ZLibResultCode.Z_NEED_DICT" /> if a preset dictionary is needed at this point, <see cref="ZLibResultCode.Z_DATA_ERROR" /> if the input data was corrupted (input stream not conforming to the ZLib format or incorrect adler32 checksum), <see cref="ZLibResultCode.Z_STREAM_ERROR" /> if the stream structure was inconsistent (for example if <see cref="next_in" /> or <see cref="next_out" /> was <c>null</c>), <see cref="ZLibResultCode.Z_MEM_ERROR" /> if there was not enough memory, <see cref="ZLibResultCode.Z_BUF_ERROR" /> if no progress is possible or if there was not enough room in the output buffer when <see cref="FlushStrategy.Z_FINISH" /> is used. In the <see cref="ZLibResultCode.Z_DATA_ERROR" /> case, the application may then call <see cref="inflateSync" /> to look for a good compression block.
 /// </returns>
 internal int inflate(FlushStrategy flush)
 {
     if (_istate == null)
     {
         return((int)ZLibResultCode.Z_STREAM_ERROR);
     }
     return(_istate.inflate(this, flush));
 }