diff --git a/include/rpm/rpmkeyring.h b/include/rpm/rpmkeyring.h index 7da8febe84..51e3ac9040 100644 --- a/include/rpm/rpmkeyring.h +++ b/include/rpm/rpmkeyring.h @@ -40,6 +40,13 @@ rpmKeyring rpmKeyringNew(void); */ rpmKeyring rpmKeyringFree(rpmKeyring keyring); +/** \ingroup rpmkeyring + * Check if there are no keys in the keyring. + * @param keyring keyring handle + * @return 1 if keyring is empy, 0 otherwise + */ +int rpmKeyringIsEmpty(rpmKeyring keyring); + /** \ingroup rpmkeyring * Add a public key to keyring. * @param keyring keyring handle diff --git a/rpmio/rpmkeyring.cc b/rpmio/rpmkeyring.cc index 4e08e97f76..0cfad81a0d 100644 --- a/rpmio/rpmkeyring.cc +++ b/rpmio/rpmkeyring.cc @@ -71,6 +71,14 @@ rpmKeyring rpmKeyringFree(rpmKeyring keyring) return NULL; } +int rpmKeyringIsEmpty(rpmKeyring keyring) +{ + if (!keyring) return 1; + rdlock lock(keyring->mutex); + return keyring->keys.empty(); +} + + rpmKeyringIterator rpmKeyringInitIterator(rpmKeyring keyring, int unused) { if (!keyring || unused != 0)