GNU Info

Info Node: (gpgme.info)Listing Keys

(gpgme.info)Listing Keys


Next: Information About Keys Up: Key Management
Enter node , (file) or (file)node

Listing Keys
------------

 - Function: GpgmeError gpgme_op_keylist_start (GpgmeCtx CTX,
          const char *PATTERN, int SECRET_ONLY)
     The function `gpgme_op_keylist_start' initiates a key listing
     operation inside the context CTX.  It sets everything up so that
     subsequent invocations of `gpgme_op_keylist_next' return the keys
     in the list.

     If PATTERN is `NULL', all available keys are returned.  Otherwise,
     PATTERN contains an engine specific expression that is used to
     limit the list to all keys matching the pattern.

     If SECRET_ONLY is not `0', the list is restricted to secret keys
     only.

     The context will be busy until either all keys are received (and
     `gpgme_op_keylist_next' returns `GPGME_EOF'), or
     `gpgme_op_keylist_end' is called to finish the operation.

     The function returns `GPGME_Invalid_Value' if CTX is not a valid
     pointer, and passes through any errors that are reported by the
     crypto engine support routines.

 - Function: GpgmeError gpgme_op_keylist_ext_start (GpgmeCtx CTX,
          const char *PATTERN[], int SECRET_ONLY, int RESERVED)
     The function `gpgme_op_keylist_ext_start' initiates an extended
     key listing operation inside the context CTX.  It sets everything
     up so that subsequent invocations of `gpgme_op_keylist_next'
     return the keys in the list.

     If PATTERN or *PATTERN is `NULL', all available keys are returned.
     Otherwise, PATTERN is a `NULL' terminated array of strings that
     are used to limit the list to all keys matching at least one of
     the patterns verbatim.

     If SECRET_ONLY is not `0', the list is restricted to secret keys
     only.

     The value of RESERVED must be `0'.

     The context will be busy until either all keys are received (and
     `gpgme_op_keylist_next' returns `GPGME_EOF'), or
     `gpgme_op_keylist_end' is called to finish the operation.

     The function returns `GPGME_Invalid_Value' if CTX is not a valid
     pointer, and passes through any errors that are reported by the
     crypto engine support routines.

 - Function: GpgmeError gpgme_op_keylist_next (GpgmeCtx CTX,
          GpgmeKey *R_KEY)
     The function `gpgme_op_keylist_next' returns the next key in the
     list created by a previous `gpgme_op_keylist_start' operation in
     the context CTX.  The key will have one reference for the user.
     Note: Manipulating Keys.

     This is the only way to get at `GpgmeKey' objects in GPGME.

     If the last key in the list has already been returned,
     `gpgme_op_keylist_next' returns `GPGME_EOF'.

     The function returns `GPGME_Invalid_Value' if CTX or R_KEY is not
     a valid pointer, `GPGME_No_Request' if there is no pending
     operation, `GPGME_Out_Of_Core' if there is not enough memory for
     the operation.

 - Function: GpgmeError gpgme_op_keylist_end (GpgmeCtx CTX)
     The function `gpgme_op_keylist_next' ends a pending key list
     operation in the context CTX.

     The function returns `GPGME_Invalid_Value' if CTX is not a valid
     pointer, `GPGME_No_Request' if there is no pending operation,
     `GPGME_Out_Of_Core' if at some time during the operation there was
     not enough memory available.

   The following example illustrates how all keys containing a certain
string (`g10code') can be listed with their key ID and the name and
e-mail address of the main user ID:

     GpgmeCtx ctx;
     GpgmeError err = gpgme_new (&ctx);
     
     if (!err)
       {
         err = gpgme_op_keylist_start (ctx, "g10code", 0);
         while (!err && (err = gpgme_op_keylist_next (ctx, &key)) != GPGME_EOF)
           {
             printf ("%s: %s <%s>\n",
                     gpgme_key_get_string_attr (key, GPGME_ATTR_KEYID, 0, 0),
     	        gpgme_key_get_string_attr (key, GPGME_ATTR_NAME, 0, 0),
     	        gpgme_key_get_string_attr (key, GPGME_ATTR_EMAIL, 0, 0));
             gpgme_key_release (key);
           }
         gpgme_release (ctx);
       }
     if (err)
       {
         fprintf (stderr, "%s: can not list keys: %s\n",
                  argv[0], gpgme_strerror (err));
         exit (1);
       }


automatically generated by info2www version 1.2.2.9