/* Define to 1 if you have the `link' function. */
#undef HAVE_LINK
+/* Define to 1 if the system has the type `long long'. */
+#undef HAVE_LONG_LONG
+
/* Define to 1 if you have the `memcpy' function. */
#undef HAVE_MEMCPY
/* Define to 1 if the system has the type `uid_t'. */
#undef HAVE_UID_T
+/* Define to 1 if the system has the type `uint64_t'. */
+#undef HAVE_UINT64_T
+
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
+/* The size of a `long', as computed by sizeof. */
+#undef SIZEOF_LONG
+
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/param.h sys/time.h)
-AC_CHECK_HEADERS(pwd.h grp.h utime.h)
+AC_CHECK_HEADERS(pwd.h grp.h utime.h inttypes.h stdint.h)
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_STRUCT_TM
AC_STRUCT_TIMEZONE
-AC_CHECK_TYPES([uid_t, gid_t])
+AC_CHECK_SIZEOF(long)
+AC_CHECK_TYPES([uid_t, gid_t, long long, uint64_t])
AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct stat.st_ino],,,
[
#if HAVE_SYS_TYPES_H
(tm->tm_sec / 2)));
}
+static unsigned long
+wintime_to_unix_stamp()
+{
+#if HAVE_UINT64_T
+ uint64_t t;
+ uint64_t epoch = 0x019db1ded53e8000; /* 1970-01-01 00:00:00 (UTC) */
+
+ t = get_longword();
+ t += (uint64_t)get_longword() << 32;
+ t = (t - epoch) / 10000000;
+ return t;
+#else
+ int i, borrow;
+ unsigned long t, q, x;
+ unsigned long wintime[8];
+ unsigned long epoch[8] = {0x01,0x9d,0xb1,0xde, 0xd5,0x3e,0x80,0x00};
+ /* 1970-01-01 00:00:00 (UTC) */
+ /* wintime -= epoch */
+ borrow = 0;
+ for (i = 7; i >= 0; i--) {
+ wintime[i] = (unsigned)get_byte() - epoch[i] - borrow;
+ borrow = (wintime[i] > 0xff) ? 1 : 0;
+ wintime[i] &= 0xff;
+ }
+
+ /* q = wintime / 10000000 */
+ t = q = 0;
+ x = 10000000; /* x: 24bit */
+ for (i = 0; i < 8; i++) {
+ t = (t << 8) + wintime[i]; /* 24bit + 8bit. t must be 32bit variable */
+ q <<= 8; /* q must be 32bit (time_t) */
+ q += t / x;
+ t %= x; /* 16bit */
+ }
+ return q;
+#endif
+}
+
/* ------------------------------------------------------------------------ */
/* build header functions */
/* ------------------------------------------------------------------------ */
* on level 3 header:
* size field is 4 bytes
*/
+
static long
get_extended_header(fp, hdr, header_size, hcrc)
FILE *fp;
break;
case 0x41:
/* Windows time stamp (FILETIME structure) */
- skip_bytes(header_size - n); /* ignored */
+ /* it is time in 100 nano seconds since 1601-01-01 00:00:00 */
+
+ skip_bytes(8); /* create time is ignored */
+
+ /* set last modified time */
+ if (hdr->header_level >= 2)
+ skip_bytes(8); /* time_t has been already set */
+ else
+ hdr->unix_last_modified_stamp = wintime_to_unix_stamp();
+
+ skip_bytes(8); /* last access time is ignored */
+
break;
case 0x50:
/* UNIX permission */