mirror of git://git.gnupg.org/gnupg.git
* util.h (gnupg_isotime_t): New.
(gnupg_copy_time): New. * gettime.c (gnupg_get_isotime): New.
This commit is contained in:
parent
71d265a684
commit
f21638c9e3
|
@ -1,3 +1,10 @@
|
||||||
|
2003-10-31 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* util.h (gnupg_isotime_t): New.
|
||||||
|
(gnupg_copy_time): New.
|
||||||
|
|
||||||
|
* gettime.c (gnupg_get_isotime): New.
|
||||||
|
|
||||||
2003-09-23 Werner Koch <wk@gnupg.org>
|
2003-09-23 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* iobuf.c (check_special_filename): Replaced is isdigit by digitp
|
* iobuf.c (check_special_filename): Replaced is isdigit by digitp
|
||||||
|
|
|
@ -46,6 +46,32 @@ gnupg_get_time ()
|
||||||
return current - timewarp;
|
return current - timewarp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Return the current time (possibly faked) in ISO format. */
|
||||||
|
void
|
||||||
|
gnupg_get_isotime (gnupg_isotime_t timebuf)
|
||||||
|
{
|
||||||
|
time_t atime = gnupg_get_time ();
|
||||||
|
|
||||||
|
if (atime < 0)
|
||||||
|
*timebuf = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct tm *tp;
|
||||||
|
#ifdef HAVE_GMTIME_R
|
||||||
|
struct tm tmbuf;
|
||||||
|
|
||||||
|
tp = gmtime_r (&atime, &tmbuf);
|
||||||
|
#else
|
||||||
|
tp = gmtime (&atime);
|
||||||
|
#endif
|
||||||
|
sprintf (timebuf,"%04d%02d%02dT%02d%02d%02d",
|
||||||
|
1900 + tp->tm_year, tp->tm_mon+1, tp->tm_mday,
|
||||||
|
tp->tm_hour, tp->tm_min, tp->tm_sec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* set the time to NEWTIME so that gnupg_get_time returns a time
|
/* set the time to NEWTIME so that gnupg_get_time returns a time
|
||||||
starting with this one. With FREEZE set to 1 the returned time
|
starting with this one. With FREEZE set to 1 the returned time
|
||||||
will never change. Just for completeness, a value of (time_t)-1
|
will never change. Just for completeness, a value of (time_t)-1
|
||||||
|
|
|
@ -51,6 +51,12 @@
|
||||||
#define xrealloc(a,b) gcry_xrealloc ((a),(b))
|
#define xrealloc(a,b) gcry_xrealloc ((a),(b))
|
||||||
#define xstrdup(a) gcry_xstrdup ((a))
|
#define xstrdup(a) gcry_xstrdup ((a))
|
||||||
|
|
||||||
|
|
||||||
|
/* A type to hold the ISO time. Note that this this is the same as
|
||||||
|
the the KSBA type ksba_isotime_t. */
|
||||||
|
typedef char gnupg_isotime_t[16];
|
||||||
|
|
||||||
|
|
||||||
/*-- maperror.c --*/
|
/*-- maperror.c --*/
|
||||||
int map_ksba_err (int err);
|
int map_ksba_err (int err);
|
||||||
int map_gcry_err (int err);
|
int map_gcry_err (int err);
|
||||||
|
@ -60,6 +66,7 @@ int map_to_assuan_status (int rc);
|
||||||
|
|
||||||
/*-- gettime.c --*/
|
/*-- gettime.c --*/
|
||||||
time_t gnupg_get_time (void);
|
time_t gnupg_get_time (void);
|
||||||
|
void gnupg_get_isotime (gnupg_isotime_t timebuf);
|
||||||
void gnupg_set_time (time_t newtime, int freeze);
|
void gnupg_set_time (time_t newtime, int freeze);
|
||||||
int gnupg_faked_time_p (void);
|
int gnupg_faked_time_p (void);
|
||||||
u32 make_timestamp (void);
|
u32 make_timestamp (void);
|
||||||
|
@ -69,6 +76,18 @@ const char *strtimevalue (u32 stamp);
|
||||||
const char *strtimestamp (u32 stamp); /* GMT */
|
const char *strtimestamp (u32 stamp); /* GMT */
|
||||||
const char *asctimestamp (u32 stamp); /* localized */
|
const char *asctimestamp (u32 stamp); /* localized */
|
||||||
|
|
||||||
|
|
||||||
|
/* Copy one iso ddate to another, this is inline so that we can do a
|
||||||
|
sanity check. */
|
||||||
|
static inline void
|
||||||
|
gnupg_copy_time (gnupg_isotime_t d, const gnupg_isotime_t s)
|
||||||
|
{
|
||||||
|
if (*s && (strlen (s) != 15 || s[8] != 'T'))
|
||||||
|
BUG();
|
||||||
|
strcpy (d, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-- signal.c --*/
|
/*-- signal.c --*/
|
||||||
void gnupg_init_signals (int mode, void (*fast_cleanup)(void));
|
void gnupg_init_signals (int mode, void (*fast_cleanup)(void));
|
||||||
void gnupg_pause_on_sigusr (int which);
|
void gnupg_pause_on_sigusr (int which);
|
||||||
|
|
Loading…
Reference in New Issue