diff --git a/g10/ChangeLog b/g10/ChangeLog index a340147ca..595dc4012 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,12 @@ +2002-09-02 Werner Koch + + * g10.c (main): Try to set a default character set. Print the + used one in verbosity level 3. + * gpgv.c (main): Try to set a default character set. + + * status.c, status.h (STATUS_IMPORT_OK): New. + * import.c (import_one,import_secret_one): Print new status. + 2002-08-30 David Shaw * pkclist.c (build_pk_list): Add new status code to indicate an @@ -73,7 +82,7 @@ 2002-08-21 Werner Koch * import.c (import_print_stats): Print new non_imported counter - which is currently not used becuase we terminate on errors. + which is currently not used because we terminate on errors. 2002-08-20 David Shaw diff --git a/g10/g10.c b/g10/g10.c index fbacee1fb..1bbf5d592 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -1158,6 +1158,8 @@ main( int argc, char **argv ) maybe_setuid = 0; /* Okay, we are now working under our real uid */ + set_native_charset (NULL); /* Try to auto set the character set */ + if( default_config ) { configname = make_filename(opt.homedir, "gpg" EXTSEP_S "conf", NULL ); @@ -1520,7 +1522,7 @@ main( int argc, char **argv ) case oNoSecmemWarn: secmem_set_flags( secmem_get_flags() | 1 ); break; case oNoPermissionWarn: opt.no_perm_warn=1; break; case oNoMDCWarn: opt.no_mdc_warn=1; break; - case oCharset: + case oCharset: if( set_native_charset( pargs.r.ret_str ) ) log_error(_("%s is not a valid character set\n"), pargs.r.ret_str); @@ -1683,6 +1685,9 @@ main( int argc, char **argv ) } #endif + if (opt.verbose > 2) + log_info ("using character set `%s'\n", get_native_charset ()); + if( may_coredump && !opt.quiet ) log_info(_("WARNING: program may create a core file!\n")); diff --git a/g10/gpgv.c b/g10/gpgv.c index 362f5c528..dcb2a9d94 100644 --- a/g10/gpgv.c +++ b/g10/gpgv.c @@ -164,6 +164,8 @@ main( int argc, char **argv ) tty_no_terminal(1); tty_batchmode(1); disable_dotlock(); + + set_native_charset (NULL); /* Try to auto set the character set */ pargs.argc = &argc; pargs.argv = &argv; diff --git a/g10/import.c b/g10/import.c index 03adafb2b..706627f45 100644 --- a/g10/import.c +++ b/g10/import.c @@ -516,6 +516,29 @@ fix_hkp_corruption(KBNODE keyblock) return changed; } + +static void +print_import_ok (PKT_public_key *pk, PKT_secret_key *sk, unsigned int reason) +{ + byte array[MAX_FINGERPRINT_LEN], *s; + char buf[MAX_FINGERPRINT_LEN*2+30], *p; + size_t i, n; + + sprintf (buf, "%u ", reason); + p = buf + strlen (buf); + + if (pk) + fingerprint_from_pk (pk, array, &n); + else + fingerprint_from_sk (sk, array, &n); + s = array; + for (i=0; i < n ; i++, s++, p += 2) + sprintf (p, "%02X", *s); + + write_status_text (STATUS_IMPORT_OK, buf); +} + + /**************** * Try to import one keyblock. Return an error only in serious cases, but * never for an invalid keyblock. It uses log_error to increase the @@ -645,6 +668,7 @@ import_one( const char *fname, KBNODE keyblock, int fast, char *us = get_long_user_id_string( keyid ); write_status_text( STATUS_IMPORTED, us ); m_free(us); + print_import_ok (pk,NULL, 1); } stats->imported++; if( is_RSA( pk->pubkey_algo ) ) @@ -736,8 +760,15 @@ import_one( const char *fname, KBNODE keyblock, int fast, stats->n_uids +=n_uids; stats->n_sigs +=n_sigs; stats->n_subk +=n_subk; + + if (is_status_enabled ()) + print_import_ok (pk, NULL, + ((n_uids?2:0)|(n_sigs?4:0)|(n_subk?8:0))); } else { + if (is_status_enabled ()) + print_import_ok (pk, NULL, 0); + if( !opt.quiet ) { char *p=get_user_id_printable(keyid); log_info( _("key %08lX: \"%s\" not changed\n"), @@ -823,11 +854,15 @@ import_secret_one( const char *fname, KBNODE keyblock, if( !opt.quiet ) log_info( _("key %08lX: secret key imported\n"), (ulong)keyid[1]); stats->secret_imported++; + if (is_status_enabled ()) + print_import_ok (NULL, sk, 1|16); } else if( !rc ) { /* we can't merge secret keys */ log_error( _("key %08lX: already in secret keyring\n"), (ulong)keyid[1]); stats->secret_dups++; + if (is_status_enabled ()) + print_import_ok (NULL, sk, 16); } else log_error( _("key %08lX: secret key not found: %s\n"), diff --git a/g10/status.c b/g10/status.c index 515be0c6e..799b42edc 100644 --- a/g10/status.c +++ b/g10/status.c @@ -120,6 +120,7 @@ get_status_string ( int no ) case STATUS_BADMDC : s = "BADMDC"; break; case STATUS_ERRMDC : s = "ERRMDC"; break; case STATUS_IMPORTED : s = "IMPORTED"; break; + case STATUS_IMPORT_OK : s = "IMPORT_OK"; break; case STATUS_IMPORT_RES : s = "IMPORT_RES"; break; case STATUS_FILE_START : s = "FILE_START"; break; case STATUS_FILE_DONE : s = "FILE_DONE"; break; diff --git a/g10/status.h b/g10/status.h index 86e232719..dd913b4bd 100644 --- a/g10/status.h +++ b/g10/status.h @@ -97,6 +97,7 @@ #define STATUS_EXPSIG 65 #define STATUS_EXPKEYSIG 66 #define STATUS_ATTRIBUTE 67 +#define STATUS_IMPORT_OK 68 /*-- status.c --*/ void set_status_fd ( int fd );