/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: */
int uzlib_zlib_parse_header(TINF_DATA *d)
/* Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: */
int uzlib_zlib_parse_header(TINF_DATA *d)
{
   unsigned char cmf, flg;
   cmf = uzlib_get_byte(d);
   flg = uzlib_get_byte(d);
   if ((256*cmf + flg) % 31) return TINF_DATA_ERROR;
   if ((cmf & 0x0f) != 8) return TINF_DATA_ERROR;
   if ((cmf >> 4) > 7) return TINF_DATA_ERROR;
   if (flg & 0x20) return TINF_DATA_ERROR;
   d->checksum_type = TINF_CHKSUM_ADLER;
   d->checksum = 1;
   return cmf >> 4;
}