* keylist.c (list_one): Don't show the keyring filename when in
[gnupg.git] / g10 / keylist.c
index 2d416d0..68d7257 100644 (file)
@@ -230,16 +230,20 @@ list_all( int secret )
             log_error ("keydb_get_keyblock failed: %s\n", g10_errstr(rc));
             goto leave;
         }
-        resname = keydb_get_resource_name (hd);
-       if (lastresname != resname ) {
-           int i;
-
-           printf("%s\n", resname );
-           for(i=strlen(resname); i; i-- )
-               putchar('-');
-           putchar('\n');
-            lastresname = resname;
-       }
+       if(!opt.with_colons)
+         {
+           resname = keydb_get_resource_name (hd);
+           if (lastresname != resname )
+             {
+               int i;
+
+               printf("%s\n", resname );
+               for(i=strlen(resname); i; i-- )
+                 putchar('-');
+               putchar('\n');
+               lastresname = resname;
+             }
+         }
         merge_keys_and_selfsig( keyblock );
        list_keyblock( keyblock, secret, opt.fingerprint,
                       opt.check_sigs?&stats:NULL);
@@ -265,7 +269,7 @@ list_one( STRLIST names, int secret )
     KBNODE keyblock = NULL;
     GETKEY_CTX ctx;
     const char *resname;
-    char *keyring_str = N_("Keyring");
+    char *keyring_str = _("Keyring");
     int i;
     struct sig_stats stats;
 
@@ -288,7 +292,7 @@ list_one( STRLIST names, int secret )
            return;
        }
        do {
-           if (opt.show_keyring) {
+           if (opt.show_keyring && !opt.with_colons) {
                resname = keydb_get_resource_name (get_ctx_handle(ctx));
                printf("%s: %s\n", keyring_str, resname);
                for(i = strlen(resname) + strlen(keyring_str) + 2; i; i-- )
@@ -308,7 +312,7 @@ list_one( STRLIST names, int secret )
            return;
        }
        do {
-           if (opt.show_keyring) {
+         if (opt.show_keyring && !opt.with_colons) {
                resname = keydb_get_resource_name (get_ctx_handle(ctx));
                printf("%s: %s\n", keyring_str, resname);
                for(i = strlen(resname) + strlen(keyring_str) + 2; i; i-- )
@@ -358,23 +362,17 @@ print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
        }
     }
 
-    if ( keyblock ) { /* figure our the usable capabilities */
+    if ( keyblock ) { /* figure out the usable capabilities */
         KBNODE k;
         int enc=0, sign=0, cert=0, disabled=0;
 
         for (k=keyblock; k; k = k->next ) {
             if ( k->pkt->pkttype == PKT_PUBLIC_KEY 
                  || k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
-               u32 kid[2];
                 pk = k->pkt->pkt.public_key;
 
-               if(k->pkt->pkttype==PKT_PUBLIC_KEY)
-                 {
-                   keyid_from_pk(pk,kid);
-
-                   if(is_disabled(NULL,kid))
-                     disabled=1;
-                 }
+               if(pk->is_primary)
+                 disabled=pk_is_disabled(pk);
 
                 if ( pk->is_valid && !pk->is_revoked && !pk->has_expired ) {
                     if ( pk->pubkey_usage & PUBKEY_USAGE_ENC )
@@ -416,13 +414,13 @@ print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
     putchar(':');
 }
 
-static void dump_attribs(const PKT_user_id *uid,
-                        PKT_public_key *pk,PKT_secret_key *sk)
+void
+dump_attribs(const PKT_user_id *uid,PKT_public_key *pk,PKT_secret_key *sk)
 {
   int i;
 
   if(!attrib_fp)
-    BUG();
+    return;
 
   for(i=0;i<uid->numattribs;i++)
     {
@@ -498,8 +496,6 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
 
     for( kbctx=NULL; (node=walk_kbnode( keyblock, &kbctx, 0)) ; ) {
        if( node->pkt->pkttype == PKT_USER_ID && !opt.fast_list_mode ) {
-           if(attrib_fp && node->pkt->pkt.user_id->attrib_data!=NULL)
-             dump_attribs(node->pkt->pkt.user_id,pk,sk);
             /* don't list revoked or expired UIDS unless we are in
              * verbose mode and signature listing has not been
              * requested */
@@ -508,6 +504,9 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
                  node->pkt->pkt.user_id->is_expired ))
                 continue; 
 
+           if(attrib_fp && node->pkt->pkt.user_id->attrib_data!=NULL)
+             dump_attribs(node->pkt->pkt.user_id,pk,sk);
+
            if( any ) 
                 printf("uid%*s", 29, "");
 
@@ -938,10 +937,20 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
             putchar(':');
             if( sigrc != ' ' )
                 putchar(sigrc);
-            printf("::%d:%08lX%08lX:%s:%s:::", sig->pubkey_algo,
-                                                (ulong)sig->keyid[0],
-                          (ulong)sig->keyid[1], colon_datestr_from_sig(sig),
-                          colon_expirestr_from_sig(sig));
+            printf("::%d:%08lX%08lX:%s:%s:", sig->pubkey_algo,
+                  (ulong)sig->keyid[0], (ulong)sig->keyid[1],
+                  colon_datestr_from_sig(sig),
+                  colon_expirestr_from_sig(sig));
+
+           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(":");
+
            if( sigrc == '%' )
                printf("[%s] ", g10_errstr(rc) );
            else if( sigrc == '?' )