CHECK_FUNCTION_EXISTS_GLIBC(chflags HAVE_CHFLAGS)
CHECK_FUNCTION_EXISTS_GLIBC(chown HAVE_CHOWN)
CHECK_FUNCTION_EXISTS_GLIBC(chroot HAVE_CHROOT)
+CHECK_FUNCTION_EXISTS_GLIBC(ctime_r HAVE_CTIME_R)
CHECK_FUNCTION_EXISTS_GLIBC(fchdir HAVE_FCHDIR)
CHECK_FUNCTION_EXISTS_GLIBC(fchflags HAVE_FCHFLAGS)
CHECK_FUNCTION_EXISTS_GLIBC(fchmod HAVE_FCHMOD)
CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY)
CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN)
CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB)
-CHECK_FUNCTION_EXISTS_GLIBC(_localtime64_s HAVE_LOCALTIME64_S)
+CHECK_FUNCTION_EXISTS_GLIBC(_ctime64_s HAVE__CTIME64_S)
+CHECK_FUNCTION_EXISTS_GLIBC(_get_timezone HAVE__GET_TIMEZONE)
+CHECK_FUNCTION_EXISTS_GLIBC(_localtime64_s HAVE__LOCALTIME64_S)
CHECK_FUNCTION_EXISTS_GLIBC(_mkgmtime64 HAVE__MKGMTIME64)
CHECK_SYMBOL_EXISTS(wmemcmp "wchar.h" HAVE_WMEMCMP)
CHECK_SYMBOL_EXISTS(wmemcpy "wchar.h" HAVE_WMEMCPY)
/* Define to 1 if you have the `CreateHardLinkW' function. */
#cmakedefine HAVE_CREATEHARDLINKW 1
+/* Define to 1 if you have the `ctime_r' function. */
+#cmakedefine HAVE_CTIME_R 1
+
/* Define to 1 if you have the <ctype.h> header file. */
#cmakedefine HAVE_CTYPE_H 1
/* Define to 1 if you have the <zlib.h> header file. */
#cmakedefine HAVE_ZLIB_H 1
+/* Define to 1 if you have the `_ctime64_s' function. */
+#cmakedefine HAVE__CTIME64_S 1
+
+/* Define to 1 if you have the `_get_timezone' function. */
+#cmakedefine HAVE__GET_TIMEZONE 1
+
/* Define to 1 if you have the `_localtime64_s' function. */
#cmakedefine HAVE__LOCALTIME64_S 1
{
long offset;
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(HAVE__GET_TIMEZONE)
_get_timezone(&offset);
-#elif defined(__CYGWIN__)
+#elif defined(__CYGWIN__) || defined(__MINGW32__)
offset = _timezone;
#else
offset = timezone;
}
#endif
+static void
+get_tmfromtime(struct tm *tm, time_t *t)
+{
+#if HAVE_LOCALTIME_R
+ tzset();
+ localtime_r(t, tm);
+#elif HAVE__LOCALTIME64_S
+ _localtime64_s(tm, t);
+#else
+ memcpy(tm, localtime(t), sizeof(*tm));
+#endif
+}
+
/*
* Date and Time Format.
* ISO9660 Standard 8.4.26.1
{
struct tm tm;
-#if HAVE_LOCALTIME_R
- tzset();
- localtime_r(&t, &tm);
-#elif HAVE__LOCALTIME64_S
- _localtime64_s(&tm, &t)
-#else
- memcpy(&tm, localtime(&t), sizeof(tm));
-#endif
+ get_tmfromtime(&tm, &t);
set_digit(p, 4, tm.tm_year + 1900);
set_digit(p+4, 2, tm.tm_mon + 1);
set_digit(p+6, 2, tm.tm_mday);
{
struct tm tm;
-#if HAVE_LOCALTIME_R
- tzset();
- localtime_r(&t, &tm);
-#elif HAVE__LOCALTIME64_S
- _localtime64_s(&tm, &t)
-#else
- memcpy(&tm, localtime(&t), sizeof(tm));
-#endif
+ get_tmfromtime(&tm, &t);
set_num_711(p+0, tm.tm_year);
set_num_711(p+1, tm.tm_mon+1);
set_num_711(p+2, tm.tm_mday);
}
memset(info.s, 0, info_size);
opt = 0;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- ctime_s(buf, sizeof(buf), &(iso9660->birth_time));
-#else
+#if defined(HAVE__CTIME64_S)
+ _ctime64_s(buf, sizeof(buf), &(iso9660->birth_time));
+#elif defined(HAVE_CTIME_R)
ctime_r(&(iso9660->birth_time), buf);
+#else
+ strncpy(buf, ctime(&(iso9660->birth_time)), sizeof(buf)-1);
+ buf[sizeof(buf)-1] = '\0';
#endif
archive_string_sprintf(&info,
"INFO %s%s", buf, archive_version_string());
if (rs <= 0) {
archive_set_error(&a->archive,
errno,
- "Can't read temporary file(%zd)",
- rs);
+ "Can't read temporary file(%jd)",
+ (intmax_t)rs);
return (ARCHIVE_FATAL);
}
size -= rs;
rs = read(np->file->temp_fd, wb, rsize);
if (rs <= 0) {
archive_set_error(&a->archive, errno,
- "Can't read temporary file(%zd)", rs);
+ "Can't read temporary file(%jd)",
+ (intmax_t)rs);
return (ARCHIVE_FATAL);
}
size -= rs;
rs = read(np->file->temp_fd, iso9660->wbuff, rsize);
if (rs <= 0) {
archive_set_error(&a->archive, errno,
- "Can't read temporary file(%zd)", rs);
+ "Can't read temporary file(%jd)",
+ (intmax_t)rs);
return (ARCHIVE_FATAL);
}
for (i = 0; i < rs; i += 4)