static const char trust_flags[] = "?- +";
+// clang-format off
+typedef uint8_t PgpKeyValidFlags; ///< Pgp Key valid fields, e.g. #PGP_KV_VALID
+#define PGP_KV_NO_FLAGS 0 ///< No flags are set
+#define PGP_KV_VALID (1 << 0) ///< PGP Key ID is valid
+#define PGP_KV_ADDR (1 << 1) ///< PGP Key address is valid
+#define PGP_KV_STRING (1 << 2) ///< PGP Key name string is valid
+#define PGP_KV_STRONGID (1 << 3) ///< PGP Key is strong
+// clang-format on
+
+#define PGP_KV_MATCH (PGP_KV_ADDR | PGP_KV_STRING)
+
/**
* pgp_key_abilities - Turn PGP key abilities into a string
* @param flags Flags, see #KeyFlags
return true;
}
-#define PGP_KV_VALID 1
-#define PGP_KV_ADDR 2
-#define PGP_KV_STRING 4
-#define PGP_KV_STRONGID 8
-
-#define PGP_KV_MATCH (PGP_KV_ADDR | PGP_KV_STRING)
-
/**
* pgp_id_matches_addr - Does the key ID match the address
* @param addr First email address
* @param uid UID of PGP key
* @retval num Flags, e.g. #PGP_KV_VALID
*/
-static int pgp_id_matches_addr(struct Address *addr, struct Address *u_addr, struct PgpUid *uid)
+static PgpKeyValidFlags pgp_id_matches_addr(struct Address *addr,
+ struct Address *u_addr, struct PgpUid *uid)
{
- int rc = 0;
+ PgpKeyValidFlags flags = PGP_KV_NO_FLAGS;
if (pgp_id_is_valid(uid))
- rc |= PGP_KV_VALID;
+ flags |= PGP_KV_VALID;
if (pgp_id_is_strong(uid))
- rc |= PGP_KV_STRONGID;
+ flags |= PGP_KV_STRONGID;
if (addr->mailbox && u_addr->mailbox &&
(mutt_str_strcasecmp(addr->mailbox, u_addr->mailbox) == 0))
{
- rc |= PGP_KV_ADDR;
+ flags |= PGP_KV_ADDR;
}
if (addr->personal && u_addr->personal &&
(mutt_str_strcasecmp(addr->personal, u_addr->personal) == 0))
{
- rc |= PGP_KV_STRING;
+ flags |= PGP_KV_STRING;
}
- return rc;
+ return flags;
}
/**
struct Address *qa = NULL;
TAILQ_FOREACH(qa, &al, entries)
{
- int validity = pgp_id_matches_addr(a, qa, q);
+ PgpKeyValidFlags validity = pgp_id_matches_addr(a, qa, q);
if (validity & PGP_KV_MATCH) /* something matches */
match = true;