summaryrefslogtreecommitdiffstats
path: root/common/mischelp.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 21:21:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 21:21:03 +0000
commit3675f65888fde5fddde20ff811638a338bf08ca6 (patch)
tree065688bbb6355a8a4784ec9c8e112cec342eac5e /common/mischelp.c
parentAdding upstream version 2.2.40. (diff)
downloadgnupg2-3675f65888fde5fddde20ff811638a338bf08ca6.tar.xz
gnupg2-3675f65888fde5fddde20ff811638a338bf08ca6.zip
Adding upstream version 2.2.43.upstream/2.2.43upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'common/mischelp.c')
-rw-r--r--common/mischelp.c77
1 files changed, 0 insertions, 77 deletions
diff --git a/common/mischelp.c b/common/mischelp.c
index ee85002..ef70c9d 100644
--- a/common/mischelp.c
+++ b/common/mischelp.c
@@ -126,80 +126,3 @@ same_file_p (const char *name1, const char *name2)
}
return yes;
}
-
-
-/*
- timegm() is a GNU function that might not be available everywhere.
- It's basically the inverse of gmtime() - you give it a struct tm,
- and get back a time_t. It differs from mktime() in that it handles
- the case where the struct tm is UTC and the local environment isn't.
-
- Note, that this replacement implementation might not be thread-safe!
-
- Some BSDs don't handle the putenv("foo") case properly, so we use
- unsetenv if the platform has it to remove environment variables.
-*/
-#ifndef HAVE_TIMEGM
-time_t
-timegm (struct tm *tm)
-{
-#ifdef HAVE_W32_SYSTEM
- /* This one is thread safe. */
- SYSTEMTIME st;
- FILETIME ft;
- unsigned long long cnsecs;
-
- st.wYear = tm->tm_year + 1900;
- st.wMonth = tm->tm_mon + 1;
- st.wDay = tm->tm_mday;
- st.wHour = tm->tm_hour;
- st.wMinute = tm->tm_min;
- st.wSecond = tm->tm_sec;
- st.wMilliseconds = 0; /* Not available. */
- st.wDayOfWeek = 0; /* Ignored. */
-
- /* System time is UTC thus the conversion is pretty easy. */
- if (!SystemTimeToFileTime (&st, &ft))
- {
- gpg_err_set_errno (EINVAL);
- return (time_t)(-1);
- }
-
- cnsecs = (((unsigned long long)ft.dwHighDateTime << 32)
- | ft.dwLowDateTime);
- cnsecs -= 116444736000000000ULL; /* The filetime epoch is 1601-01-01. */
- return (time_t)(cnsecs / 10000000ULL);
-
-#else /* (Non thread safe implementation!) */
-
- time_t answer;
- char *zone;
-
- zone=getenv("TZ");
- putenv("TZ=UTC");
- tzset();
- answer=mktime(tm);
- if(zone)
- {
- static char *old_zone;
-
- if (!old_zone)
- {
- old_zone = malloc(3+strlen(zone)+1);
- if (old_zone)
- {
- strcpy(old_zone,"TZ=");
- strcat(old_zone,zone);
- }
- }
- if (old_zone)
- putenv (old_zone);
- }
- else
- gnupg_unsetenv("TZ");
-
- tzset();
- return answer;
-#endif
-}
-#endif /*!HAVE_TIMEGM*/