2002-08-20  Marcus Brinkmann  <marcus@g10code.de>

	* gpgme.texi (Importing Keys): Document gpgme_op_import_ext.

gpgme/
2002-08-20  Marcus Brinkmann  <marcus@g10code.de>

	* 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.
This commit is contained in:
Marcus Brinkmann 2002-08-20 13:38:40 +00:00
parent 009390ddb1
commit bfbe265613
5 changed files with 44 additions and 5 deletions

View File

@ -1,3 +1,7 @@
2002-08-20 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Document gpgme_op_import_ext.
2002-08-14 Werner Koch <wk@gnupg.org>
* gpgme.texi (Information About Keys): Changed GPGME_ATTR_TYPE.

View File

@ -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

View File

@ -1,3 +1,13 @@
2002-08-20 Marcus Brinkmann <marcus@g10code.de>
* 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 <wk@gnupg.org>
* vasprintf.c (int_vasprintf): Hack to handle NULL passed for %s.

View File

@ -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,

View File

@ -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);
}