compress from file to def until provided buffer is full or end of input reached; return last deflate() return value, or Z_ERRNO if there was read error on the file */
| 76 | input reached; return last deflate() return value, or Z_ERRNO if |
| 77 | there was read error on the file */ |
| 78 | local int partcompress(FILE *in, z_streamp def) |
| 79 | { |
| 80 | int ret, flush; |
| 81 | unsigned char raw[RAWLEN]; |
| 82 | |
| 83 | flush = Z_SYNC_FLUSH; |
| 84 | do { |
| 85 | def->avail_in = (uInt)fread(raw, 1, RAWLEN, in); |
| 86 | if (ferror(in)) |
| 87 | return Z_ERRNO; |
| 88 | def->next_in = raw; |
| 89 | if (feof(in)) |
| 90 | flush = Z_FINISH; |
| 91 | LOG_FITBLK("partcompress1 avail_in=%d total_in=%d avail_out=%d total_out=%d\n", (int)def->avail_in, (int)def->total_in, (int)def->avail_out, (int)def->total_out); |
| 92 | ret = deflate(def, flush); |
| 93 | LOG_FITBLK("partcompress2 ret=%d avail_in=%d total_in=%d avail_out=%d total_out=%d\n", ret, (int)def->avail_in, (int)def->total_in, (int)def->avail_out, (int)def->total_out); |
| 94 | assert(ret != Z_STREAM_ERROR); |
| 95 | } while (def->avail_out != 0 && flush == Z_SYNC_FLUSH); |
| 96 | return ret; |
| 97 | } |
| 98 | |
| 99 | /* recompress from inf's input to def's output; the input for inf and |
| 100 | the output for def are set in those structures before calling; |