From 2f94e980b26ab47069fa58d650ab323f84297ba9 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 22 Sep 1999 08:14:21 +0000 Subject: [PATCH] See ChangeLog: Wed Sep 22 10:14:17 CEST 1999 Werner Koch --- doc/DETAILS | 9 +++++++++ g10/ChangeLog | 15 +++++++++++++++ g10/openfile.c | 46 +++++++++++++++++++++++++++++++++++----------- g10/sign.c | 21 ++++++++++++++------- g10/status.c | 2 ++ g10/status.h | 2 ++ g10/verify.c | 9 +++++++++ 7 files changed, 86 insertions(+), 18 deletions(-) diff --git a/doc/DETAILS b/doc/DETAILS index 7c1e11edf..e043d9269 100644 --- a/doc/DETAILS +++ b/doc/DETAILS @@ -181,6 +181,15 @@ more arguments in future versions. Final statistics on import process (this is one long line) + FILE_START + Start processing a file . indicates the performed + operation: + 1 - verify + + FILE_DONE + Marks the end of a file processing which has been started + by FILE_START. + Key generation diff --git a/g10/ChangeLog b/g10/ChangeLog index 73a9c4a7e..089ab1d59 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,18 @@ +Wed Sep 22 10:14:17 CEST 1999 Werner Koch + + + * openfile.c (make_outfile_name): Use case-insenstive compare for + DOS systems. Add ".pgp" to the list of know extensions. + (open_outfile): For DOS systems try to replace the suffiy instead of + appending it. + + * status.c, status.h: Add STATUS_FILE_{START,DONE}. + * verify.c (verify_one_file): Emit these new stati. + + * sign.c (clearsign_file): Avoid duplicated Entries in the "Hash:" + line. Those headers are now only _not_ printed when there are + only old-style keys _and_ all hashs are MD5. + Mon Sep 20 12:24:41 CEST 1999 Werner Koch diff --git a/g10/openfile.c b/g10/openfile.c index 4d16db500..97a2e7f54 100644 --- a/g10/openfile.c +++ b/g10/openfile.c @@ -39,6 +39,13 @@ #define SKELEXT ".skel" #endif +#ifdef HAVE_DRIVE_LETTERS + #define CMP_FILENAME(a,b) stricmp( (a), (b) ) +#else + #define CMP_FILENAME(a,b) strcmp( (a), (b) ) +#endif + + /* FIXME: Implement opt.interactive. */ /**************** @@ -82,13 +89,11 @@ make_outfile_name( const char *iname ) if( (!iname || (*iname=='-' && !iname[1]) )) return m_strdup("-"); - #ifdef HAVE_DRIVE_LETTERS - #warning add case insensitive compare - #endif n = strlen(iname); - if( n > 4 && ( !strcmp(iname+n-4,".gpg") - || !strcmp(iname+n-4,".sig") - || !strcmp(iname+n-4,".asc") ) ) { + if( n > 4 && ( !CMP_FILENAME(iname+n-4,".gpg") + || !CMP_FILENAME(iname+n-4,".pgp") + || !CMP_FILENAME(iname+n-4,".sig") + || !CMP_FILENAME(iname+n-4,".asc") ) ) { char *buf = m_strdup( iname ); buf[n-4] = 0; return buf; @@ -169,11 +174,33 @@ open_outfile( const char *iname, int mode, IOBUF *a ) name = opt.outfile; else { #ifdef USE_ONLY_8DOT3 - #warning please implement 8.3 files - #endif + /* It is quite common DOS system to have only one dot in a + * a filename So if we have something like this, we simple + * replace the suffix execpt in cases where the suffix is + * larger than 3 characters and not the same as. + * We should really map the filenames to 8.3 but this tends to + * be more complicated and is probaly a duty of the filesystem + */ + char *dot; + const char *newsfx = mode==1 ? ".asc" : + mode==2 ? ".sig" : ".gpg"; + + buf = m_alloc(strlen(iname)+4+1); + strcpy(buf,iname); + dot = strchr(buf, '.' ); + if( dot && dot > buf && dot[1] && strlen(dot) <= 4 + && CMP_FILENAME(newsfx, dot) ) { + strcpy(buf, newsfx ); + } + else if( dot && !dot[1] ) /* don't duplicate a dot */ + strcpy( dot, newsfx ); + else + strcat( buf, newsfx ); + #else buf = m_alloc(strlen(iname)+4+1); strcpy(stpcpy(buf,iname), mode==1 ? ".asc" : mode==2 ? ".sig" : ".gpg"); + #endif name = buf; } @@ -204,9 +231,6 @@ open_sigfile( const char *iname ) IOBUF a = NULL; size_t len; - #ifdef USE_ONLY_8DOT3 - #warning please implement 8.3 files - #endif if( iname && !(*iname == '-' && !iname[1]) ) { len = strlen(iname); if( len > 4 && ( !strcmp(iname + len - 4, ".sig") diff --git a/g10/sign.c b/g10/sign.c index eb53794dc..3b7183677 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -594,21 +594,28 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile ) } } - if( old_style || only_md5 ) + if( old_style && only_md5 ) iobuf_writestr(out, "\n" ); else { const char *s; int any = 0; + byte hashs_seen[256]; + memset( hashs_seen, 0, sizeof hashs_seen ); iobuf_writestr(out, "Hash: " ); for( sk_rover = sk_list; sk_rover; sk_rover = sk_rover->next ) { PKT_secret_key *sk = sk_rover->sk; - s = digest_algo_to_string( hash_for(sk->pubkey_algo) ); - if( s ) { - if( any ) - iobuf_put(out, ',' ); - iobuf_writestr(out, s ); - any = 1; + int i = hash_for(sk->pubkey_algo); + + if( !hashs_seen[ i & 0xff ] ) { + s = digest_algo_to_string( i ); + if( s ) { + hashs_seen[ i & 0xff ] = 1; + if( any ) + iobuf_put(out, ',' ); + iobuf_writestr(out, s ); + any = 1; + } } } assert(any); diff --git a/g10/status.c b/g10/status.c index 9f1c5a669..c8d750944 100644 --- a/g10/status.c +++ b/g10/status.c @@ -117,6 +117,8 @@ write_status_text ( int no, const char *text) case STATUS_ERRMDC : s = "ERRMDC\n"; break; case STATUS_IMPORTED : s = "IMPORTED\n"; break; case STATUS_IMPORT_RES : s = "IMPORT_RES\n"; break; + case STATUS_FILE_START : s = "FILE_START\n"; break; + case STATUS_FILE_DONE : s = "FILE_DONE\n"; break; default: s = "?\n"; break; } diff --git a/g10/status.h b/g10/status.h index 817b34a3c..2365dbdf5 100644 --- a/g10/status.h +++ b/g10/status.h @@ -65,6 +65,8 @@ #define STATUS_ERRMDC 35 #define STATUS_IMPORTED 36 #define STATUS_IMPORT_RES 37 +#define STATUS_FILE_START 38 +#define STATUS_FILE_DONE 39 /*-- status.c --*/ diff --git a/g10/verify.c b/g10/verify.c index 171bff7b2..37a0caeb6 100644 --- a/g10/verify.c +++ b/g10/verify.c @@ -33,6 +33,7 @@ #include "memory.h" #include "util.h" #include "main.h" +#include "status.h" #include "filter.h" #include "ttyio.h" #include "i18n.h" @@ -90,6 +91,13 @@ verify_one_file( const char *name ) armor_filter_context_t afx; int rc; + + { + char *p = m_alloc(strlen(name)+10); + sprintf(p, "1 %s", name ); + write_status_text( STATUS_FILE_START, p ); + m_free(p); + } fp = iobuf_open(name); if( !fp ) { log_error(_("can't open `%s'\n"), print_fname_stdin(name)); @@ -105,6 +113,7 @@ verify_one_file( const char *name ) rc = proc_signature_packets( NULL, fp, NULL, name ); iobuf_close(fp); + write_status( STATUS_FILE_DONE ); return rc; }