| /* bits taken from ppc */ |
| extern void *avail_ram, *end_avail; |
| void *zalloc(unsigned size) |
| if (avail_ram > end_avail) { |
| //puts("oops... out of memory\n"); |
| void gunzip (void *dst, int dstlen, unsigned char *src, int *lenp) |
| if (src[2] != DEFLATED || (flags & RESERVED) != 0) { |
| //puts("bad gzipped data\n"); |
| if ((flags & EXTRA_FIELD) != 0) |
| i = 12 + src[10] + (src[11] << 8); |
| if ((flags & ORIG_NAME) != 0) |
| if ((flags & COMMENT) != 0) |
| if ((flags & HEAD_CRC) != 0) |
| //puts("gunzip: ran out of data in header\n"); |
| s.workspace = zalloc(zlib_inflate_workspacesize()); |
| r = zlib_inflateInit2(&s, -MAX_WBITS); |
| //puts("inflateInit2 returned "); puthex(r); puts("\n"); |
| r = zlib_inflate(&s, Z_FINISH); |
| if (r != Z_OK && r != Z_STREAM_END) { |
| //puts("inflate returned "); puthex(r); puts("\n"); |
| *lenp = s.next_out - (unsigned char *) dst; |