| 4827 | */ |
| 4828 | |
| 4829 | static int stbi__parse_zlib(stbi__zbuf* a, int parse_header) { |
| 4830 | int final, type; |
| 4831 | if (parse_header) |
| 4832 | if (!stbi__parse_zlib_header(a)) |
| 4833 | return 0; |
| 4834 | a->num_bits = 0; |
| 4835 | a->code_buffer = 0; |
| 4836 | do { |
| 4837 | final = stbi__zreceive(a, 1); |
| 4838 | type = stbi__zreceive(a, 2); |
| 4839 | if (type == 0) { |
| 4840 | if (!stbi__parse_uncompressed_block(a)) |
| 4841 | return 0; |
| 4842 | } else if (type == 3) { |
| 4843 | return 0; |
| 4844 | } else { |
| 4845 | if (type == 1) { |
| 4846 | // use fixed code lengths |
| 4847 | if (!stbi__zbuild_huffman( |
| 4848 | &a->z_length, stbi__zdefault_length, STBI__ZNSYMS)) |
| 4849 | return 0; |
| 4850 | if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) |
| 4851 | return 0; |
| 4852 | } else { |
| 4853 | if (!stbi__compute_huffman_codes(a)) |
| 4854 | return 0; |
| 4855 | } |
| 4856 | if (!stbi__parse_huffman_block(a)) |
| 4857 | return 0; |
| 4858 | } |
| 4859 | } while (!final); |
| 4860 | return 1; |
| 4861 | } |
| 4862 | |
| 4863 | static int stbi__do_zlib( |
| 4864 | stbi__zbuf* a, char* obuf, int olen, int exp, int parse_header) { |
no test coverage detected