* configure.ac: Check for timegm.

* mkerrors: Prettier error formating for gpg-error style codes.

* conversion.c (_gpgme_parse_timestamp): New.  Now also handles ISO
8601 timestamps as used by gnupg 1.9.2.
* keylist.c (parse_timestamp): Removed.  Replaced calls by
_gpgme_parse_timestamp.
* verify.c (_gpgme_verify_status_handler): Replaced strtoul by
_gpgme_parse_timestamp.
* sign.c (append_xml_siginfo): Ditto.
This commit is contained in:
Werner Koch 2003-11-18 17:29:19 +00:00
parent 43961ac064
commit b440942f16
12 changed files with 113 additions and 22 deletions

View File

@ -1,3 +1,7 @@
2003-11-18 Werner Koch <wk@gnupg.org>
* configure.ac: Check for timegm.
2003-02-18 Marcus Brinkmann <marcus@g10code.de>
Released 0.3.15.

5
NEWS
View File

@ -1,3 +1,8 @@
Noteworthy changes in version 0.3.16
-------------------------------------------------
* Compatibility fixes for GnuPG 1.9.
Noteworthy changes in version 0.3.15 (2003-02-18)
-------------------------------------------------

View File

@ -1,3 +1,7 @@
2003-11-18 Werner Koch <wk@gnupg.org>
* mkerrors: Prettier error formating for gpg-error style codes.
2002-05-03 Werner Koch <wk@gnupg.org>
* assuan-pipe-connect.c (assuan_pipe_connect2): New to extend

View File

@ -40,7 +40,7 @@ const char *
assuan_strerror (AssuanError err)
{
const char *s;
static char buf[25];
static char buf[50];
switch (err)
{
@ -62,7 +62,18 @@ printf "%s\"; break;\n", tolower(substr(s,8));
'
cat <<EOF
default: sprintf (buf, "ec=%d", err ); s=buf; break;
default:
{
unsigned int source, code;
source = ((err >> 24) & 0xff);
code = (err & 0x00ffffff);
if (source) /* Assume this is an libgpg-error. */
sprintf (buf, "ec=%u.%u", source, code );
else
sprintf (buf, "ec=%d", err );
s=buf; break;
}
}
return s;

View File

@ -154,6 +154,8 @@ fi
dnl
dnl Checks for library functions.
dnl
AC_CHECK_FUNCS(timegm)
AC_REPLACE_FUNCS(stpcpy)

View File

@ -1,3 +1,13 @@
2003-11-18 Werner Koch <wk@gnupg.org>
* conversion.c (_gpgme_parse_timestamp): New. Now also handles ISO
8601 timestamps as used by gnupg 1.9.2.
* keylist.c (parse_timestamp): Removed. Replaced calls by
_gpgme_parse_timestamp.
* verify.c (_gpgme_verify_status_handler): Replaced strtoul by
_gpgme_parse_timestamp.
* sign.c (append_xml_siginfo): Ditto.
2003-02-18 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_op_sign): Call

View File

@ -1,6 +1,6 @@
/* conversion.c - String conversion helper functions.
* Copyright (C) 2000 Werner Koch (dd9jn)
* Copyright (C) 2001, 2002 g10 Code GmbH
* Copyright (C) 2001, 2002, 2003 g10 Code GmbH
*
* This file is part of GPGME.
*
@ -23,11 +23,17 @@
#include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "gpgme.h"
#include "util.h"
#define atoi_1(p) (*(p) - '0' )
#define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1))
#define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2))
int
_gpgme_hextobyte (const byte *str)
@ -138,3 +144,56 @@ _gpgme_decode_c_string (const char *src, char **destp)
return 0;
}
time_t
_gpgme_parse_timestamp (const char *timestamp)
{
/* Need toskip leading spaces, becuase that is what strtoul does but
not our ISO 8601 checking code. */
while (*timestamp && *timestamp== ' ')
timestamp++;
if (!*timestamp)
return 0;
if (strlen (timestamp) >= 15 && timestamp[8] == 'T')
{
struct tm buf;
int year;
year = atoi_4 (timestamp);
if (year < 1900)
return (time_t)(-1);
/* Fixme: We would better use a configure test to see whether
mktime can handle dates beyond 2038. */
if (sizeof (time_t) <= 4 && year >= 2038)
return (time_t)2145914603; /* 2037-12-31 23:23:23 */
memset (&buf, 0, sizeof buf);
buf.tm_year = year - 1900;
buf.tm_mon = atoi_2 (timestamp+4) - 1;
buf.tm_mday = atoi_2 (timestamp+6);
buf.tm_hour = atoi_2 (timestamp+9);
buf.tm_min = atoi_2 (timestamp+11);
buf.tm_sec = atoi_2 (timestamp+13);
#ifdef HAVE_TIMEGM
return timegm (&buf);
#else
{
time_t tim;
putenv ("TZ=UTC");
tim = mktime (&buf);
#ifdef __GNUC__
#warning fixme: we must somehow reset TZ here. It is not threadsafe anyway.
#endif
return tim;
}
#endif /* !HAVE_TIMEGM */
}
else
return (time_t)strtoul (timestamp, NULL, 10);
}

View File

@ -44,7 +44,7 @@ extern "C" {
AM_PATH_GPGME macro) check that this header matches the installed
library. Warning: Do not edit the next line. configure will do
that for you! */
#define GPGME_VERSION "0.3.15"
#define GPGME_VERSION "0.3.16-cvs"
/* The opaque data types used by GPGME. */

View File

@ -1,6 +1,6 @@
/* keylist.c - key listing
* Copyright (C) 2000 Werner Koch (dd9jn)
* Copyright (C) 2001, 2002 g10 Code GmbH
* Copyright (C) 2001, 2002, 2003 g10 Code GmbH
*
* This file is part of GPGME.
*
@ -118,16 +118,6 @@ keylist_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
}
static time_t
parse_timestamp (char *p)
{
if (!*p)
return 0;
return (time_t)strtoul (p, NULL, 10);
}
static void
set_mainkey_trust_info (GpgmeKey key, const char *s)
{
@ -389,10 +379,10 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
strcpy (key->keys.keyid, p);
break;
case 6: /* timestamp (seconds) */
key->keys.timestamp = parse_timestamp (p);
key->keys.timestamp = _gpgme_parse_timestamp (p);
break;
case 7: /* expiration time (seconds) */
key->keys.expires_at = parse_timestamp (p);
key->keys.expires_at = _gpgme_parse_timestamp (p);
break;
case 8: /* X.509 serial number */
if (rectype == RT_CRT || rectype == RT_CRS)
@ -444,10 +434,10 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
strcpy (sk->keyid, p);
break;
case 6: /* timestamp (seconds) */
sk->timestamp = parse_timestamp (p);
sk->timestamp = _gpgme_parse_timestamp (p);
break;
case 7: /* expiration time (seconds) */
sk->expires_at = parse_timestamp (p);
sk->expires_at = _gpgme_parse_timestamp (p);
break;
case 8: /* reserved (LID) */
break;

View File

@ -122,7 +122,7 @@ append_xml_siginfo (GpgmeData *rdh, char *args)
_gpgme_data_append_string (dh, helpbuf);
SKIP_TOKEN_OR_RETURN (args);
ul = strtoul (args, NULL, 10);
ul = _gpgme_parse_timestamp (args);
sprintf (helpbuf, " <created>%lu</created>\n", ul);
_gpgme_data_append_string (dh, helpbuf);
SKIP_TOKEN_OR_RETURN (args);

View File

@ -100,5 +100,6 @@ FILE *fopencookie (void *cookie, const char *opentype,
/*-- conversion.c --*/
GpgmeError _gpgme_decode_c_string (const char *src, char **destp);
int _gpgme_hextobyte (const byte *str);
time_t _gpgme_parse_timestamp (const char *p);
#endif /* UTIL_H */

View File

@ -251,9 +251,14 @@ _gpgme_verify_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
while (args[i] && args[i] != ' ')
i++;
/* And get the timestamp. */
ctx->result.verify->timestamp = strtoul (args+i, &p, 10);
ctx->result.verify->timestamp = _gpgme_parse_timestamp (args+i);
if (args[i])
ctx->result.verify->exptimestamp = strtoul (p, NULL, 10);
{
/* Skip that timestamp. */
while (args[i] && args[i] != ' ')
i++;
ctx->result.verify->exptimestamp = _gpgme_parse_timestamp (args+i);
}
break;
case GPGME_STATUS_BADSIG: