* gpgsm/t-keylist.c (doit): Print operation info if available.
gpgme/
* keylist.c (struct keylist_result_s): New.
(_gpgme_release_keylist_result): Release it here
(keylist_status_handler): Handle truncated.
(append_xml_keylistinfo): New.
* gpgme.c (_gpgme_release_result): and use it here.
* types.h: Declare the new type here.
* context.h (struct gpgme_context_s): Use it here.
@item GPGME_ATTR_SIG_STATUS
This is the same value as returned by @code{gpgme_get_sig_status}.
+@item GPGME_ATTR_SIG_SUMMARY
+This returns a bit vector giving a summary of the signature status.
+Itprovides an easy interface to a defined semantic of the signature
+status. Checking just one bit is sufficient to see whether a signature
+is valid without any restrictions.
+
+The defined bits are:
+ @table @code
+ @item GPGME_SIGSUM_VALID
+ The signature is fully valid.
+
+ @item GPGME_SIGSUM_GREEN
+ The signature is good but one might want to display some extra
+ information. Check the other bits.
+
+ @item GPGME_SIGSUM_RED
+ The signature is bad. It might be useful to checkother bits and
+ display moe information, i.e. a revoked certificate might not render a
+ signature invalid when the message was received prior to the cause for
+ the revocation.
+
+ @item GPGME_SIGSUM_KEY_REVOKED
+ The key or at least one certificate has been revoked.
+
+ @item GPGME_SIGSUM_KEY_EXPIRED
+ The key or one of the certificates has expired. It is probably a good
+ idea to display the date of the expiration.
+
+ @item GPGME_SIGSUM_SIG_EXPIRED
+ The signature has expired.
+
+ @item GPGME_SIGSUM_KEY_MISSING
+ Can't verifydue to a missing key o certificate.
+
+ @item GPGME_SIGSUM_CRL_MISSING
+ The CRL (or an equivalent mechanism) is not available.
+
+ @item GPGME_SIGSUM_CRL_TOO_OLD
+ Available CRL is too old.
+
+ @item GPGME_SIGSUM_BAD_POLICY
+ A policy requirement was not met.
+
+ @item GPGME_SIGSUM_SYS_ERROR
+ A system error occured.
+
+ @end table
+
@end table
@end deftypefun
+2002-06-12 Werner Koch <wk@gnupg.org>
+
+ * keylist.c (struct keylist_result_s): New.
+ (_gpgme_release_keylist_result): Release it here
+ (keylist_status_handler): Handle truncated.
+ (append_xml_keylistinfo): New.
+ * gpgme.c (_gpgme_release_result): and use it here.
+ * types.h: Declare the new type here.
+ * context.h (struct gpgme_context_s): Use it here.
+
2002-06-11 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_release): Close status_cb.fd.
ImportResult import;
DeleteResult delete;
GenKeyResult genkey;
+ KeylistResult keylist;
} result;
/* Last signature notation. */
_gpgme_release_import_result (ctx->result.import);
_gpgme_release_delete_result (ctx->result.delete);
_gpgme_release_genkey_result (ctx->result.genkey);
+ _gpgme_release_keylist_result (ctx->result.keylist);
memset (&ctx->result, 0, sizeof (ctx->result));
_gpgme_set_op_info (ctx, NULL);
ctx->error = 0;
#define my_isdigit(a) ( (a) >='0' && (a) <= '9' )
+struct keylist_result_s
+{
+ int truncated;
+ GpgmeData xmlinfo;
+};
+
static void finish_key ( GpgmeCtx ctx );
+void
+_gpgme_release_keylist_result (KeylistResult result)
+{
+ if (!result)
+ return;
+ xfree (result);
+}
+
+/* Append some XML info. args is currently ignore but we might want
+ to add more information in the future (like source of the
+ keylisting. With args of NULL the XML structure is closed. */
+static void
+append_xml_keylistinfo (GpgmeData *rdh, char *args)
+{
+ GpgmeData dh;
+
+ if (!*rdh)
+ {
+ if (gpgme_data_new (rdh))
+ return; /* FIXME: We are ignoring out-of-core. */
+ dh = *rdh;
+ _gpgme_data_append_string (dh, "<GnupgOperationInfo>\n");
+ }
+ else
+ {
+ dh = *rdh;
+ _gpgme_data_append_string (dh, " </keylisting>\n");
+ }
+
+ if (!args)
+ {
+ /* Just close the XML containter. */
+ _gpgme_data_append_string (dh, "</GnupgOperationInfo>\n");
+ return;
+ }
+
+ _gpgme_data_append_string (dh,
+ " <keylisting>\n"
+ " <truncated/>\n"
+ );
+
+}
+
+
+
static void
keylist_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
{
if (ctx->error)
return;
+ test_and_allocate_result (ctx, keylist);
switch (code)
{
+ case STATUS_TRUNCATED:
+ ctx->result.keylist->truncated = 1;
+ break;
+
case STATUS_EOF:
finish_key (ctx);
+ if (ctx->result.keylist->truncated)
+ append_xml_keylistinfo (&ctx->result.keylist->xmlinfo, "1");
+ if (ctx->result.keylist->xmlinfo)
+ {
+ append_xml_keylistinfo (&ctx->result.keylist->xmlinfo, NULL);
+ _gpgme_set_op_info (ctx, ctx->result.keylist->xmlinfo);
+ ctx->result.keylist->xmlinfo = NULL;
+ }
break;
default:
/*-- genkey.c --*/
void _gpgme_release_genkey_result (GenKeyResult res);
+/*-- keylist.c --*/
+void _gpgme_release_keylist_result (KeylistResult res);
+
/*-- version.c --*/
const char *_gpgme_compare_versions (const char *my_version,
const char *req_version);
struct genkey_result_s;
typedef struct genkey_result_s *GenKeyResult;
+/*-- keylist.c --*/
+struct keylist_result_s;
+typedef struct keylist_result_s *KeylistResult;
+
#endif /* TYPES_H */
for (i = 1; i < length && *s && *s != ' ' ; i++)
*p++ = *s++;
*p = 0;
- /* conmtinue scanning in case the copy was truncated */
+ /* continue scanning in case the copy was truncated */
while (*s && *s != ' ')
s++;
return s - string;
else if (result->status == GPGME_SIG_STAT_ERROR)
sum |= GPGME_SIGSUM_SYS_ERROR;
- /* FIXME: Set GPGME_SIGSUM_KEY_REVOKED. */
- /* FIXME: Set GPGME_SIGSUM_CRL_MISSING. */
- /* FIXME: Set GPGME_SIGSUM_CRL_TOO_OLD. */
- /* FIXME: Set GPGME_SIGSUM_BAD_POLICY. */
+ if ( !strcmp (result->trust_errtok, "Certificate_Revoked"))
+ sum |= GPGME_SIGSUM_KEY_REVOKED;
+ else if ( !strcmp (result->trust_errtok, "No_CRL_Known"))
+ sum |= GPGME_SIGSUM_CRL_MISSING;
+ else if ( !strcmp (result->trust_errtok, "CRL_Too_Old"))
+ sum |= GPGME_SIGSUM_CRL_TOO_OLD;
+ else if ( !strcmp (result->trust_errtok, "No_Policy_Match"))
+ sum |= GPGME_SIGSUM_BAD_POLICY;
+ else if (*result->trust_errtok)
+ sum |= GPGME_SIGSUM_SYS_ERROR;
- /* That the valid flag when the signature is unquestionable
+ /* Set the valid flag when the signature is unquestionable
valid. */
if ((sum & GPGME_SIGSUM_GREEN) && !(sum & ~GPGME_SIGSUM_GREEN))
sum |= GPGME_SIGSUM_VALID;
+2002-06-12 Werner Koch <wk@gnupg.org>
+
+ * gpgsm/t-keylist.c (doit): Print operation info if available.
+
2002-06-10 Werner Koch <wk@gnupg.org>
* gpgsm/t-verify.c (print_sig_stat): Print the error token.
}
if ( err != GPGME_EOF )
fail_if_err (err);
+
+ {
+ char *p;
+
+ p = gpgme_get_op_info (ctx, 0);
+ if (p)
+ {
+ fputs ("<!-- begin operation info -->\n", stdout);
+ fputs (p, stdout);
+ fputs ("<!-- end operation info -->\n", stdout);
+ free (p);
+ }
+ }
}
static void
print_sig_stat ( GpgmeCtx ctx, GpgmeSigStat status )
{
- const char *s;
- time_t created;
- int idx;
- GpgmeKey key;
-
- printf ("Verification Status: %s\n", status_string (status));
+ const char *s;
+ time_t created;
+ int idx;
+ GpgmeKey key;
+
+ printf ("Verification Status: %s\n", status_string (status));
- for(idx=0; (s=gpgme_get_sig_status (ctx, idx, &status, &created)); idx++ ) {
- printf ("sig %d: created: %lu expires: %lu status: %s\n",
- idx, (unsigned long)created,
- gpgme_get_sig_ulong_attr (ctx, idx, GPGME_ATTR_EXPIRE, 0),
- status_string(status) );
- printf ("sig %d: fpr/keyid: `%s' exterr: `%s' validity: %s\n",
- idx, s,
+ for (idx=0; (s=gpgme_get_sig_status (ctx, idx, &status, &created)); idx++ )
+ {
+ unsigned long sum;
+
+ printf ("sig %d: created: %lu expires: %lu status: %s\n",
+ idx, (unsigned long)created,
+ gpgme_get_sig_ulong_attr (ctx, idx, GPGME_ATTR_EXPIRE, 0),
+ status_string(status) );
+ printf ("sig %d: fpr/keyid: `%s' exterr: `%s' validity: %s\n",
+ idx, s,
gpgme_get_sig_string_attr (ctx, idx, GPGME_ATTR_ERRTOK, 0),
- validity_string (gpgme_get_sig_ulong_attr
- (ctx, idx, GPGME_ATTR_VALIDITY, 0)) );
- if ( !gpgme_get_sig_key (ctx, idx, &key) ) {
- char *p = gpgme_key_get_as_xml ( key );
- printf ("sig %d: key object:\n%s\n", idx, p );
- free (p);
- gpgme_key_release (key);
- }
+ validity_string (gpgme_get_sig_ulong_attr
+ (ctx, idx, GPGME_ATTR_VALIDITY, 0)) );
+
+ sum = gpgme_get_sig_ulong_attr (ctx, idx, GPGME_ATTR_SIG_SUMMARY, 0);
+ fputs ("summary:", stdout);
+ if ((sum & GPGME_SIGSUM_VALID))
+ fputs (" valid", stdout);
+ if ((sum & GPGME_SIGSUM_GREEN))
+ fputs (" green", stdout);
+ if ((sum & GPGME_SIGSUM_RED))
+ fputs (" red", stdout);
+ if ((sum & GPGME_SIGSUM_KEY_REVOKED))
+ fputs (" keyRevoked", stdout);
+ if ((sum & GPGME_SIGSUM_KEY_EXPIRED))
+ fputs (" keyExpired", stdout);
+ if ((sum & GPGME_SIGSUM_SIG_EXPIRED))
+ fputs (" sigExpired", stdout);
+ if ((sum & GPGME_SIGSUM_KEY_MISSING))
+ fputs (" keyMissing", stdout);
+ if ((sum & GPGME_SIGSUM_CRL_MISSING))
+ fputs (" crlMissing", stdout);
+ if ((sum & GPGME_SIGSUM_CRL_TOO_OLD))
+ fputs (" crlTooOld", stdout);
+ if ((sum & GPGME_SIGSUM_BAD_POLICY))
+ fputs (" badPolicy", stdout);
+ if ((sum & GPGME_SIGSUM_SYS_ERROR))
+ fputs (" sysError", stdout);
+ putchar ('\n');
+
+ if ( !gpgme_get_sig_key (ctx, idx, &key) )
+ {
+ char *p = gpgme_key_get_as_xml ( key );
+ printf ("sig %d: key object:\n%s\n", idx, p );
+ free (p);
+ gpgme_key_release (key);
+ }
}
}