--list-secret-keys and stdout

Werner Koch wk at gnupg.org
Mon Mar 19 09:40:17 CET 2007


On Sat, 17 Mar 2007 13:09, buanzo at buanzo.com.ar said:

> Is there an undocument way of saving that information to a file? If not, would you implement
> --output support for --list-secret-keys? Should I implement it, and send you a patch? Any other

No, there is no such option.  Eventually we will add this but it needs
quite some work because we can't use the standard stdio printf for
some reasons (we need an emulation of funopen).

I wonder why you are not using gpgme - it takes care of all this and
listing the secret keys is the just a matter of:

  err = gpgme_op_keylist_start (ctx, NULL, 1);
  fail_if_err (err);
    
  while (!(err = gpgme_op_keylist_next (ctx, &key)))
    {
      /* Now check key flags or do whatever you want to do with that
         key.  E.g: */
      if (key->revoked)
	{
	  fprintf (stderr, "Key has been revoked\n");
          gpgme_key_unref (key);
	  continue
	}
      foo (key);
      gpgme_key_unref (key);
    }
  if (gpg_err_code (err) != GPG_ERR_EOF)
    fail_if_err (err);
  err = gpgme_op_keylist_end (ctx);
  fail_if_err (err);

This also allows to switch to X.509 keys with just one function call.
Further you automagically participate from newer developments, like
running gpg as a co-process.



Salam-Shalom,

   Werner




More information about the Gnupg-devel mailing list