* gpgsm/t-import.c (print_op_info): New.
(main): Print operation info. * engine-gpgsm.c (map_assuan_error): Map No_Data_Available to EOF. * import.c (append_xml_impinfo): Kludge to print fingerprint instead of keyid for use with gpgsm. (import_status_handler): Set a flag to know whether any import occured. (gpgme_op_import): Reurn -1 if no certificate ewas imported. * gpgme.texi (Importing Keys): Document the return value -1 of gpgme_op_import.
This commit is contained in:
parent
73f47e40b1
commit
06cd423a8b
@ -1,3 +1,8 @@
|
||||
2002-06-26 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* gpgme.texi (Importing Keys): Document the return value -1 of
|
||||
gpgme_op_import.
|
||||
|
||||
2002-06-20 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* gpgme.texi (Verify): Explain the new whatidx variable.
|
||||
|
@ -1900,8 +1900,9 @@ More information about the import is available with
|
||||
|
||||
The function returns @code{GPGME_No_Error} if the import was completed
|
||||
successfully, @code{GPGME_Invalid_Value} if @var{keydata} if @var{ctx}
|
||||
or @var{keydata} is not a valid pointer, and @code{GPGME_No_Data} if
|
||||
@var{keydata} is an empty data buffer.
|
||||
or @var{keydata} is not a valid pointer, @code{GPGME_No_Data} if
|
||||
@var{keydata} is an empty data buffer, and @code{GPGME_EOF} if the
|
||||
operation was completed successfully but no data was actually imported.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun GpgmeError gpgme_op_import_start (@w{GpgmeCtx @var{ctx}}, @w{GpgmeData @var{keydata}})
|
||||
|
@ -1,3 +1,13 @@
|
||||
2002-06-26 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* engine-gpgsm.c (map_assuan_error): Map No_Data_Available to EOF.
|
||||
|
||||
* import.c (append_xml_impinfo): Kludge to print fingerprint
|
||||
instead of keyid for use with gpgsm.
|
||||
(import_status_handler): Set a flag to know whether any import
|
||||
occured.
|
||||
(gpgme_op_import): Reurn -1 if no certificate ewas imported.
|
||||
|
||||
2002-06-25 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* engine-gpgsm.c (_gpgme_gpgsm_set_io_cbs) [ENABLE_GPGSM]: Fixed
|
||||
|
@ -220,8 +220,10 @@ map_assuan_error (AssuanError err)
|
||||
case ASSUAN_Unsupported_Algorithm:
|
||||
return mk_error (Not_Implemented); /* XXX Argh. */
|
||||
|
||||
/* These are errors internal to GPGME. */
|
||||
case ASSUAN_No_Data_Available:
|
||||
return mk_error (EOF);
|
||||
|
||||
/* These are errors internal to GPGME. */
|
||||
case ASSUAN_No_Input:
|
||||
case ASSUAN_No_Output:
|
||||
case ASSUAN_Invalid_Command:
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
struct import_result_s
|
||||
{
|
||||
int any_imported;
|
||||
GpgmeData xmlinfo;
|
||||
};
|
||||
|
||||
@ -55,6 +56,8 @@ append_xml_impinfo (GpgmeData *rdh, GpgStatusCode code, char *args)
|
||||
#define MAX_IMPORTED_FIELDS 14
|
||||
static const char *const imported_fields[MAX_IMPORTED_FIELDS]
|
||||
= { "keyid", "username", 0 };
|
||||
static const char *const imported_fields_x509[MAX_IMPORTED_FIELDS]
|
||||
= { "fpr", 0 };
|
||||
static const char *const import_res_fields[MAX_IMPORTED_FIELDS]
|
||||
= { "count", "no_user_id", "imported", "imported_rsa",
|
||||
"unchanged", "n_uids", "n_subk", "n_sigs", "s_sigsn_revoc",
|
||||
@ -88,6 +91,11 @@ append_xml_impinfo (GpgmeData *rdh, GpgStatusCode code, char *args)
|
||||
*args++ = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* gpgsm does not print a useful user ID and uses a fingerprint
|
||||
instead of the key ID. */
|
||||
if (code == STATUS_IMPORTED && field[0] && strlen (field[0]) > 16)
|
||||
field_name = imported_fields_x509;
|
||||
}
|
||||
|
||||
/* Initialize the data buffer if necessary. */
|
||||
@ -116,7 +124,7 @@ append_xml_impinfo (GpgmeData *rdh, GpgStatusCode code, char *args)
|
||||
for (i = 0; field_name[i]; i++)
|
||||
{
|
||||
_gpgme_data_append_string (dh, " <");
|
||||
_gpgme_data_append_string (dh, field_name[i]);
|
||||
_gpgme_data_append_string (dh, field_name[i]);
|
||||
_gpgme_data_append_string (dh, ">");
|
||||
_gpgme_data_append_string (dh, field[i]);
|
||||
_gpgme_data_append_string (dh, "</");
|
||||
@ -152,6 +160,7 @@ import_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args)
|
||||
break;
|
||||
|
||||
case STATUS_IMPORTED:
|
||||
ctx->result.import->any_imported = 1;
|
||||
case STATUS_IMPORT_RES:
|
||||
append_xml_impinfo (&ctx->result.import->xmlinfo, code, args);
|
||||
break;
|
||||
@ -211,7 +220,7 @@ gpgme_op_import_start (GpgmeCtx ctx, GpgmeData keydata)
|
||||
*
|
||||
* Import all key material from @keydata into the key database.
|
||||
*
|
||||
* Return value: o on success or an error code.
|
||||
* Return value: 0 on success or an error code.
|
||||
**/
|
||||
GpgmeError
|
||||
gpgme_op_import (GpgmeCtx ctx, GpgmeData keydata)
|
||||
@ -219,5 +228,8 @@ gpgme_op_import (GpgmeCtx ctx, GpgmeData keydata)
|
||||
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. */
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-06-26 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* gpgsm/t-import.c (print_op_info): New.
|
||||
(main): Print operation info.
|
||||
|
||||
2002-06-25 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* gpgsm/Makefile.am (DISTCLEANFILES): new.
|
||||
|
@ -57,6 +57,20 @@ make_filename (const char *fname)
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void
|
||||
print_op_info (GpgmeCtx c)
|
||||
{
|
||||
char *s = gpgme_get_op_info (c, 0);
|
||||
|
||||
if (!s)
|
||||
puts ("<!-- no operation info available -->");
|
||||
else {
|
||||
puts (s);
|
||||
free (s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@ -76,6 +90,7 @@ main (int argc, char **argv)
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_op_import (ctx, in);
|
||||
print_op_info (ctx);
|
||||
fail_if_err (err);
|
||||
|
||||
gpgme_data_release (in);
|
||||
@ -84,6 +99,7 @@ main (int argc, char **argv)
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_op_import (ctx, in);
|
||||
print_op_info (ctx);
|
||||
fail_if_err (err);
|
||||
|
||||
gpgme_data_release (in);
|
||||
|
Loading…
Reference in New Issue
Block a user