1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

avoid function clone

This commit is contained in:
Stefan Bellon 2002-09-22 09:20:08 +00:00
parent 78c754cd70
commit 77ffe357a9
2 changed files with 39 additions and 49 deletions

View File

@ -1,8 +1,9 @@
2002-09-22 Stefan Bellon <sbellon@sbellon.de>
* import.c (import_keys, import_keys_stream): Added trustdb
update/check to key import if not fast-import and interactive
set/no-auto-check-trustdb unset.
* import.c (import_keys, import_keys_stream,
import_keys_internal): Added trustdb update/check to key import if
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>

View File

@ -173,35 +173,40 @@ import_release_stats_handle (void *p)
* Key revocation certificates have special handling.
*
*/
void
import_keys( char **fnames, int nnames, int fast,
void *stats_handle, unsigned int options )
static int
import_keys_internal( IOBUF inp, char **fnames, int nnames, int fast,
void *stats_handle, unsigned int options )
{
int i;
int i, rc = 0;
struct stats_s *stats = stats_handle;
if (!stats)
stats = import_new_stats_handle ();
if( !fnames && !nnames )
nnames = 1; /* Ohh what a ugly hack to jump into the loop */
if (inp) {
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++ ) {
const char *fname = fnames? fnames[i] : NULL;
IOBUF inp = iobuf_open(fname);
if( !fname )
fname = "[stdin]";
if( !inp )
log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
else {
int rc = import( inp, fast, fname, stats, options );
iobuf_close(inp);
if( rc )
log_error("import from `%s' failed: %s\n", fname,
g10_errstr(rc) );
for(i=0; i < nnames; i++ ) {
const char *fname = fnames? fnames[i] : NULL;
IOBUF inp = iobuf_open(fname);
if( !fname )
fname = "[stdin]";
if( !inp )
log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
else {
rc = import( inp, fast, fname, stats, options );
iobuf_close(inp);
if( rc )
log_error("import from `%s' failed: %s\n", fname,
g10_errstr(rc) );
}
if( !fname )
break;
}
if( !fname )
break;
}
if (!stats_handle) {
import_print_stats (stats);
@ -218,37 +223,21 @@ import_keys( char **fnames, int nnames, int fast,
else if (!opt.no_auto_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
import_keys_stream( IOBUF inp, int fast,
void *stats_handle, unsigned int options )
{
int rc = 0;
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;
return import_keys_internal( inp, NULL, NULL, fast, stats_handle, options);
}
static int