lib/ruby/truffle/pr-zlib/lib/pr/rbzlib.rb
# Check the gzip header of a gz_stream opened for reading. Set the stream
# mode to transparent if the gzip magic header is not present; set s->err
# to Z_DATA_ERROR if the magic header is present but the rest of the header
# is incorrect.
#
# IN assertion: the stream s has already been created sucessfully;
#    s->stream.avail_in is zero for the first time, but may be non-zero
#    for concatenated .gz files.
#
Check the gzip header of a gz_stream opened for reading. Set the stream
mode to transparent if the gzip magic header is not present; set s->err
to Z_DATA_ERROR if the magic header is present but the rest of the header
is incorrect.

IN assertion: the stream s has already been created sucessfully;
s->stream.avail_in is zero for the first time, but may be non-zero
for concatenated .gz files.
Check the gzip header of a gz_stream opened for reading . Set the stream mode to transparent if the gzip magic header is not present ; set s - > err to Z_DATA_ERROR if the magic header is present but the rest of the header is incorrect . IN assertion : the stream s has already been created sucessfully ; s - > stream . avail_in is zero for the first time but may be non - zero for concatenated . gz files .
def check_header(s)
    len = s.stream.avail_in
    if len < 2
      if len != 0
        s.inbuf[0] = s.stream.next_in[0]
      end
      begin
        buf = s.file.read(Z_BUFSIZE >> len)
        if buf
          s.inbuf[len,buf.length] = buf
          len = buf.length
        else
          len = 0
        end
      rescue
        len = 0
        s.z_err = Z_ERRNO
      end
      s.stream.avail_in += len
      s.stream.next_in = Bytef.new(s.inbuf)
      if s.stream.avail_in < 2
        s.transparent = !s.stream.avail_in == 0
        return
      end
    end
    if s.stream.next_in[0] != @@gz_magic[0].ord ||
      s.stream.next_in[1] != @@gz_magic[1].ord
    then
      s.transparent = true
      return
    end
    s.stream.avail_in -= 2
    s.stream.next_in += 2
    method = get_byte(s)
    flags = get_byte(s)
    if (method != Z_DEFLATED) || (flags & RESERVED) != 0
      s.z_err = Z_DATA_ERROR
      return
    end
    for len in 0 .. 5
      get_byte(s)
    end
    if (flags & EXTRA_FIELD) != 0
      len = (get_byte(s))
      len += ((get_byte(s)) << 8)
      while len != 0 || (get_byte(s) != Z_EOF)
        len -= 1
      end
    end
    if (flags & ORIG_NAME) != 0
      loop do
        c = get_byte(s)
        break if c == 0 || (c == Z_EOF)
      end
    end
    if (flags & COMMENT_) != 0
      loop do
        c = get_byte(s)
        break if c == 0 || (c == Z_EOF)
      end
    end
    if (flags & HEAD_CRC) != 0
      get_byte(s)
      get_byte(s)
    end
    s.z_err = s.z_eof ? Z_DATA_ERROR : Z_OK
  end
def check_header ( s ) len = s . stream . avail_in if len < 2 if len != 0 s . inbuf [ 0 ] = s . stream . next_in [ 0 ] end begin buf = s . file . read ( Z_BUFSIZE >> len ) if buf s . inbuf [ len , buf . length ] = buf len = buf . length else len = 0 end rescue len = 0 s . z_err = Z_ERRNO end s . stream . avail_in += len s . stream . next_in = Bytef . new ( s . inbuf ) if s . stream . avail_in < 2 s . transparent = ! s . stream . avail_in == 0 return end end if s . stream . next_in [ 0 ] != @@gz_magic [ 0 ] . ord || s . stream . next_in [ 1 ] != @@gz_magic [ 1 ] . ord then s . transparent = true return end s . stream . avail_in -= 2 s . stream . next_in += 2 method = get_byte ( s ) flags = get_byte ( s ) if ( method != Z_DEFLATED ) || ( flags & RESERVED ) != 0 s . z_err = Z_DATA_ERROR return end for len in 0 .. 5 get_byte ( s ) end if ( flags & EXTRA_FIELD ) != 0 len = ( get_byte ( s ) ) len += ( ( get_byte ( s ) ) << 8 ) while len != 0 || ( get_byte ( s ) != Z_EOF ) len -= 1 end end if ( flags & ORIG_NAME ) != 0 loop do c = get_byte ( s ) break if c == 0 || ( c == Z_EOF ) end end if ( flags & COMMENT_ ) != 0 loop do c = get_byte ( s ) break if c == 0 || ( c == Z_EOF ) end end if ( flags & HEAD_CRC ) != 0 get_byte ( s ) get_byte ( s ) end s . z_err = s . z_eof ? Z_DATA_ERROR : Z_OK end
Check the gzip header of a gz_stream opened for reading.
Check the gzip header of a gz_stream opened for reading .
s
<not_specific>