mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
gpg: Use a regular type instead of a void* for import stats.
* g10/import.c (struct stats_s): Rename to import_stats_s. Change all users. * g10/main.h (import_stats_t): New. Change fucntions to use this instead of a void pointer. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
f0ae40b0c9
commit
4d3395ef1f
46
g10/import.c
46
g10/import.c
@ -40,7 +40,7 @@
|
|||||||
#include "call-agent.h"
|
#include "call-agent.h"
|
||||||
#include "../common/membuf.h"
|
#include "../common/membuf.h"
|
||||||
|
|
||||||
struct stats_s
|
struct import_stats_s
|
||||||
{
|
{
|
||||||
ulong count;
|
ulong count;
|
||||||
ulong no_user_id;
|
ulong no_user_id;
|
||||||
@ -62,23 +62,24 @@ struct stats_s
|
|||||||
|
|
||||||
|
|
||||||
static int import (ctrl_t ctrl,
|
static int import (ctrl_t ctrl,
|
||||||
IOBUF inp, const char* fname, struct stats_s *stats,
|
IOBUF inp, const char* fname, struct import_stats_s *stats,
|
||||||
unsigned char **fpr, size_t *fpr_len, unsigned int options,
|
unsigned char **fpr, size_t *fpr_len, unsigned int options,
|
||||||
import_screener_t screener, void *screener_arg);
|
import_screener_t screener, void *screener_arg);
|
||||||
static int read_block (IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root,
|
static int read_block (IOBUF a, PACKET **pending_pkt, kbnode_t *ret_root,
|
||||||
int *r_v3keys);
|
int *r_v3keys);
|
||||||
static void revocation_present (ctrl_t ctrl, kbnode_t keyblock);
|
static void revocation_present (ctrl_t ctrl, kbnode_t keyblock);
|
||||||
static int import_one (ctrl_t ctrl,
|
static int import_one (ctrl_t ctrl,
|
||||||
const char *fname, kbnode_t keyblock,struct stats_s *stats,
|
const char *fname, kbnode_t keyblock,
|
||||||
|
struct import_stats_s *stats,
|
||||||
unsigned char **fpr, size_t *fpr_len,
|
unsigned char **fpr, size_t *fpr_len,
|
||||||
unsigned int options, int from_sk, int silent,
|
unsigned int options, int from_sk, int silent,
|
||||||
import_screener_t screener, void *screener_arg);
|
import_screener_t screener, void *screener_arg);
|
||||||
static int import_secret_one (ctrl_t ctrl, const char *fname, kbnode_t keyblock,
|
static int import_secret_one (ctrl_t ctrl, const char *fname, kbnode_t keyblock,
|
||||||
struct stats_s *stats, int batch,
|
struct import_stats_s *stats, int batch,
|
||||||
unsigned int options, int for_migration,
|
unsigned int options, int for_migration,
|
||||||
import_screener_t screener, void *screener_arg);
|
import_screener_t screener, void *screener_arg);
|
||||||
static int import_revoke_cert( const char *fname, kbnode_t node,
|
static int import_revoke_cert( const char *fname, kbnode_t node,
|
||||||
struct stats_s *stats);
|
struct import_stats_s *stats);
|
||||||
static int chk_self_sigs (const char *fname, kbnode_t keyblock,
|
static int chk_self_sigs (const char *fname, kbnode_t keyblock,
|
||||||
PKT_public_key *pk, u32 *keyid, int *non_self );
|
PKT_public_key *pk, u32 *keyid, int *non_self );
|
||||||
static int delete_inv_parts (const char *fname, kbnode_t keyblock,
|
static int delete_inv_parts (const char *fname, kbnode_t keyblock,
|
||||||
@ -137,15 +138,15 @@ parse_import_options(char *str,unsigned int *options,int noisy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *
|
import_stats_t
|
||||||
import_new_stats_handle (void)
|
import_new_stats_handle (void)
|
||||||
{
|
{
|
||||||
return xmalloc_clear ( sizeof (struct stats_s) );
|
return xmalloc_clear ( sizeof (struct import_stats_s) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
import_release_stats_handle (void *p)
|
import_release_stats_handle (import_stats_t p)
|
||||||
{
|
{
|
||||||
xfree (p);
|
xfree (p);
|
||||||
}
|
}
|
||||||
@ -183,13 +184,14 @@ import_release_stats_handle (void *p)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
import_keys_internal (ctrl_t ctrl, iobuf_t inp, char **fnames, int nnames,
|
import_keys_internal (ctrl_t ctrl, iobuf_t inp, char **fnames, int nnames,
|
||||||
void *stats_handle, unsigned char **fpr, size_t *fpr_len,
|
import_stats_t stats_handle,
|
||||||
|
unsigned char **fpr, size_t *fpr_len,
|
||||||
unsigned int options,
|
unsigned int options,
|
||||||
import_screener_t screener, void *screener_arg)
|
import_screener_t screener, void *screener_arg)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
struct stats_s *stats = stats_handle;
|
struct import_stats_s *stats = stats_handle;
|
||||||
|
|
||||||
if (!stats)
|
if (!stats)
|
||||||
stats = import_new_stats_handle ();
|
stats = import_new_stats_handle ();
|
||||||
@ -256,14 +258,14 @@ import_keys_internal (ctrl_t ctrl, iobuf_t inp, char **fnames, int nnames,
|
|||||||
|
|
||||||
void
|
void
|
||||||
import_keys (ctrl_t ctrl, char **fnames, int nnames,
|
import_keys (ctrl_t ctrl, char **fnames, int nnames,
|
||||||
void *stats_handle, unsigned int options )
|
import_stats_t stats_handle, unsigned int options )
|
||||||
{
|
{
|
||||||
import_keys_internal (ctrl, NULL, fnames, nnames, stats_handle,
|
import_keys_internal (ctrl, NULL, fnames, nnames, stats_handle,
|
||||||
NULL, NULL, options, NULL, NULL);
|
NULL, NULL, options, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
import_keys_stream (ctrl_t ctrl, IOBUF inp, void *stats_handle,
|
import_keys_stream (ctrl_t ctrl, IOBUF inp, import_stats_t stats_handle,
|
||||||
unsigned char **fpr, size_t *fpr_len, unsigned int options)
|
unsigned char **fpr, size_t *fpr_len, unsigned int options)
|
||||||
{
|
{
|
||||||
return import_keys_internal (ctrl, inp, NULL, 0, stats_handle,
|
return import_keys_internal (ctrl, inp, NULL, 0, stats_handle,
|
||||||
@ -273,7 +275,8 @@ import_keys_stream (ctrl_t ctrl, IOBUF inp, void *stats_handle,
|
|||||||
|
|
||||||
/* Variant of import_keys_stream reading from an estream_t. */
|
/* Variant of import_keys_stream reading from an estream_t. */
|
||||||
int
|
int
|
||||||
import_keys_es_stream (ctrl_t ctrl, estream_t fp, void *stats_handle,
|
import_keys_es_stream (ctrl_t ctrl, estream_t fp,
|
||||||
|
import_stats_t stats_handle,
|
||||||
unsigned char **fpr, size_t *fpr_len,
|
unsigned char **fpr, size_t *fpr_len,
|
||||||
unsigned int options,
|
unsigned int options,
|
||||||
import_screener_t screener, void *screener_arg)
|
import_screener_t screener, void *screener_arg)
|
||||||
@ -299,7 +302,7 @@ import_keys_es_stream (ctrl_t ctrl, estream_t fp, void *stats_handle,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
import (ctrl_t ctrl, IOBUF inp, const char* fname,struct stats_s *stats,
|
import (ctrl_t ctrl, IOBUF inp, const char* fname,struct import_stats_s *stats,
|
||||||
unsigned char **fpr,size_t *fpr_len, unsigned int options,
|
unsigned char **fpr,size_t *fpr_len, unsigned int options,
|
||||||
import_screener_t screener, void *screener_arg)
|
import_screener_t screener, void *screener_arg)
|
||||||
{
|
{
|
||||||
@ -378,7 +381,7 @@ import_old_secring (ctrl_t ctrl, const char *fname)
|
|||||||
kbnode_t keyblock = NULL; /* Need to initialize because gcc can't
|
kbnode_t keyblock = NULL; /* Need to initialize because gcc can't
|
||||||
grasp the return semantics of
|
grasp the return semantics of
|
||||||
read_block. */
|
read_block. */
|
||||||
struct stats_s *stats;
|
struct import_stats_s *stats;
|
||||||
int v3keys;
|
int v3keys;
|
||||||
|
|
||||||
inp = iobuf_open (fname);
|
inp = iobuf_open (fname);
|
||||||
@ -422,10 +425,8 @@ import_old_secring (ctrl_t ctrl, const char *fname)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
import_print_stats (void *hd)
|
import_print_stats (import_stats_t stats)
|
||||||
{
|
{
|
||||||
struct stats_s *stats = hd;
|
|
||||||
|
|
||||||
if (!opt.quiet)
|
if (!opt.quiet)
|
||||||
{
|
{
|
||||||
log_info(_("Total number processed: %lu\n"),
|
log_info(_("Total number processed: %lu\n"),
|
||||||
@ -932,7 +933,7 @@ check_prefs (ctrl_t ctrl, kbnode_t keyblock)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
import_one (ctrl_t ctrl,
|
import_one (ctrl_t ctrl,
|
||||||
const char *fname, kbnode_t keyblock, struct stats_s *stats,
|
const char *fname, kbnode_t keyblock, struct import_stats_s *stats,
|
||||||
unsigned char **fpr, size_t *fpr_len, unsigned int options,
|
unsigned char **fpr, size_t *fpr_len, unsigned int options,
|
||||||
int from_sk, int silent,
|
int from_sk, int silent,
|
||||||
import_screener_t screener, void *screener_arg)
|
import_screener_t screener, void *screener_arg)
|
||||||
@ -1318,7 +1319,7 @@ import_one (ctrl_t ctrl,
|
|||||||
true the secret keys are stored by gpg-agent in the transfer format
|
true the secret keys are stored by gpg-agent in the transfer format
|
||||||
(i.e. no re-protection and aksing for passphrases). */
|
(i.e. no re-protection and aksing for passphrases). */
|
||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
transfer_secret_keys (ctrl_t ctrl, struct stats_s *stats, kbnode_t sec_keyblock,
|
transfer_secret_keys (ctrl_t ctrl, struct import_stats_s *stats, kbnode_t sec_keyblock,
|
||||||
int batch)
|
int batch)
|
||||||
{
|
{
|
||||||
gpg_error_t err = 0;
|
gpg_error_t err = 0;
|
||||||
@ -1652,7 +1653,7 @@ sec_to_pub_keyblock (kbnode_t sec_keyblock)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
import_secret_one (ctrl_t ctrl, const char *fname, kbnode_t keyblock,
|
import_secret_one (ctrl_t ctrl, const char *fname, kbnode_t keyblock,
|
||||||
struct stats_s *stats, int batch, unsigned int options,
|
struct import_stats_s *stats, int batch, unsigned int options,
|
||||||
int for_migration,
|
int for_migration,
|
||||||
import_screener_t screener, void *screener_arg)
|
import_screener_t screener, void *screener_arg)
|
||||||
{
|
{
|
||||||
@ -1819,7 +1820,8 @@ import_secret_one (ctrl_t ctrl, const char *fname, kbnode_t keyblock,
|
|||||||
* Import a revocation certificate; this is a single signature packet.
|
* Import a revocation certificate; this is a single signature packet.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
import_revoke_cert( const char *fname, kbnode_t node, struct stats_s *stats )
|
import_revoke_cert (const char *fname, kbnode_t node,
|
||||||
|
struct import_stats_s *stats)
|
||||||
{
|
{
|
||||||
PKT_public_key *pk = NULL;
|
PKT_public_key *pk = NULL;
|
||||||
kbnode_t onode;
|
kbnode_t onode;
|
||||||
|
@ -1566,7 +1566,7 @@ keyserver_search (ctrl_t ctrl, strlist_t tokens)
|
|||||||
static gpg_error_t
|
static gpg_error_t
|
||||||
keyserver_get_chunk (ctrl_t ctrl, KEYDB_SEARCH_DESC *desc, int ndesc,
|
keyserver_get_chunk (ctrl_t ctrl, KEYDB_SEARCH_DESC *desc, int ndesc,
|
||||||
int *r_ndesc_used,
|
int *r_ndesc_used,
|
||||||
void *stats_handle,
|
import_stats_t stats_handle,
|
||||||
struct keyserver_spec *override_keyserver,
|
struct keyserver_spec *override_keyserver,
|
||||||
unsigned char **r_fpr, size_t *r_fprlen)
|
unsigned char **r_fpr, size_t *r_fprlen)
|
||||||
|
|
||||||
@ -1749,7 +1749,7 @@ keyserver_get (ctrl_t ctrl, KEYDB_SEARCH_DESC *desc, int ndesc,
|
|||||||
unsigned char **r_fpr, size_t *r_fprlen)
|
unsigned char **r_fpr, size_t *r_fprlen)
|
||||||
{
|
{
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
void *stats_handle;
|
import_stats_t stats_handle;
|
||||||
int ndesc_used;
|
int ndesc_used;
|
||||||
int any_good = 0;
|
int any_good = 0;
|
||||||
|
|
||||||
@ -1858,7 +1858,7 @@ keyserver_fetch (ctrl_t ctrl, strlist_t urilist)
|
|||||||
err = gpg_dirmngr_ks_fetch (ctrl, sl->d, &datastream);
|
err = gpg_dirmngr_ks_fetch (ctrl, sl->d, &datastream);
|
||||||
if (!err)
|
if (!err)
|
||||||
{
|
{
|
||||||
void *stats_handle;
|
import_stats_t stats_handle;
|
||||||
|
|
||||||
stats_handle = import_new_stats_handle();
|
stats_handle = import_new_stats_handle();
|
||||||
import_keys_es_stream (ctrl, datastream, stats_handle, NULL, NULL,
|
import_keys_es_stream (ctrl, datastream, stats_handle, NULL, NULL,
|
||||||
|
15
g10/main.h
15
g10/main.h
@ -318,22 +318,25 @@ gcry_mpi_t encode_md_value (PKT_public_key *pk,
|
|||||||
gcry_md_hd_t md, int hash_algo );
|
gcry_md_hd_t md, int hash_algo );
|
||||||
|
|
||||||
/*-- import.c --*/
|
/*-- import.c --*/
|
||||||
|
struct import_stats_s;
|
||||||
|
typedef struct import_stats_s *import_stats_t;
|
||||||
typedef gpg_error_t (*import_screener_t)(kbnode_t keyblock, void *arg);
|
typedef gpg_error_t (*import_screener_t)(kbnode_t keyblock, void *arg);
|
||||||
|
|
||||||
int parse_import_options(char *str,unsigned int *options,int noisy);
|
int parse_import_options(char *str,unsigned int *options,int noisy);
|
||||||
void import_keys (ctrl_t ctrl, char **fnames, int nnames,
|
void import_keys (ctrl_t ctrl, char **fnames, int nnames,
|
||||||
void *stats_hd, unsigned int options);
|
import_stats_t stats_hd, unsigned int options);
|
||||||
int import_keys_stream (ctrl_t ctrl, iobuf_t inp, void *stats_hd,
|
int import_keys_stream (ctrl_t ctrl, iobuf_t inp, import_stats_t stats_hd,
|
||||||
unsigned char **fpr,
|
unsigned char **fpr,
|
||||||
size_t *fpr_len, unsigned int options);
|
size_t *fpr_len, unsigned int options);
|
||||||
int import_keys_es_stream (ctrl_t ctrl, estream_t fp, void *stats_handle,
|
int import_keys_es_stream (ctrl_t ctrl, estream_t fp,
|
||||||
|
import_stats_t stats_handle,
|
||||||
unsigned char **fpr, size_t *fpr_len,
|
unsigned char **fpr, size_t *fpr_len,
|
||||||
unsigned int options,
|
unsigned int options,
|
||||||
import_screener_t screener, void *screener_arg);
|
import_screener_t screener, void *screener_arg);
|
||||||
gpg_error_t import_old_secring (ctrl_t ctrl, const char *fname);
|
gpg_error_t import_old_secring (ctrl_t ctrl, const char *fname);
|
||||||
void *import_new_stats_handle (void);
|
import_stats_t import_new_stats_handle (void);
|
||||||
void import_release_stats_handle (void *p);
|
void import_release_stats_handle (import_stats_t hd);
|
||||||
void import_print_stats (void *hd);
|
void import_print_stats (import_stats_t hd);
|
||||||
|
|
||||||
int collapse_uids( KBNODE *keyblock );
|
int collapse_uids( KBNODE *keyblock );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user