]> granicus.if.org Git - neomutt/commitdiff
replace 'pgp_key_t' with 'struct PgpKeyInfo'
authorRichard Russon <rich@flatcap.org>
Mon, 15 May 2017 13:48:57 +0000 (14:48 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 15 May 2017 23:05:11 +0000 (00:05 +0100)
gnupgparse.c
mutt_crypt.h
pgp.c
pgp.h
pgpkey.c
pgplib.c
pgplib.h
pgppubring.c

index 4eee679756684866434ecfe525c0ade7a37d6ae1..6f08c2cda9e1446da7e124a0915c04be71cdbe85 100644 (file)
@@ -107,7 +107,7 @@ static void fix_uid(char *uid)
   }
 }
 
-static pgp_key_t parse_pub_line(char *buf, int *is_subkey, pgp_key_t k)
+static struct PgpKeyInfo *parse_pub_line(char *buf, int *is_subkey, struct PgpKeyInfo *k)
 {
   pgp_uid_t *uid = NULL;
   int field = 0, is_uid = 0;
@@ -116,7 +116,7 @@ static pgp_key_t parse_pub_line(char *buf, int *is_subkey, pgp_key_t k)
   char *pend = NULL, *p = NULL;
   int trust = 0;
   int flags = 0;
-  struct pgp_keyinfo tmp;
+  struct PgpKeyInfo tmp;
 
   *is_subkey = 0;
   if (!*buf)
@@ -368,12 +368,12 @@ bail:
   return NULL;
 }
 
-pgp_key_t  pgp_get_candidates(pgp_ring_t keyring, struct List *hints)
+struct PgpKeyInfo *pgp_get_candidates(pgp_ring_t keyring, struct List *hints)
 {
   FILE *fp = NULL;
   pid_t thepid;
   char buf[LONG_STRING];
-  pgp_key_t db = NULL, *kend, k = NULL, kk, mainkey = NULL;
+  struct PgpKeyInfo *db = NULL, **kend, *k = NULL, *kk = NULL, *mainkey = NULL;
   int is_sub;
   int devnull;
 
index 98937772140d60825c1bd04b68652ca40408972a..73d65e590a20beb2d1f1f07ef7456c152bc0118e 100644 (file)
@@ -98,10 +98,6 @@ enum pgp_ring
 };
 typedef enum pgp_ring pgp_ring_t;
 
-
-struct pgp_keyinfo;
-typedef struct pgp_keyinfo *pgp_key_t;
-
 /* Some prototypes -- old crypt.h. */
 
 int mutt_protect(struct Header *msg, char *keylist);
diff --git a/pgp.c b/pgp.c
index 7b5b3232bcf6db34c9a346a65bb5efc4c099294c..6320f6ac60498fd753ede863ea50bc4fa8031c7e 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -96,7 +96,7 @@ bool pgp_use_gpg_agent(void)
   return true;
 }
 
-static pgp_key_t _pgp_parent(pgp_key_t k)
+static struct PgpKeyInfo *_pgp_parent(struct PgpKeyInfo *k)
 {
   if ((k->flags & KEYFLAG_SUBKEY) && k->parent && option(OPTPGPIGNORESUB))
     k = k->parent;
@@ -104,28 +104,28 @@ static pgp_key_t _pgp_parent(pgp_key_t k)
   return k;
 }
 
-char *pgp_long_keyid(pgp_key_t k)
+char *pgp_long_keyid(struct PgpKeyInfo *k)
 {
   k = _pgp_parent(k);
 
   return k->keyid;
 }
 
-char *pgp_short_keyid(pgp_key_t k)
+char *pgp_short_keyid(struct PgpKeyInfo *k)
 {
   k = _pgp_parent(k);
 
   return k->keyid + 8;
 }
 
-char *pgp_keyid(pgp_key_t k)
+char *pgp_keyid(struct PgpKeyInfo *k)
 {
   k = _pgp_parent(k);
 
   return _pgp_keyid(k);
 }
 
-char *_pgp_keyid(pgp_key_t k)
+char *_pgp_keyid(struct PgpKeyInfo *k)
 {
   if (option(OPTPGPLONGIDS))
     return k->keyid;
@@ -133,7 +133,7 @@ char *_pgp_keyid(pgp_key_t k)
     return (k->keyid + 8);
 }
 
-static char *pgp_fingerprint(pgp_key_t k)
+static char *pgp_fingerprint(struct PgpKeyInfo *k)
 {
   k = _pgp_parent(k);
 
@@ -146,7 +146,7 @@ static char *pgp_fingerprint(pgp_key_t k)
  * The longest available should be used for internally identifying
  * the key and for invoking pgp commands.
  */
-char *pgp_fpr_or_lkeyid(pgp_key_t k)
+char *pgp_fpr_or_lkeyid(struct PgpKeyInfo *k)
 {
   char *fingerprint = NULL;
 
@@ -1192,7 +1192,7 @@ char *pgp_find_keys(struct Address *adrlist, int oppenc_mode)
   size_t keylist_used = 0;
   struct Address *addr = NULL;
   struct Address *p = NULL, *q = NULL;
-  pgp_key_t k_info = NULL;
+  struct PgpKeyInfo *k_info = NULL;
   char buf[LONG_STRING];
   int r;
   int key_selected;
@@ -1600,7 +1600,7 @@ struct Body *pgp_traditional_encryptsign(struct Body *a, int flags, char *keylis
 
 int pgp_send_menu(struct Header *msg)
 {
-  pgp_key_t p;
+  struct PgpKeyInfo *p = NULL;
   char input_signas[SHORT_STRING];
   char *prompt = NULL, *letters = NULL, *choices = NULL;
   char promptbuf[LONG_STRING];
diff --git a/pgp.h b/pgp.h
index b1b8bc111a4714adb8258573e186dbb8ee764b66..3dd7fd00ee4bfd596a3dcf84d94f81604b059aff 100644 (file)
--- a/pgp.h
+++ b/pgp.h
@@ -34,18 +34,18 @@ int pgp_check_traditional(FILE *fp, struct Body *b, int tagged_only);
 struct Body *pgp_make_key_attachment(char *tempf);
 const char *pgp_micalg(const char *fname);
 
-char *_pgp_keyid(pgp_key_t);
-char *pgp_keyid(pgp_key_t);
-char *pgp_short_keyid(pgp_key_t k);
-char *pgp_long_keyid(pgp_key_t k);
-char *pgp_fpr_or_lkeyid(pgp_key_t k);
+char *_pgp_keyid(struct PgpKeyInfo *k);
+char *pgp_keyid(struct PgpKeyInfo *k);
+char *pgp_short_keyid(struct PgpKeyInfo *k);
+char *pgp_long_keyid(struct PgpKeyInfo *k);
+char *pgp_fpr_or_lkeyid(struct PgpKeyInfo *k);
 
 int pgp_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur);
 
-pgp_key_t pgp_ask_for_key(char *tag, char *whatfor, short abilities, pgp_ring_t keyring);
-pgp_key_t pgp_get_candidates(pgp_ring_t keyring, struct List *hints);
-pgp_key_t pgp_getkeybyaddr(struct Address *a, short abilities, pgp_ring_t keyring, int oppenc_mode);
-pgp_key_t pgp_getkeybystr(char *p, short abilities, pgp_ring_t keyring);
+struct PgpKeyInfo *pgp_ask_for_key(char *tag, char *whatfor, short abilities, pgp_ring_t keyring);
+struct PgpKeyInfo *pgp_get_candidates(pgp_ring_t keyring, struct List *hints);
+struct PgpKeyInfo *pgp_getkeybyaddr(struct Address *a, short abilities, pgp_ring_t keyring, int oppenc_mode);
+struct PgpKeyInfo *pgp_getkeybystr(char *p, short abilities, pgp_ring_t keyring);
 
 char *pgp_find_keys(struct Address *adrlist, int oppenc_mode);
 
index 9b38ea63d8cc72fcb05f12dca7ba1a71a7e652f6..d4042c8a1258e4ecd652beaad748af13d935a81b 100644 (file)
--- a/pgpkey.c
+++ b/pgpkey.c
@@ -81,7 +81,7 @@ static char pgp_flags(int flags)
     return ' ';
 }
 
-static pgp_key_t pgp_principal_key(pgp_key_t key)
+static struct PgpKeyInfo *pgp_principal_key(struct PgpKeyInfo *key)
 {
   if (key->flags & KEYFLAG_SUBKEY && key->parent)
     return key->parent;
@@ -117,7 +117,7 @@ static const char *pgp_entry_fmt(char *dest, size_t destlen, size_t col, int col
   char fmt[16];
   pgp_entry_t *entry = NULL;
   pgp_uid_t *uid = NULL;
-  pgp_key_t key, pkey;
+  struct PgpKeyInfo *key = NULL, *pkey = NULL;
   int kflags = 0;
   int optional = (flags & MUTT_FORMAT_OPTIONAL);
 
@@ -363,9 +363,9 @@ static int pgp_compare_trust(const void *a, const void *b)
                                          _pgp_compare_trust(a, b));
 }
 
-static bool pgp_key_is_valid(pgp_key_t k)
+static bool pgp_key_is_valid(struct PgpKeyInfo *k)
 {
-  pgp_key_t pk = pgp_principal_key(k);
+  struct PgpKeyInfo *pk = pgp_principal_key(k);
   if (k->flags & KEYFLAG_CANTUSE)
     return false;
   if (pk->flags & KEYFLAG_CANTUSE)
@@ -420,7 +420,7 @@ static int pgp_id_matches_addr(struct Address *addr, struct Address *u_addr, pgp
   return rv;
 }
 
-static pgp_key_t pgp_select_key(pgp_key_t keys, struct Address *p, const char *s)
+static struct PgpKeyInfo *pgp_select_key(struct PgpKeyInfo *keys, struct Address *p, const char *s)
 {
   int keymax;
   pgp_uid_t **KeyTable;
@@ -430,7 +430,7 @@ static pgp_key_t pgp_select_key(pgp_key_t keys, struct Address *p, const char *s
   char cmd[LONG_STRING], tempfile[_POSIX_PATH_MAX];
   FILE *fp = NULL, *devnull = NULL;
   pid_t thepid;
-  pgp_key_t kp;
+  struct PgpKeyInfo *kp = NULL;
   pgp_uid_t *a = NULL;
   int (*f)(const void *, const void *);
 
@@ -631,9 +631,9 @@ static pgp_key_t pgp_select_key(pgp_key_t keys, struct Address *p, const char *s
   return kp;
 }
 
-pgp_key_t pgp_ask_for_key(char *tag, char *whatfor, short abilities, pgp_ring_t keyring)
+struct PgpKeyInfo *pgp_ask_for_key(char *tag, char *whatfor, short abilities, pgp_ring_t keyring)
 {
-  pgp_key_t key;
+  struct PgpKeyInfo *key = NULL;
   char resp[SHORT_STRING];
   struct pgp_cache *l = NULL;
 
@@ -689,7 +689,7 @@ struct Body *pgp_make_key_attachment(char *tempf)
   FILE *devnull = NULL;
   struct stat sb;
   pid_t thepid;
-  pgp_key_t key;
+  struct PgpKeyInfo *key = NULL;
   unset_option(OPTPGPCHECKTRUST);
 
   key = pgp_ask_for_key(_("Please enter the key ID: "), NULL, 0, PGP_PUBRING);
@@ -773,7 +773,7 @@ static struct List *pgp_add_string_to_hints(struct List *hints, const char *str)
   return hints;
 }
 
-static pgp_key_t *pgp_get_lastp(pgp_key_t p)
+static struct PgpKeyInfo **pgp_get_lastp(struct PgpKeyInfo *p)
 {
   for (; p; p = p->next)
     if (!p->next)
@@ -782,7 +782,7 @@ static pgp_key_t *pgp_get_lastp(pgp_key_t p)
   return NULL;
 }
 
-pgp_key_t pgp_getkeybyaddr(struct Address *a, short abilities, pgp_ring_t keyring, int oppenc_mode)
+struct PgpKeyInfo *pgp_getkeybyaddr(struct Address *a, short abilities, pgp_ring_t keyring, int oppenc_mode)
 {
   struct Address *r = NULL, *p = NULL;
   struct List *hints = NULL;
@@ -790,11 +790,11 @@ pgp_key_t pgp_getkeybyaddr(struct Address *a, short abilities, pgp_ring_t keyrin
   int multi = 0;
   int match;
 
-  pgp_key_t keys, k, kn;
-  pgp_key_t the_strong_valid_key = NULL;
-  pgp_key_t a_valid_addrmatch_key = NULL;
-  pgp_key_t matches = NULL;
-  pgp_key_t *last = &matches;
+  struct PgpKeyInfo *keys = NULL, *k = NULL, *kn = NULL;
+  struct PgpKeyInfo *the_strong_valid_key = NULL;
+  struct PgpKeyInfo *a_valid_addrmatch_key = NULL;
+  struct PgpKeyInfo *matches = NULL;
+  struct PgpKeyInfo **last = &matches;
   pgp_uid_t *q = NULL;
 
   if (a && a->mailbox)
@@ -911,13 +911,13 @@ pgp_key_t pgp_getkeybyaddr(struct Address *a, short abilities, pgp_ring_t keyrin
   return NULL;
 }
 
-pgp_key_t pgp_getkeybystr(char *p, short abilities, pgp_ring_t keyring)
+struct PgpKeyInfo *pgp_getkeybystr(char *p, short abilities, pgp_ring_t keyring)
 {
   struct List *hints = NULL;
-  pgp_key_t keys;
-  pgp_key_t matches = NULL;
-  pgp_key_t *last = &matches;
-  pgp_key_t k, kn;
+  struct PgpKeyInfo *keys = NULL;
+  struct PgpKeyInfo *matches = NULL;
+  struct PgpKeyInfo **last = &matches;
+  struct PgpKeyInfo *k = NULL, *kn = NULL;
   pgp_uid_t *a = NULL;
   short match;
   size_t l;
index 21828780222301578e465370f19c8a14f0d406a9..68e3e895c34b082c27160e15f600b313b62981c3 100644 (file)
--- a/pgplib.c
+++ b/pgplib.c
@@ -121,7 +121,7 @@ static void pgp_free_uid(pgp_uid_t **upp)
   *upp = NULL;
 }
 
-pgp_uid_t *pgp_copy_uids(pgp_uid_t *up, pgp_key_t parent)
+pgp_uid_t *pgp_copy_uids(pgp_uid_t *up, struct PgpKeyInfo *parent)
 {
   pgp_uid_t *l = NULL;
   pgp_uid_t **lp = &l;
@@ -139,9 +139,9 @@ pgp_uid_t *pgp_copy_uids(pgp_uid_t *up, pgp_key_t parent)
   return l;
 }
 
-static void _pgp_free_key(pgp_key_t *kpp)
+static void _pgp_free_key(struct PgpKeyInfo **kpp)
 {
-  pgp_key_t kp;
+  struct PgpKeyInfo *kp = NULL;
 
   if (!kpp || !*kpp)
     return;
@@ -151,14 +151,13 @@ static void _pgp_free_key(pgp_key_t *kpp)
   pgp_free_uid(&kp->address);
   FREE(&kp->keyid);
   FREE(&kp->fingerprint);
-  /* mutt_crypt.h: 'typedef struct pgp_keyinfo *pgp_key_t;' */
   FREE(kpp);
 }
 
-pgp_key_t pgp_remove_key(pgp_key_t *klist, pgp_key_t key)
+struct PgpKeyInfo *pgp_remove_key(struct PgpKeyInfo **klist, struct PgpKeyInfo *key)
 {
-  pgp_key_t *last = NULL;
-  pgp_key_t p, q, r;
+  struct PgpKeyInfo **last = NULL;
+  struct PgpKeyInfo *p = NULL, *q = NULL, *r = NULL;
 
   if (!klist || !*klist || !key)
     return NULL;
@@ -183,9 +182,9 @@ pgp_key_t pgp_remove_key(pgp_key_t *klist, pgp_key_t key)
   return q;
 }
 
-void pgp_free_key(pgp_key_t *kpp)
+void pgp_free_key(struct PgpKeyInfo **kpp)
 {
-  pgp_key_t p, q, r;
+  struct PgpKeyInfo *p = NULL, *q = NULL, *r = NULL;
 
   if (!kpp || !*kpp)
     return;
index 26300649ae5df41ee53bbb0f08476ccde1455450..7bfbffdc4003ff17f0225fd26871e1ff15a80fa1 100644 (file)
--- a/pgplib.h
+++ b/pgplib.h
@@ -32,7 +32,7 @@ typedef struct pgp_signature
   unsigned long sid2;
 } pgp_sig_t;
 
-struct pgp_keyinfo
+struct PgpKeyInfo
 {
   char *keyid;
   char *fingerprint;
@@ -42,18 +42,17 @@ struct pgp_keyinfo
   time_t gen_time;
   int numalg;
   const char *algorithm;
-  struct pgp_keyinfo *parent;
+  struct PgpKeyInfo *parent;
   struct pgp_signature *sigs;
-  struct pgp_keyinfo *next;
+  struct PgpKeyInfo *next;
 };
-/* Note, that pgp_key_t is now pointer and declared in crypt.h */
 
 typedef struct pgp_uid
 {
   char *addr;
   short trust;
   int flags;
-  struct pgp_keyinfo *parent;
+  struct PgpKeyInfo *parent;
   struct pgp_uid *next;
   struct pgp_signature *sigs;
 } pgp_uid_t;
@@ -70,18 +69,18 @@ enum pgp_version
 
 const char *pgp_pkalgbytype(unsigned char type);
 
-pgp_key_t pgp_remove_key(pgp_key_t *klist, pgp_key_t key);
-pgp_uid_t *pgp_copy_uids(pgp_uid_t *up, pgp_key_t parent);
+struct PgpKeyInfo *pgp_remove_key(struct PgpKeyInfo **klist, struct PgpKeyInfo *key);
+pgp_uid_t *pgp_copy_uids(pgp_uid_t *up, struct PgpKeyInfo *parent);
 
 bool pgp_canencrypt(unsigned char type);
 bool pgp_cansign(unsigned char type);
 short pgp_get_abilities(unsigned char type);
 
-void pgp_free_key(pgp_key_t *kpp);
+void pgp_free_key(struct PgpKeyInfo **kpp);
 
-static inline pgp_key_t pgp_new_keyinfo(void)
+static inline struct PgpKeyInfo *pgp_new_keyinfo(void)
 {
-  return safe_calloc(1, sizeof(*((pgp_key_t) 0)));
+  return safe_calloc(1, sizeof(struct PgpKeyInfo));
 }
 
 #endif /* CRYPT_BACKEND_CLASSIC_PGP */
index f0fac6ef7457527d3de0104d5fc8a1032249e771..0ec6f13574a733a4e8878cd3adf85b12cf7fc90a 100644 (file)
@@ -76,7 +76,7 @@ static void print_userid(const char *id)
   }
 }
 
-static void print_fingerprint(pgp_key_t p)
+static void print_fingerprint(struct PgpKeyInfo *p)
 {
   if (!p->fingerprint)
     return;
@@ -96,7 +96,7 @@ static void pgpring_dump_signatures(pgp_sig_t *sig)
   }
 }
 
-static void pgpring_dump_keyblock(pgp_key_t p)
+static void pgpring_dump_keyblock(struct PgpKeyInfo *p)
 {
   pgp_uid_t *uid = NULL;
   short first;
@@ -233,9 +233,9 @@ static char *binary_fingerprint_to_string(unsigned char *buff, size_t length)
   return fingerprint;
 }
 
-static pgp_key_t pgp_parse_pgp2_key(unsigned char *buff, size_t l)
+static struct PgpKeyInfo *pgp_parse_pgp2_key(unsigned char *buff, size_t l)
 {
-  pgp_key_t p;
+  struct PgpKeyInfo *p = NULL;
   unsigned char alg;
   unsigned char digest[MD5_DIGEST_LENGTH];
   size_t expl;
@@ -342,9 +342,9 @@ static void skip_bignum(unsigned char *buff, size_t l, size_t j, size_t *toff, s
     *toff = j;
 }
 
-static pgp_key_t pgp_parse_pgp3_key(unsigned char *buff, size_t l)
+static struct PgpKeyInfo *pgp_parse_pgp3_key(unsigned char *buff, size_t l)
 {
-  pgp_key_t p;
+  struct PgpKeyInfo *p = NULL;
   unsigned char alg;
   unsigned char digest[SHA_DIGEST_LENGTH];
   unsigned char scratch[LONG_STRING];
@@ -398,7 +398,7 @@ static pgp_key_t pgp_parse_pgp3_key(unsigned char *buff, size_t l)
   return p;
 }
 
-static pgp_key_t pgp_parse_keyinfo(unsigned char *buff, size_t l)
+static struct PgpKeyInfo *pgp_parse_keyinfo(unsigned char *buff, size_t l)
 {
   if (!buff || l < 2)
     return NULL;
@@ -415,7 +415,7 @@ static pgp_key_t pgp_parse_keyinfo(unsigned char *buff, size_t l)
   }
 }
 
-static int pgp_parse_pgp2_sig(unsigned char *buff, size_t l, pgp_key_t p, pgp_sig_t *s)
+static int pgp_parse_pgp2_sig(unsigned char *buff, size_t l, struct PgpKeyInfo *p, pgp_sig_t *s)
 {
   unsigned char sigtype;
   time_t sig_gen_time;
@@ -455,7 +455,7 @@ static int pgp_parse_pgp2_sig(unsigned char *buff, size_t l, pgp_key_t p, pgp_si
   return 0;
 }
 
-static int pgp_parse_pgp3_sig(unsigned char *buff, size_t l, pgp_key_t p, pgp_sig_t *s)
+static int pgp_parse_pgp3_sig(unsigned char *buff, size_t l, struct PgpKeyInfo *p, pgp_sig_t *s)
 {
   unsigned char sigtype;
   unsigned char skt;
@@ -594,7 +594,7 @@ static int pgp_parse_pgp3_sig(unsigned char *buff, size_t l, pgp_key_t p, pgp_si
   return 0;
 }
 
-static int pgp_parse_sig(unsigned char *buff, size_t l, pgp_key_t p, pgp_sig_t *sig)
+static int pgp_parse_sig(unsigned char *buff, size_t l, struct PgpKeyInfo *p, pgp_sig_t *sig)
 {
   if (!buff || l < 2 || !p)
     return -1;
@@ -613,7 +613,7 @@ static int pgp_parse_sig(unsigned char *buff, size_t l, pgp_key_t p, pgp_sig_t *
 
 /* parse one key block, including all subkeys. */
 
-static pgp_key_t pgp_parse_keyblock(FILE *fp)
+static struct PgpKeyInfo *pgp_parse_keyblock(FILE *fp)
 {
   unsigned char *buff = NULL;
   unsigned char pt = 0;
@@ -623,9 +623,9 @@ static pgp_key_t pgp_parse_keyblock(FILE *fp)
 
   fpos_t pos;
 
-  pgp_key_t root = NULL;
-  pgp_key_t *last = &root;
-  pgp_key_t p = NULL;
+  struct PgpKeyInfo *root = NULL;
+  struct PgpKeyInfo **last = &root;
+  struct PgpKeyInfo *p = NULL;
   pgp_uid_t *uid = NULL;
   pgp_uid_t **addr = NULL;
   pgp_sig_t **lsig = NULL;
@@ -805,7 +805,7 @@ static void pgpring_find_candidates(char *ringfile, const char *hints[], int nhi
 
       if (pgpring_string_matches_hint(tmp, hints, nhints))
       {
-        pgp_key_t p;
+        struct PgpKeyInfo *p = NULL;
 
         fsetpos(rfp, &keypos);