mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
avoid function clone
This commit is contained in:
parent
78c754cd70
commit
77ffe357a9
@ -1,8 +1,9 @@
|
|||||||
2002-09-22 Stefan Bellon <sbellon@sbellon.de>
|
2002-09-22 Stefan Bellon <sbellon@sbellon.de>
|
||||||
|
|
||||||
* import.c (import_keys, import_keys_stream): Added trustdb
|
* import.c (import_keys, import_keys_stream,
|
||||||
update/check to key import if not fast-import and interactive
|
import_keys_internal): Added trustdb update/check to key import if
|
||||||
set/no-auto-check-trustdb unset.
|
not fast-import and interactive set/no-auto-check-trustdb unset.
|
||||||
|
Avoided function clone by introducing import_keys_internal.
|
||||||
|
|
||||||
2002-09-19 David Shaw <dshaw@jabberwocky.com>
|
2002-09-19 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
81
g10/import.c
81
g10/import.c
@ -173,35 +173,40 @@ import_release_stats_handle (void *p)
|
|||||||
* Key revocation certificates have special handling.
|
* Key revocation certificates have special handling.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
static int
|
||||||
import_keys( char **fnames, int nnames, int fast,
|
import_keys_internal( IOBUF inp, char **fnames, int nnames, int fast,
|
||||||
void *stats_handle, unsigned int options )
|
void *stats_handle, unsigned int options )
|
||||||
{
|
{
|
||||||
int i;
|
int i, rc = 0;
|
||||||
struct stats_s *stats = stats_handle;
|
struct stats_s *stats = stats_handle;
|
||||||
|
|
||||||
if (!stats)
|
if (!stats)
|
||||||
stats = import_new_stats_handle ();
|
stats = import_new_stats_handle ();
|
||||||
|
|
||||||
if( !fnames && !nnames )
|
if (inp) {
|
||||||
nnames = 1; /* Ohh what a ugly hack to jump into the loop */
|
rc = import( inp, fast, "[stream]", stats, options);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if( !fnames && !nnames )
|
||||||
|
nnames = 1; /* Ohh what a ugly hack to jump into the loop */
|
||||||
|
|
||||||
for(i=0; i < nnames; i++ ) {
|
for(i=0; i < nnames; i++ ) {
|
||||||
const char *fname = fnames? fnames[i] : NULL;
|
const char *fname = fnames? fnames[i] : NULL;
|
||||||
IOBUF inp = iobuf_open(fname);
|
IOBUF inp = iobuf_open(fname);
|
||||||
if( !fname )
|
if( !fname )
|
||||||
fname = "[stdin]";
|
fname = "[stdin]";
|
||||||
if( !inp )
|
if( !inp )
|
||||||
log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
|
log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
|
||||||
else {
|
else {
|
||||||
int rc = import( inp, fast, fname, stats, options );
|
rc = import( inp, fast, fname, stats, options );
|
||||||
iobuf_close(inp);
|
iobuf_close(inp);
|
||||||
if( rc )
|
if( rc )
|
||||||
log_error("import from `%s' failed: %s\n", fname,
|
log_error("import from `%s' failed: %s\n", fname,
|
||||||
g10_errstr(rc) );
|
g10_errstr(rc) );
|
||||||
|
}
|
||||||
|
if( !fname )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if( !fname )
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (!stats_handle) {
|
if (!stats_handle) {
|
||||||
import_print_stats (stats);
|
import_print_stats (stats);
|
||||||
@ -218,37 +223,21 @@ import_keys( char **fnames, int nnames, int fast,
|
|||||||
else if (!opt.no_auto_check_trustdb)
|
else if (!opt.no_auto_check_trustdb)
|
||||||
check_trustdb();
|
check_trustdb();
|
||||||
}
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
import_keys( char **fnames, int nnames, int fast,
|
||||||
|
void *stats_handle, unsigned int options )
|
||||||
|
{
|
||||||
|
import_keys_internal( NULL, fnames, nnames, fast, stats_handle, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
import_keys_stream( IOBUF inp, int fast,
|
import_keys_stream( IOBUF inp, int fast,
|
||||||
void *stats_handle, unsigned int options )
|
void *stats_handle, unsigned int options )
|
||||||
{
|
{
|
||||||
int rc = 0;
|
return import_keys_internal( inp, NULL, NULL, fast, stats_handle, options);
|
||||||
struct stats_s *stats = stats_handle;
|
|
||||||
|
|
||||||
if (!stats)
|
|
||||||
stats = import_new_stats_handle ();
|
|
||||||
|
|
||||||
rc = import( inp, fast, "[stream]", stats, options);
|
|
||||||
if (!stats_handle) {
|
|
||||||
import_print_stats (stats);
|
|
||||||
import_release_stats_handle (stats);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If no fast import and we really added new keys or merged new
|
|
||||||
user ids, signatures or revocations, then update/check the
|
|
||||||
trustdb if the user specified by setting interactive or by
|
|
||||||
not setting no-auto-check-trustdb */
|
|
||||||
if (!fast && (stats->imported || stats->n_uids ||
|
|
||||||
stats->n_sigs || stats->n_revoc)) {
|
|
||||||
if (opt.interactive)
|
|
||||||
update_trustdb();
|
|
||||||
else if (!opt.no_auto_check_trustdb)
|
|
||||||
check_trustdb();
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user