time_t mtime;
char date[32];
char date2[32];
+ struct tm *tmptr;
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
+ struct tm tmbuf;
+#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
/* List reference archive, make sure the TOC is correct. */
extract_reference_file("test_option_t.cpio");
#ifdef HAVE_LOCALE_H
setlocale(LC_ALL, "");
#endif
+#if defined(HAVE_LOCALTIME_R)
+ tmptr = localtime_r(&mtime, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = mtime;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ tmptr = NULL;
+ else
+ tmptr = &tmbuf;
+#else
+ tmptr = localtime(&mtime);
+#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
- strftime(date2, sizeof(date2)-1, "%b %d %Y", localtime(&mtime));
+ strftime(date2, sizeof(date2)-1, "%b %d %Y", tmptr);
_snprintf(date, sizeof(date)-1, "%12.12s file", date2);
#else
- strftime(date2, sizeof(date2)-1, "%b %e %Y", localtime(&mtime));
+ strftime(date2, sizeof(date2)-1, "%b %e %Y", tmptr);
snprintf(date, sizeof(date)-1, "%12.12s file", date2);
#endif
assertEqualMem(p + 42, date, strlen(date));
/* Misc variables */
unsigned long crc;
- struct tm *tm = localtime(&now);
-
+ struct tm *tm;
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
+ struct tm tmbuf;
+#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
/* p is the pointer to walk over the central directory,
* q walks over the local headers, the data and the data descriptors. */
const char *p, *q, *local_header, *extra_start;
+#if defined(HAVE_LOCALTIME_R)
+ tm = localtime_r(&now, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = now;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ tm = NULL;
+ else
+ tm = &tmbuf;
+#else
+ tm = localtime(&now);
+#endif
+
/* Remember the end of the archive in memory. */
buffend = buff + used;
struct archive *a;
struct archive_entry *ae;
time_t t = 1234567890;
- struct tm *tm = localtime(&t);
+ struct tm *tm;
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
+ struct tm tmbuf;
+#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
size_t used, buffsize = 1000000;
unsigned long crc;
int file_perm = 00644;
zip_compression = 0;
#endif
+#if defined(HAVE_LOCALTIME_R)
+ tm = localtime_r(&t, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = t;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ tm = NULL;
+ else
+ tm = &tmbuf;
+#else
+ tm = localtime(&t);
+#endif
buff = malloc(buffsize);
/* Create a new archive in memory. */
struct archive *a;
struct archive_entry *ae;
time_t t = 1234567890;
- struct tm *tm = localtime(&t);
+ struct tm *tm;
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
+ struct tm tmbuf;
+#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
size_t used, buffsize = 1000000;
unsigned long crc;
int file_perm = 00644;
zip_compression = 0;
#endif
+#if defined(HAVE_LOCALTIME_R)
+ tm = localtime_r(&t, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = t;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ tm = NULL;
+ else
+ tm = &tmbuf;
+#else
+ tm = localtime(&t);
+#endif
buff = malloc(buffsize);
/* Create a new archive in memory. */
int tmp2_len;
#endif
time_t now;
+ struct tm *tmptr;
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
+ struct tm tmbuf;
+#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
char *refdir_alloc = NULL;
const char *progname;
char **saved_argv;
*/
now = time(NULL);
for (i = 0; ; i++) {
+#if defined(HAVE_LOCALTIME_R)
+ tmptr = localtime_r(&now, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = now;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ tmptr = NULL;
+ else
+ tmptr = &tmbuf;
+#else
+ tmptr = localtime(&now);
+#endif
strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp),
- "%Y-%m-%dT%H.%M.%S",
- localtime(&now));
+ "%Y-%m-%dT%H.%M.%S", tmptr);
if ((strlen(tmp) + 1 + strlen(progname) + 1 +
strlen(tmpdir_timestamp) + 1 + 3) >
(sizeof(tmpdir) / sizeof(char))) {