X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=pgpkey.c;h=b31676a5ec5985c42f911f36f4929670c25c2f19;hp=640f080b72e03196d69ba2927a6d082ccba0814e;hb=2891636277fb96f992eaf08b4e6acc11ca9ea57c;hpb=bbc4fd52516a8afefbd14c77e34f8389d6f0a6ed diff --git a/pgpkey.c b/pgpkey.c index 640f080..b31676a 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -12,20 +12,23 @@ # include "config.h" #endif +#include +#include +#include +#include +#include + +#include + #include "mutt.h" #include "enter.h" -#include "ascii.h" #include "recvattach.h" #include "mutt_curses.h" #include "mutt_menu.h" -#include "mime.h" #include "pgp.h" #include "pager.h" #include "sort.h" -#include "lib/mem.h" -#include "lib/intl.h" -#include "lib/str.h" #include "lib/debug.h" #include @@ -37,8 +40,6 @@ #include -#ifdef CRYPT_BACKEND_CLASSIC_PGP - struct pgp_cache { char *what; char *dflt; @@ -281,10 +282,10 @@ static int _pgp_compare_address (const void *a, const void *b) pgp_uid_t **s = (pgp_uid_t **) a; pgp_uid_t **t = (pgp_uid_t **) b; - if ((r = str_casecmp ((*s)->addr, (*t)->addr))) + if ((r = m_strcasecmp((*s)->addr, (*t)->addr))) return r > 0; else - return (str_casecmp (_pgp_keyid ((*s)->parent), + return (m_strcasecmp(_pgp_keyid ((*s)->parent), _pgp_keyid ((*t)->parent)) > 0); } @@ -303,11 +304,11 @@ static int _pgp_compare_keyid (const void *a, const void *b) pgp_uid_t **s = (pgp_uid_t **) a; pgp_uid_t **t = (pgp_uid_t **) b; - if ((r = str_casecmp (_pgp_keyid ((*s)->parent), + if ((r = m_strcasecmp(_pgp_keyid ((*s)->parent), _pgp_keyid ((*t)->parent)))) return r > 0; else - return (str_casecmp ((*s)->addr, (*t)->addr)) > 0; + return (m_strcasecmp((*s)->addr, (*t)->addr)) > 0; } static int pgp_compare_keyid (const void *a, const void *b) @@ -324,7 +325,7 @@ static int _pgp_compare_date (const void *a, const void *b) if ((r = ((*s)->parent->gen_time - (*t)->parent->gen_time))) return r > 0; - return (str_casecmp ((*s)->addr, (*t)->addr)) > 0; + return (m_strcasecmp((*s)->addr, (*t)->addr)) > 0; } static int pgp_compare_date (const void *a, const void *b) @@ -349,9 +350,9 @@ static int _pgp_compare_trust (const void *a, const void *b) return r < 0; if ((r = ((*s)->parent->gen_time - (*t)->parent->gen_time))) return r < 0; - if ((r = str_casecmp ((*s)->addr, (*t)->addr))) + if ((r = m_strcasecmp((*s)->addr, (*t)->addr))) return r > 0; - return (str_casecmp (_pgp_keyid ((*s)->parent), + return (m_strcasecmp(_pgp_keyid ((*s)->parent), _pgp_keyid ((*t)->parent))) > 0; } @@ -398,7 +399,7 @@ static int pgp_id_is_valid (pgp_uid_t * uid) #define PGP_KV_MATCH (PGP_KV_ADDR|PGP_KV_STRING) -static int pgp_id_matches_addr (ADDRESS * addr, ADDRESS * u_addr, +static int pgp_id_matches_addr (address_t * addr, address_t * u_addr, pgp_uid_t * uid) { int rv = 0; @@ -410,17 +411,17 @@ static int pgp_id_matches_addr (ADDRESS * addr, ADDRESS * u_addr, rv |= PGP_KV_STRONGID; if (addr->mailbox && u_addr->mailbox - && str_casecmp (addr->mailbox, u_addr->mailbox) == 0) + && m_strcasecmp(addr->mailbox, u_addr->mailbox) == 0) rv |= PGP_KV_ADDR; if (addr->personal && u_addr->personal - && str_casecmp (addr->personal, u_addr->personal) == 0) + && m_strcasecmp(addr->personal, u_addr->personal) == 0) rv |= PGP_KV_STRING; return rv; } -static pgp_key_t pgp_select_key (pgp_key_t keys, ADDRESS * p, const char *s) +static pgp_key_t pgp_select_key (pgp_key_t keys, address_t * p, const char *s) { int keymax; pgp_uid_t **KeyTable; @@ -453,7 +454,7 @@ static pgp_key_t pgp_select_key (pgp_key_t keys, ADDRESS * p, const char *s) if (i == keymax) { keymax += 5; - mem_realloc (&KeyTable, sizeof (pgp_uid_t *) * keymax); + p_realloc(&KeyTable, keymax); } KeyTable[i++] = a; @@ -581,7 +582,7 @@ static pgp_key_t pgp_select_key (pgp_key_t keys, ADDRESS * p, const char *s) if (option (OPTPGPCHECKTRUST) && (!pgp_id_is_valid (KeyTable[menu->current]) || !pgp_id_is_strong (KeyTable[menu->current]))) { - char *s = ""; + const char *s = ""; char buff[LONG_STRING]; if (KeyTable[menu->current]->flags & KEYFLAG_CANTUSE) @@ -625,7 +626,7 @@ static pgp_key_t pgp_select_key (pgp_key_t keys, ADDRESS * p, const char *s) } mutt_menuDestroy (&menu); - mem_free (&KeyTable); + p_delete(&KeyTable); set_option (OPTNEEDREDRAW); @@ -645,27 +646,27 @@ pgp_key_t pgp_ask_for_key (char *tag, char *whatfor, if (whatfor) { for (l = id_defaults; l; l = l->next) - if (!str_casecmp (whatfor, l->what)) { - strfcpy (resp, NONULL (l->dflt), sizeof (resp)); + if (!m_strcasecmp(whatfor, l->what)) { + m_strcpy(resp, sizeof(resp), NONULL(l->dflt)); break; } } - FOREVER { + for (;;) { resp[0] = 0; if (mutt_get_field (tag, resp, sizeof (resp), M_CLEAR) != 0) return NULL; if (whatfor) { if (l) - str_replace (&l->dflt, resp); + m_strreplace(&l->dflt, resp); else { - l = mem_malloc (sizeof (struct pgp_cache)); + l = p_new(struct pgp_cache, 1); l->next = id_defaults; id_defaults = l; - l->what = str_dup (whatfor); - l->dflt = str_dup (resp); + l->what = m_strdup(whatfor); + l->dflt = m_strdup(resp); } } @@ -741,13 +742,13 @@ BODY *pgp_make_key_attachment (char *tempf) fclose (devnull); att = mutt_new_body (); - att->filename = str_dup (tempf); + att->filename = m_strdup(tempf); att->unlink = 1; att->use_disp = 0; att->type = TYPEAPPLICATION; - att->subtype = str_dup ("pgp-keys"); + att->subtype = m_strdup("pgp-keys"); snprintf (buff, sizeof (buff), _("PGP Key %s."), tmp); - att->description = str_dup (buff); + att->description = m_strdup(buff); mutt_update_encoding (att); stat (tempf, &sb); @@ -761,16 +762,16 @@ static LIST *pgp_add_string_to_hints (LIST * hints, const char *str) char *scratch; char *t; - if ((scratch = str_dup (str)) == NULL) + if ((scratch = m_strdup(str)) == NULL) return hints; for (t = strtok (scratch, " ,.:\"()<>\n"); t; t = strtok (NULL, " ,.:\"()<>\n")) { - if (str_len (t) > 3) + if (m_strlen(t) > 3) hints = mutt_add_list (hints, t); } - mem_free (&scratch); + p_delete(&scratch); return hints; } @@ -783,9 +784,9 @@ static pgp_key_t *pgp_get_lastp (pgp_key_t p) return NULL; } -pgp_key_t pgp_getkeybyaddr (ADDRESS * a, short abilities, pgp_ring_t keyring) +pgp_key_t pgp_getkeybyaddr (address_t * a, short abilities, pgp_ring_t keyring) { - ADDRESS *r, *p; + address_t *r, *p; LIST *hints = NULL; int weak = 0; @@ -858,7 +859,7 @@ pgp_key_t pgp_getkeybyaddr (ADDRESS * a, short abilities, pgp_ring_t keyring) this_key_has_weak = 1; } - rfc822_free_address (&r); + address_delete (&r); } if (match && !this_key_has_strong && this_key_has_invalid) @@ -931,12 +932,12 @@ pgp_key_t pgp_getkeybystr (char *p, short abilities, pgp_ring_t keyring) for (a = k->address; a; a = a->next) { debug_print (5, ("matching \"%s\" against key %s, \"%s\":\n", p, pgp_keyid (k), a->addr)); - if (!*p || str_casecmp (p, pgp_keyid (k)) == 0 - || (!str_ncasecmp (p, "0x", 2) - && !str_casecmp (p + 2, pgp_keyid (k))) - || (option (OPTPGPLONGIDS) && !str_ncasecmp (p, "0x", 2) - && !str_casecmp (p + 2, k->keyid + 8)) - || str_isstr (a->addr, p)) { + if (!*p || m_strcasecmp(p, pgp_keyid (k)) == 0 + || (!m_strncasecmp(p, "0x", 2) + && !m_strcasecmp(p + 2, pgp_keyid (k))) + || (option (OPTPGPLONGIDS) && !m_strncasecmp(p, "0x", 2) + && !m_strcasecmp(p + 2, k->keyid + 8)) + || m_stristr(a->addr, p)) { debug_print (5, ("match.\n")); match = 1; break; @@ -963,6 +964,3 @@ pgp_key_t pgp_getkeybystr (char *p, short abilities, pgp_ring_t keyring) return NULL; } - - -#endif /* CRYPT_BACKEND_CLASSIC_PGP */