static char rcsid[] = "$Id$";
#endif
-#include <sys/types.h>
-
+#include <config.h>
#include "tailor.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
-#ifndef NO_FCNTL_H
+#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
posbits = 0;
if (insize < INBUF_EXTRA) {
- if ((rsize = read(in, (char*)inbuf+insize, INBUFSIZ)) == EOF) {
+ if ((rsize = read(in, (char*)inbuf+insize, INBUFSIZ)) == -1) {
read_error();
}
insize += rsize;
- bytes_in += (ulg)rsize;
+ bytes_in += (off_t)rsize;
}
inbits = ((rsize != 0) ? ((long)insize - insize%n_bits)<<3 :
((long)insize<<3)-(n_bits-1));
#endif
if (!test && outpos > 0) {
write_buf(out, (char*)outbuf, outpos);
- bytes_out += (ulg)outpos;
+ bytes_out += (off_t)outpos;
}
error(to_stdout ? "corrupt input." :
"corrupt input. Use zcat to recover some data.");
if (outpos >= OUTBUFSIZ) {
if (!test) {
write_buf(out, (char*)outbuf, outpos);
- bytes_out += (ulg)outpos;
+ bytes_out += (off_t)outpos;
}
outpos = 0;
}
if (!test && outpos > 0) {
write_buf(out, (char*)outbuf, outpos);
- bytes_out += (ulg)outpos;
+ bytes_out += (off_t)outpos;
}
return OK;
}
static char rcsid[] = "$Id$";
#endif
+#include <config.h>
#include <ctype.h>
-#include <sys/types.h>
#include "tailor.h"
#include "gzip.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
-#ifndef NO_FCNTL_H
+#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
local ulg crc; /* crc on uncompressed file data */
-long header_bytes; /* number of bytes in gzip header */
+off_t header_bytes; /* number of bytes in gzip header */
/* ===========================================================================
* Deflate in to out.
flags |= ORIG_NAME;
}
put_byte(flags); /* general flags */
- put_long(time_stamp);
+ put_long(time_stamp == (time_stamp & 0xffffffff)
+ ? (ulg)time_stamp : (ulg)0);
/* Write deflated file to zip file */
crc = updcrc(0, 0);
put_byte(OS_CODE); /* OS identifier */
if (save_orig_name) {
- char *p = basename(ifname); /* Don't save the directory part. */
+ char *p = base_name(ifname); /* Don't save the directory part. */
do {
put_char(*p);
} while (*p++);
}
- header_bytes = (long)outcnt;
+ header_bytes = (off_t)outcnt;
(void)deflate();
/* Check input size (but not in VMS -- variable record lengths mess it up)
* and not on MSDOS -- diet in TSR mode reports an incorrect file size)
*/
- if (ifile_size != -1L && isize != (ulg)ifile_size) {
- Trace((stderr, " actual=%ld, read=%ld ", ifile_size, isize));
+ if (ifile_size != -1L && bytes_in != ifile_size) {
fprintf(stderr, "%s: %s: file size changed while zipping\n",
progname, ifname);
}
/* Write the crc and uncompressed size */
put_long(crc);
- put_long(isize);
+ put_long((ulg)bytes_in);
header_bytes += 2*sizeof(long);
flush_outbuf();
Assert(insize == 0, "inbuf not empty");
len = read(ifd, buf, size);
- if (len == (unsigned)(-1) || len == 0) return (int)len;
+ if (len == 0) return (int)len;
+ if (len == (unsigned)-1) {
+ read_error();
+ return EOF;
+ }
crc = updcrc((uch*)buf, len);
- isize += (ulg)len;
+ bytes_in += (off_t)len;
return (int)len;
}