From aede7659c64800b89163a3fff6d2930ea0983883 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 20 Aug 2002 13:38:40 +0000 Subject: [PATCH] doc/ 2002-08-20 Marcus Brinkmann * gpgme.texi (Importing Keys): Document gpgme_op_import_ext. gpgme/ 2002-08-20 Marcus Brinkmann * gpgme.h: Add prototype for gpgme_op_import_ext. * import.c (struct import_result_s): New member `nr_considered'. Rename `any_imported' to `nr_imported'. (import_status_handler): Increment nr_imported. Set nr_considered if appropriate. (gpgme_op_import_ext): New function. (gpgme_op_import): Implement in terms of gpgme_op_import_ext. --- trunk/doc/ChangeLog | 4 ++++ trunk/doc/gpgme.texi | 7 +++++++ trunk/gpgme/ChangeLog | 10 ++++++++++ trunk/gpgme/gpgme.h | 1 + trunk/gpgme/import.c | 27 ++++++++++++++++++++++----- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/trunk/doc/ChangeLog b/trunk/doc/ChangeLog index 30d81ed..aa45097 100644 --- a/trunk/doc/ChangeLog +++ b/trunk/doc/ChangeLog @@ -1,3 +1,7 @@ +2002-08-20 Marcus Brinkmann + + * gpgme.texi (Importing Keys): Document gpgme_op_import_ext. + 2002-08-14 Werner Koch * gpgme.texi (Information About Keys): Changed GPGME_ATTR_TYPE. diff --git a/trunk/doc/gpgme.texi b/trunk/doc/gpgme.texi index a408f8f..904160a 100644 --- a/trunk/doc/gpgme.texi +++ b/trunk/doc/gpgme.texi @@ -1932,6 +1932,13 @@ started successfully, @code{GPGME_Invalid_Value} if @var{keydata} if @code{GPGME_No_Data} if @var{keydata} is an empty data buffer. @end deftypefun +@deftypefun GpgmeError gpgme_op_import_ext (@w{GpgmeCtx @var{ctx}}, @w{GpgmeData @var{keydata}}, @w{int *@var{nr}}) +The function @code{gpgme_op_import_ext} is like +@code{gpgme_op_import}, but also returns the number of processed keys +in @var{nr}. This is the same as the @code{count} information in the +detailed results available with @code{gpgme_get_op_info}. +@end deftypefun + @node Deleting Keys @subsection Deleting Keys diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 2e6f116..2a2de06 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,13 @@ +2002-08-20 Marcus Brinkmann + + * gpgme.h: Add prototype for gpgme_op_import_ext. + * import.c (struct import_result_s): New member `nr_considered'. + Rename `any_imported' to `nr_imported'. + (import_status_handler): Increment nr_imported. Set nr_considered + if appropriate. + (gpgme_op_import_ext): New function. + (gpgme_op_import): Implement in terms of gpgme_op_import_ext. + 2002-08-20 Werner Koch * vasprintf.c (int_vasprintf): Hack to handle NULL passed for %s. diff --git a/trunk/gpgme/gpgme.h b/trunk/gpgme/gpgme.h index 826375e..ed82ecf 100644 --- a/trunk/gpgme/gpgme.h +++ b/trunk/gpgme/gpgme.h @@ -663,6 +663,7 @@ GpgmeError gpgme_op_verify (GpgmeCtx ctx, /* Import the key in KEYDATA into the keyring. */ GpgmeError gpgme_op_import_start (GpgmeCtx ctx, GpgmeData keydata); GpgmeError gpgme_op_import (GpgmeCtx ctx, GpgmeData keydata); +GpgmeError gpgme_op_import_ext (GpgmeCtx ctx, GpgmeData keydata, int *nr); /* Export the keys listed in RECP into KEYDATA. */ GpgmeError gpgme_op_export_start (GpgmeCtx ctx, GpgmeRecipients recp, diff --git a/trunk/gpgme/import.c b/trunk/gpgme/import.c index e157363..a550f86 100644 --- a/trunk/gpgme/import.c +++ b/trunk/gpgme/import.c @@ -32,7 +32,8 @@ struct import_result_s { - int any_imported; + int nr_imported; + int nr_considered; GpgmeData xmlinfo; }; @@ -160,8 +161,12 @@ import_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) break; case GPGME_STATUS_IMPORTED: - ctx->result.import->any_imported = 1; + ctx->result.import->nr_imported++; + append_xml_impinfo (&ctx->result.import->xmlinfo, code, args); + break; + case GPGME_STATUS_IMPORT_RES: + ctx->result.import->nr_considered = strtol (args, 0, 0); append_xml_impinfo (&ctx->result.import->xmlinfo, code, args); break; @@ -217,19 +222,31 @@ gpgme_op_import_start (GpgmeCtx ctx, GpgmeData keydata) * gpgme_op_import: * @c: Context * @keydata: Data object + * @nr: Will contain number of considered keys. * * Import all key material from @keydata into the key database. * * Return value: 0 on success or an error code. **/ GpgmeError -gpgme_op_import (GpgmeCtx ctx, GpgmeData keydata) +gpgme_op_import_ext (GpgmeCtx ctx, GpgmeData keydata, int *nr) { GpgmeError err = _gpgme_op_import_start (ctx, 1, keydata); if (!err) err = _gpgme_wait_one (ctx); - if (!err && (!ctx->result.import || !ctx->result.import->any_imported)) - err = -1; /* Nothing at all imported. */ + if (!err && nr) + { + if (ctx->result.import) + *nr = ctx->result.import->nr_considered; + else + *nr = 0; + } return err; } +GpgmeError +gpgme_op_import (GpgmeCtx ctx, GpgmeData keydata) +{ + return gpgme_op_import_ext (ctx, keydata, 0); +} + -- 2.26.2