* main.h, keylist.c (print_subpackets_colon): Make a public function.
authorDavid Shaw <dshaw@jabberwocky.com>
Mon, 13 Sep 2004 12:31:25 +0000 (12:31 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Mon, 13 Sep 2004 12:31:25 +0000 (12:31 +0000)
* keyedit.c (print_and_check_one_sig_colon): New.  Print a with-colons
version of the sig record. (menu_delsig): Call it here for a with-colons
delsig.

g10/ChangeLog
g10/keyedit.c
g10/keylist.c
g10/main.h

index 8e49478..d141064 100644 (file)
@@ -1,3 +1,12 @@
+2004-09-13  David Shaw  <dshaw@jabberwocky.com>
+
+       * main.h, keylist.c (print_subpackets_colon): Make a public
+       function.
+
+       * keyedit.c (print_and_check_one_sig_colon): New.  Print a
+       with-colons version of the sig record.
+       (menu_delsig): Call it here for a with-colons delsig.
+
 2004-09-12  David Shaw  <dshaw@jabberwocky.com>
 
        * options.h, keylist.c (print_one_subpacket,
index f559756..b5c4ac5 100644 (file)
@@ -94,6 +94,71 @@ struct sign_attrib {
     char *trust_regexp;
 };
 
+
+/* TODO: Fix duplicated code between here and the check-sigs/list-sigs
+   code in keylist.c. */
+static int
+print_and_check_one_sig_colon( KBNODE keyblock, KBNODE node,
+                              int *inv_sigs, int *no_key, int *oth_err,
+                              int *is_selfsig, int print_without_key )
+{
+  PKT_signature *sig = node->pkt->pkt.signature;
+  int rc, sigrc;
+
+  /* TODO: Make sure a cached sig record here still has the pk that
+     issued it.  See also keylist.c:list_keyblock_print */
+
+  switch((rc=check_key_signature(keyblock,node,is_selfsig)))
+    {
+    case 0:
+      node->flag &= ~(NODFLG_BADSIG|NODFLG_NOKEY|NODFLG_SIGERR);
+      sigrc = '!';
+      break;
+    case G10ERR_BAD_SIGN:
+      node->flag = NODFLG_BADSIG;
+      sigrc = '-';
+      if( inv_sigs )
+       ++*inv_sigs;
+      break;
+    case G10ERR_NO_PUBKEY:
+    case G10ERR_UNU_PUBKEY:
+      node->flag = NODFLG_NOKEY;
+      sigrc = '?';
+      if( no_key )
+       ++*no_key;
+      break;
+    default:
+      node->flag = NODFLG_SIGERR;
+      sigrc = '%';
+      if( oth_err )
+       ++*oth_err;
+      break;
+    }
+
+  if( sigrc != '?' || print_without_key )
+    {
+      printf("sig:%c::%d:%08lX%08lX:%lu:%lu:",
+            sigrc,sig->pubkey_algo,(ulong)sig->keyid[1],(ulong)sig->keyid[2],
+            (ulong)sig->timestamp,(ulong)sig->expiredate);
+
+      if(sig->trust_depth || sig->trust_value)
+       printf("%d %d",sig->trust_depth,sig->trust_value);
+
+      printf(":");
+
+      if(sig->trust_regexp)
+       print_string(stdout,sig->trust_regexp,strlen(sig->trust_regexp),':');
+
+      printf("::%02x%c\n",sig->sig_class,sig->flags.exportable?'x':'l');
+
+      if(opt.show_subpackets)
+       print_subpackets_colon(sig);
+    }
+
+  return (sigrc == '!');
+}
+
+
 /****************
  * Print information about a signature, check it and return true
  * if the signature is okay. NODE must be a signature packet.
@@ -255,8 +320,6 @@ check_all_keysigs( KBNODE keyblock, int only_selected )
 }
 
 
-
-
 static int
 sign_mk_attrib( PKT_signature *sig, void *opaque )
 {
@@ -2534,10 +2597,15 @@ menu_delsig( KBNODE pub_keyblock )
            tty_print_utf8_string( uid->name, uid->len );
            tty_printf("\n");
 
-          okay = inv_sig = no_key = other_err = 0;
-           valid = print_and_check_one_sig( pub_keyblock, node,
-                                           &inv_sig, &no_key, &other_err,
-                                           &selfsig, 1 );
+           okay = inv_sig = no_key = other_err = 0;
+           if(opt.with_colons)
+             valid = print_and_check_one_sig_colon( pub_keyblock, node,
+                                              &inv_sig, &no_key, &other_err,
+                                              &selfsig, 1 );
+           else
+             valid = print_and_check_one_sig( pub_keyblock, node,
+                                              &inv_sig, &no_key, &other_err,
+                                              &selfsig, 1 );
 
           if( valid ) {
               okay = cpr_get_answer_yes_no_quit(
index 34c2920..ce66a13 100644 (file)
@@ -571,7 +571,7 @@ print_one_subpacket(sigsubpkttype_t type,size_t len,int flags,const byte *buf)
   printf("\n");
 }
 
-static void
+void
 print_subpackets_colon(PKT_signature *sig)
 {
   byte *i;
index d65c43b..d86931e 100644 (file)
@@ -217,6 +217,7 @@ void release_revocation_reason_info( struct revocation_reason_info *reason );
 /*-- keylist.c --*/
 void public_key_list( STRLIST list );
 void secret_key_list( STRLIST list );
+void print_subpackets_colon(PKT_signature *sig);
 void reorder_keyblock (KBNODE keyblock);
 void list_keyblock( KBNODE keyblock, int secret, int fpr, void *opaque );
 void print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode);