Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
93e9fe33
Commit
93e9fe33
authored
Sep 17, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
__CYGWIN__ portability
parent
8dd0eedc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
41 deletions
+58
-41
ChangeLog
ChangeLog
+1
-1
skeletons/GeneralizedTime.c
skeletons/GeneralizedTime.c
+57
-40
No files found.
ChangeLog
View file @
93e9fe33
0.9.5: 2004-Sep-1
4
0.9.5: 2004-Sep-1
7
* Fixed CER (common BER) decoder code. See check-25.c/VisibleString
case for details. X.690 specifies that inner structures in BER
...
...
skeletons/GeneralizedTime.c
View file @
93e9fe33
...
...
@@ -11,8 +11,8 @@
#if defined(WIN32)
#warning PLEASE STOP AND READ!
#warning localtime_r is implemented via localtime(), which
is
not thread-safe.
#warning gmtime_r is implemented via gmtime(), which
is
not thread-safe.
#warning localtime_r is implemented via localtime(), which
may be
not thread-safe.
#warning gmtime_r is implemented via gmtime(), which
may be
not thread-safe.
#warning
#warning You must fix the code by inserting appropriate locking
#warning if you want to use asn_GT2time() or asn_UT2time().
...
...
@@ -32,39 +32,76 @@ static struct tm *gmtime_r(const time_t *tloc, struct tm *result) {
return
0
;
}
#define tzset() _tzset()
#define _EMULATE_TIMEGM
#endif
/* WIN32 */
/*
* Where to look for offset from GMT, Phase I.
* Several platforms are known.
*/
#if defined(__FreeBSD__) \
|| (defined(__GNUC__) && defined(__APPLE_CC__)) \
|| (defined __GLIBC__ && __GLIBC__ >= 2)
#undef HAVE_TM_GMTOFF
#define HAVE_TM_GMTOFF
#endif
/* BSDs and newer glibc */
/*
* Where to look for offset from GMT, Phase II.
*/
#ifdef HAVE_TM_GMTOFF
#define GMTOFF(tm) ((tm).tm_gmtoff)
#else
/* HAVE_TM_GMTOFF */
#define GMTOFF(tm) (-timezone)
#endif
/* HAVE_TM_GMTOFF */
/*
* Override our GMTOFF decision for other known platforms.
*/
#ifdef __CYGWIN__
#undef GMTOFF
static
long
GMTOFF
(
struct
tm
a
){
struct
tm
*
lt
;
time_t
local_time
,
gmt_time
;
long
zone
;
tzset
();
gmt_time
=
time
(
NULL
);
lt
=
gmtime
(
&
gmt_time
);
local_time
=
mktime
(
lt
);
return
(
gmt_time
-
local_time
);
}
#define _EMULATE_TIMEGM
#endif
/* __CYGWIN__ */
#ifdef _EMULATE_TIMEGM
static
time_t
timegm
(
struct
tm
*
tm
)
{
time_t
tloc
;
char
*
tz
;
char
*
buf
;
tz
=
getenv
(
"TZ"
);
_putenv
(
"TZ=UTC"
);
_
tzset
();
_putenv
(
"TZ=UTC"
);
tzset
();
tloc
=
mktime
(
tm
);
if
(
tz
)
{
buf
=
alloca
(
strlen
(
tz
)
+
4
);
sprintf
(
buf
,
"TZ=%s"
,
tz
);
int
bufsize
=
strlen
(
tz
)
+
4
;
buf
=
alloca
(
bufsize
);
snprintf
(
buf
,
bufsize
,
"TZ=%s"
,
tz
);
}
else
{
buf
=
"TZ="
;
}
_putenv
(
buf
);
_
tzset
();
tzset
();
return
tloc
;
}
#endif
/* _EMULATE_TIMEGM */
#if 0 /* Alternate version */
/* vlm: I am not sure about validity of this algorithm. */
static time_t timegm(struct tm *tm) {
struct tm tmp;
time_t tloc = mktime(tm);
localtime_r(&tloc, &tmp); /* Figure out our GMT offset */
tloc += tmp.tm_gmtoff;
tm->tm_zone = "GMT";
tm->tm_gmtoff = 0; /* Simulate GMT */
return tloc;
}
#endif
#endif
/* WIN32 */
#ifndef __NO_ASN_TABLE__
...
...
@@ -185,26 +222,6 @@ GeneralizedTime_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
}
}
/*
* Where to look for offset from GMT, Phase I.
* Several platforms are known.
*/
#if defined(__FreeBSD__) \
|| (defined(__GNUC__) && defined(__APPLE_CC__)) \
|| (defined __GLIBC__ && __GLIBC__ >= 2)
#undef HAVE_TM_GMTOFF
#define HAVE_TM_GMTOFF
#endif
/* BSDs and newer glibc */
/*
* Where to look for offset from GMT, Phase II.
*/
#ifdef HAVE_TM_GMTOFF
#define GMTOFF(tm) ((tm).tm_gmtoff)
#else
/* HAVE_TM_GMTOFF */
#define GMTOFF(tm) (-timezone)
#endif
/* HAVE_TM_GMTOFF */
time_t
asn_GT2time
(
const
GeneralizedTime_t
*
st
,
struct
tm
*
ret_tm
,
int
as_gmt
)
{
struct
tm
tm_s
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment