+ buffer = (char *) slp->tblock[0]; /* set write pointer */
+ bufsize = writesize; /* length to write */
+ returns.clen = returns.unclen = bufsize;
+
+#ifdef HAVE_ZLIB
+ /*
+ * If the data can't be compressed it's written with no
+ * prefix as writesize bytes. If it's compressible, it's
+ * written from struct tapebuf with an 8 byte prefix
+ * followed by the data. This will always be less than
+ * writesize. Restore, on a short read, can compare the
+ * length read to the compressed length in the header
+ * to verify that the read was good.
+ */
+
+ if (do_compress) { /* don't compress the first block */
+ comp_buf->clen = comp_buf->unclen = bufsize;
+ worklen = TP_BSIZE + writesize;
+ 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->clen = worklen;
+ buffer = (char *) comp_buf;
+ returns.clen = bufsize = worklen + 8;
+ }
+ }
+ /* compress the remaining blocks */
+ do_compress = compressed;
+#endif /* HAVE_ZLIB */