simplify parse_parameters tokenizer
[apps/madmutt.git] / crypt-gpgme.c
index e920128..145a6e0 100644 (file)
 #include <lib-lib/macros.h>
 #include <lib-lib/file.h>
 
+#include <lib-mime/mime.h>
+
 #include "mutt.h"
-#include "mutt_crypt.h"
+#include <lib-crypt/crypt.h>
 #include "mutt_menu.h"
 #include "mutt_curses.h"
 #include "handler.h"
 #include "enter.h"
-#include "mime.h"
 #include "copy.h"
 #include "pager.h"
 #include "recvattach.h"
@@ -287,7 +288,7 @@ static int crypt_id_is_valid (crypt_key_t * key)
 
 /* Return a bit vector describing how well the addresses ADDR and
    U_ADDR match and whether KEY is valid. */
-static int crypt_id_matches_addr (ADDRESS * addr, ADDRESS * u_addr,
+static int crypt_id_matches_addr (address_t * addr, address_t * u_addr,
                                   crypt_key_t * key)
 {
   int rv = 0;
@@ -3232,7 +3233,7 @@ static LIST *crypt_add_string_to_hints (LIST * hints, const char *str)
    will be set to true on return if the user did override the the
    key's validity. */
 static crypt_key_t *crypt_select_key (crypt_key_t * keys,
-                                      ADDRESS * p, const char *s,
+                                      address_t * p, const char *s,
                                       unsigned int app, int *forced_valid)
 {
   int keymax;
@@ -3423,10 +3424,10 @@ static crypt_key_t *crypt_select_key (crypt_key_t * keys,
   return k;
 }
 
-static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities,
+static crypt_key_t *crypt_getkeybyaddr (address_t * a, short abilities,
                                         unsigned int app, int *forced_valid)
 {
-  ADDRESS *r, *p;
+  address_t *r, *p;
   LIST *hints = NULL;
 
   int weak = 0;
@@ -3496,7 +3497,7 @@ static crypt_key_t *crypt_getkeybyaddr (ADDRESS * a, short abilities,
                    || !(validity & CRYPT_KV_ADDR)))
         this_key_has_weak = 1;
     }
-    rfc822_free_address (&r);
+    address_delete (&r);
 
     if (match) {
       crypt_key_t *tmp;
@@ -3575,7 +3576,7 @@ static crypt_key_t *crypt_getkeybystr (char *p, short abilities,
         || (option (OPTPGPLONGIDS)
             && !m_strncasecmp(p, "0x", 2)
             && !m_strcasecmp(p + 2, crypt_keyid (k) + 8))
-        || str_isstr (k->uid, p)) {
+        || m_stristr(k->uid, p)) {
       crypt_key_t *tmp;
 
       debug_print (5, ("match.\n"));
@@ -3635,7 +3636,7 @@ static crypt_key_t *crypt_ask_for_key (char *tag,
 
     if (whatfor) {
       if (l)
-        str_replace (&l->dflt, resp);
+        m_strreplace(&l->dflt, resp);
       else {
         l = p_new(struct crypt_cache, 1);
         l->next = id_defaults;
@@ -3655,15 +3656,15 @@ static crypt_key_t *crypt_ask_for_key (char *tag,
 
 /* This routine attempts to find the keyids of the recipients of a
    message.  It returns NULL if any of the keys can not be found.  */
-static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc,
+static char *find_keys (address_t * to, address_t * cc, address_t * bcc,
                         unsigned int app)
 {
   char *keyID, *keylist = NULL, *t;
   size_t keylist_size = 0;
   size_t keylist_used = 0;
-  ADDRESS *tmp = NULL, *addr = NULL;
-  ADDRESS **last = &tmp;
-  ADDRESS *p, *q;
+  address_t *tmp = NULL, *addr = NULL;
+  address_t **last = &tmp;
+  address_t *p, *q;
   int i;
   crypt_key_t *k_info, *key;
   const char *fqdn = mutt_fqdn (1);
@@ -3687,7 +3688,7 @@ static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc,
       abort ();
     }
 
-    *last = rfc822_cpy_adr (p);
+    *last = address_list_dup (p);
     while (*last)
       last = &((*last)->next);
   }
@@ -3729,8 +3730,8 @@ static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc,
       }
       else if (r == -1) {
         p_delete(&keylist);
-        rfc822_free_address (&tmp);
-        rfc822_free_address (&addr);
+        address_delete (&tmp);
+        address_delete (&addr);
         return NULL;
       }
     }
@@ -3748,8 +3749,8 @@ static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc,
 #endif
                                     &forced_valid)) == NULL) {
         p_delete(&keylist);
-        rfc822_free_address (&tmp);
-        rfc822_free_address (&addr);
+        address_delete (&tmp);
+        address_delete (&addr);
         return NULL;
       }
     }
@@ -3774,18 +3775,18 @@ static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc,
     keylist_used = m_strlen(keylist);
 
     crypt_free_key (&key);
-    rfc822_free_address (&addr);
+    address_delete (&addr);
   }
-  rfc822_free_address (&tmp);
+  address_delete (&tmp);
   return (keylist);
 }
 
-char *pgp_gpgme_findkeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc)
+char *pgp_gpgme_findkeys (address_t * to, address_t * cc, address_t * bcc)
 {
   return find_keys (to, cc, bcc, APPLICATION_PGP);
 }
 
-char *smime_gpgme_findkeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc)
+char *smime_gpgme_findkeys (address_t * to, address_t * cc, address_t * bcc)
 {
   return find_keys (to, cc, bcc, APPLICATION_SMIME);
 }
@@ -3853,7 +3854,7 @@ static int gpgme_send_menu (HEADER * msg, int *redraw, int is_smime)
                                 is_smime ? APPLICATION_SMIME :
                                 APPLICATION_PGP, NULL))) {
       snprintf (input_signas, sizeof (input_signas), "0x%s", crypt_keyid (p));
-      str_replace (is_smime ? &SmimeDefaultKey : &PgpSignAs,
+      m_strreplace(is_smime ? &SmimeDefaultKey : &PgpSignAs,
                         input_signas);
       crypt_free_key (&p);
 
@@ -3906,7 +3907,7 @@ int smime_gpgme_send_menu (HEADER * msg, int *redraw)
 
 static int verify_sender (HEADER * h, gpgme_protocol_t protocol)
 {
-  ADDRESS *sender = NULL;
+  address_t *sender = NULL;
   unsigned int ret = 1;
 
   if (h->env->from) {