791 |
err = keycache_next_key (ctx, flags, &c, r_key); |
err = keycache_next_key (ctx, flags, &c, r_key); |
792 |
return err; |
return err; |
793 |
} |
} |
794 |
|
|
795 |
|
/* Search for a key with the pattern @pattern and mark |
796 |
|
this key as the default signing key if found. |
797 |
|
Return value: 0 on success. */ |
798 |
|
gpgme_error_t |
799 |
|
gpg_keycache_set_default_key (gpg_keycache_t ctx, |
800 |
|
const char *pattern) |
801 |
|
{ |
802 |
|
gpgme_error_t err; |
803 |
|
gpgme_key_t key; |
804 |
|
struct keycache_s *itm; |
805 |
|
|
806 |
|
err = gpg_keycache_find_key2 (ctx, pattern, 0, &key, &itm); |
807 |
|
if (err) |
808 |
|
return err; |
809 |
|
|
810 |
|
if (itm) |
811 |
|
itm->default_key = 1; |
812 |
|
return 0; |
813 |
|
} |
814 |
|
|
815 |
|
/* Return the default key from the cache. If no was |
816 |
|
marked before, NULL is returned in @r_key. |
817 |
|
Return value: 0 on success. */ |
818 |
|
gpgme_error_t |
819 |
|
gpg_keycache_get_default_key (gpg_keycache_t ctx, |
820 |
|
gpgme_key_t *r_key) |
821 |
|
{ |
822 |
|
struct keycache_s *itm; |
823 |
|
|
824 |
|
*r_key = NULL; |
825 |
|
for (itm = ctx->item; itm; itm = itm->next) { |
826 |
|
if (itm->default_key) { |
827 |
|
*r_key = itm->key; |
828 |
|
break; |
829 |
|
} |
830 |
|
} |
831 |
|
if (!*r_key) |
832 |
|
return gpgme_error (GPG_ERR_NOT_FOUND); |
833 |
|
return 0; |
834 |
|
} |
835 |
|
|
836 |
|
|
837 |
|
|