Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\zlib_inflate\inflate.c Create Date:2022-07-28 06:57:59
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:late() uses a state machine to process as much input data and generate asmuch output data as possible before returning

Proto:int zlib_inflate(z_streamp strm, int flush)

Type:int

Parameter:

TypeParameterName
z_streampstrm>next_out, given the space available and the provided input--the effect
intflush
332  static const unsigned short order[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}
338  If >next_out, given the space available and the provided input--the effect == NULL || not visible by applications == NULL || next input byte == NULL && number of bytes available at next_in != 0 Then Return Z_STREAM_ERROR
342  state = not visible by applications
344  If current inflate mode == waiting for type bits, including last-flag bit Then current inflate mode = same, but skip check to exit inflate on new block
345  Load registers with state in inflate() for speed ()
346  in = have
347  out = left
348  ret = Allowed flush values; see deflate() and inflate() below for details
349  cycle switch current inflate mode
351  Case current inflate mode == waiting for magic header
354  Break
356  Assure that there are at least n bits in the bit accumulator. If there isnot enough available input to do that, then return from inflate(). (16)
357  If ((Return the low n bits of the bit accumulator (n < 16) (8) << 8) + (hold >> 8)) % 31 Then
359  last error message, NULL if no error = "incorrect header check"
361  Break
364  last error message, NULL if no error = "unknown compression method"
366  Break
368  Remove n bits from the bit accumulator (4)
369  len = Return the low n bits of the bit accumulator (n < 16) (4) + 8
371  last error message, NULL if no error = "invalid window size"
373  Break
375  zlib header max distance (INFLATE_STRICT) = 1U << len
376  adler32 value of the uncompressed data = protected copy of check value = Update a running Adler-32 checksum with the bytes buf[0..len-1] andreturn the updated checksum. If buf is NULL, this function returnsthe required initial value for the checksum.An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
377  current inflate mode = If hold & 0x200 Then waiting for dictionary check value Else waiting for type bits, including last-flag bit
378  Clear the input bit accumulator ()
379  Break
380  Case current inflate mode == waiting for dictionary check value
381  Assure that there are at least n bits in the bit accumulator. If there isnot enough available input to do that, then return from inflate(). (32)
382  adler32 value of the uncompressed data = protected copy of check value = Reverse the bytes in a 32-bit value (hold)
383  Clear the input bit accumulator ()
384  current inflate mode = waiting for inflateSetDictionary() call
386  Case current inflate mode == waiting for inflateSetDictionary() call
387  If rue if dictionary provided == 0 Then
389  Return Z_NEED_DICT
391  adler32 value of the uncompressed data = protected copy of check value = Update a running Adler-32 checksum with the bytes buf[0..len-1] andreturn the updated checksum. If buf is NULL, this function returnsthe required initial value for the checksum.An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
392  current inflate mode = waiting for type bits, including last-flag bit
394  Case current inflate mode == waiting for type bits, including last-flag bit
395  If flush == Only for inflate at present Then Go to inf_leave
397  Case current inflate mode == same, but skip check to exit inflate on new block
401  Break
403  Assure that there are at least n bits in the bit accumulator. If there isnot enough available input to do that, then return from inflate(). (3)
404  rue if processing last block = Return the low n bits of the bit accumulator (n < 16) (1)
405  Remove n bits from the bit accumulator (1)
409  Break
413  Break
416  Break
418  last error message, NULL if no error = "invalid block type"
421  Remove n bits from the bit accumulator (2)
422  Break
423  Case current inflate mode == waiting for stored size (length and complement)
424  Remove zero to seven bits as needed to go to a byte boundary ()
425  Assure that there are at least n bits in the bit accumulator. If there isnot enough available input to do that, then return from inflate(). (32)
426  If (hold & 0xffff) != ( hold >> 16 ^ 0xffff) Then
427  last error message, NULL if no error = "invalid stored block lengths"
429  Break
431  literal or length of data to copy = hold & 0xffff
432  Clear the input bit accumulator ()
433  current inflate mode = /o: waiting for input or output to copy stored block
435  Case current inflate mode == /o: waiting for input or output to copy stored block
436  copy = literal or length of data to copy
437  If copy Then
438  If copy > have Then copy = have
439  If copy > left Then copy = left
440  If copy == 0 Then Go to inf_leave
441  No 3D Now!(put, next, copy)
442  have -= copy
443  next += copy
444  left -= copy
445  put += copy
447  Break
449  current inflate mode = waiting for type bits, including last-flag bit
450  Break
451  Case current inflate mode == waiting for dynamic block table lengths
452  Assure that there are at least n bits in the bit accumulator. If there isnot enough available input to do that, then return from inflate(). (14)
453  umber of length code lengths = Return the low n bits of the bit accumulator (n < 16) (5) + 257
454  Remove n bits from the bit accumulator (5)
455  umber of distance code lengths = Return the low n bits of the bit accumulator (n < 16) (5) + 1
456  Remove n bits from the bit accumulator (5)
457  umber of code length code lengths = Return the low n bits of the bit accumulator (n < 16) (4) + 4
458  Remove n bits from the bit accumulator (4)
461  last error message, NULL if no error = "too many length or distance symbols"
463  Break
466  umber of code lengths in lens[] = 0
467  current inflate mode = waiting for code length code lengths
469  Case current inflate mode == waiting for code length code lengths
475  When umber of code lengths in lens[] < 19 cycle
476  mporary storage for code lengths [order[umber of code lengths in lens[] ++]] = 0
477  xt available space in codes[] = space for code tables
478  starting table for length/literal codes = xt available space in codes[]
479  dex bits for lencode = 7
480  ret = zlib_inflate_table(CODES, mporary storage for code lengths , 19, & (xt available space in codes[] ), & (dex bits for lencode ), work area for code table building )
482  If ret Then
483  last error message, NULL if no error = "invalid code lengths set"
485  Break
487  umber of code lengths in lens[] = 0
488  current inflate mode = waiting for length/lit and distance code lengths
490  Case current inflate mode == waiting for length/lit and distance code lengths
492  cycle
497  If ffset in table or code value < 16 Then
502  Else
503  If ffset in table or code value == 16 Then
515  Else if ffset in table or code value == 17 Then
522  Else
534  When copy-- cycle
540  If current inflate mode == got a data error -- remain here until reset Then Break
543  xt available space in codes[] = space for code tables
544  starting table for length/literal codes = xt available space in codes[]
545  dex bits for lencode = 9
546  ret = zlib_inflate_table(LENS, mporary storage for code lengths , umber of length code lengths , & (xt available space in codes[] ), & (dex bits for lencode ), work area for code table building )
548  If ret Then
549  last error message, NULL if no error = "invalid literal/lengths set"
551  Break
553  starting table for distance codes = xt available space in codes[]
554  dex bits for distcode = 6
555  ret = zlib_inflate_table(DISTS, mporary storage for code lengths + umber of length code lengths , umber of distance code lengths , & (xt available space in codes[] ), & (dex bits for distcode ), work area for code table building )
557  If ret Then
558  last error message, NULL if no error = "invalid distances set"
560  Break
562  current inflate mode = waiting for length/lit code
564  Case current inflate mode == waiting for length/lit code
565  If have >= 6 && left >= 258 Then
569  Break
571  cycle
573  If s in this part of the code <= bits Then Break
577  last = this
578  cycle
586  Remove n bits from the bit accumulator (s in this part of the code )
587  literal or length of data to copy = ffset in table or code value
590  Break
594  Break
597  last error message, NULL if no error = "invalid literal/length code"
599  Break
601  xtra bits needed = peration, extra bits, table bits & 15
602  current inflate mode = waiting for length extra bits
604  Case current inflate mode == waiting for length extra bits
605  If xtra bits needed Then
610  current inflate mode = waiting for distance code
612  Case current inflate mode == waiting for distance code
613  cycle
615  If s in this part of the code <= bits Then Break
618  If (peration, extra bits, table bits & 0xf0) == 0 Then
619  last = this
620  cycle
628  Remove n bits from the bit accumulator (s in this part of the code )
630  last error message, NULL if no error = "invalid distance code"
632  Break
634  distance back to copy string from = ffset in table or code value
635  xtra bits needed = peration, extra bits, table bits & 15
636  current inflate mode = waiting for distance extra bits
638  Case current inflate mode == waiting for distance extra bits
639  If xtra bits needed Then
652  last error message, NULL if no error = "invalid distance too far back"
654  Break
656  current inflate mode = waiting for output space to copy string
658  Case current inflate mode == waiting for output space to copy string
659  If left == 0 Then Go to inf_leave
660  copy = out - left
663  If copy > window write index Then
671  Else
675  If copy > left Then copy = left
676  left -= copy
677  literal or length of data to copy -= copy
678  Do
679  put++ = from++
680  When --copy cycle
681  If literal or length of data to copy == 0 Then current inflate mode = waiting for length/lit code
682  Break
683  Case current inflate mode == waiting for output space to write literal
684  If left == 0 Then Go to inf_leave
685  put++ = literal or length of data to copy
686  left--
687  current inflate mode = waiting for length/lit code
688  Break
689  Case current inflate mode == waiting for 32-bit check value
692  out -= left
698  out = left
707  current inflate mode = ished check, done -- remain here until reset
709  Case current inflate mode == ished check, done -- remain here until reset
710  ret = Z_STREAM_END
711  Go to inf_leave
712  Case current inflate mode == got a data error -- remain here until reset
713  ret = Z_DATA_ERROR
714  Go to inf_leave
715  Case current inflate mode == got an inflate() memory error -- remain here until reset
716  Return Z_MEM_ERROR
717  Case current inflate mode == SYNC
718  Default
719  Return Z_STREAM_ERROR
727  inf_leave :
728  Restore state from registers in inflate() ()
729  If window size or zero if not using window || current inflate mode < waiting for 32-bit check value && out != remaining free space at next_out Then Update the window with the last wsize (normally 32K) bytes written beforereturning. This is only called when a window is already in use, or whenoutput has been written during this inflate call, but the end of the deflatestream has not been reached yet
732  in -= number of bytes available at next_in
733  out -= remaining free space at next_out
734  total nb of input bytes read so far += in
735  total nb of bytes output so far += out
736  protected copy of output count += out
737  If 0 true for zlib, bit 1 true for gzip && out Then adler32 value of the uncompressed data = protected copy of check value = check function to use adler32() for zlib or crc32() for gzip (protected copy of check value , next output byte should be put there - out, out)
741  best guess about the data type: ascii or binary = umber of bits in "in" + If rue if processing last block Then 64 Else 0 + If current inflate mode == waiting for type bits, including last-flag bit Then 128 Else 0
744  If flush == Z_PACKET_FLUSH && ret == Allowed flush values; see deflate() and inflate() below for details && remaining free space at next_out != 0 && number of bytes available at next_in == 0 Then Return Returns true if inflate is currently at the end of a block generated byZ_SYNC_FLUSH or Z_FULL_FLUSH
748  If ( in == 0 && out == 0 || flush == Z_FINISH ) && ret == Allowed flush values; see deflate() and inflate() below for details Then ret = Z_BUF_ERROR
751  Return ret
Caller
NameDescribe
zlib_inflate_blobUtility function: initialize zlib, unpack binary blob, clean up zlib,* return len or negative error code.
__gunzipIncluded from initramfs et al code