+ if (compressed) {
+ comp_buf->length = bufsize;
+ worklen = TP_BSIZE + writesize;
+ if (do_compress)
+ compresult = compress2(comp_buf->buf, &worklen,
+ (char *)slp->tblock[0], writesize, complevel);
+ if (compresult == Z_OK && worklen <= writesize-32) {
+ /* write the compressed buffer */
+ comp_buf->length = worklen;
+ comp_buf->compressed = 1;
+ buffer = (char *) comp_buf;
+ returns.clen = bufsize = worklen + sizeof(struct tapebuf);
+ }
+ else {
+ /* write the data uncompressed */
+ comp_buf->length = writesize;
+ comp_buf->compressed = 0;
+ buffer = (char *) comp_buf;
+ returns.clen = bufsize = writesize + sizeof(struct tapebuf);
+ returns.unclen = returns.clen;
+ memcpy(comp_buf->buf, (char *)slp->tblock[0], writesize);
+ }
+ }
+ /* compress the remaining blocks */
+ do_compress = compressed;
+#endif /* HAVE_ZLIB */
+
+ while (eot_count < 10 && size < bufsize) {